[GHC] #12076: "lazy" leads to undefined reference to `stg_ap_0_upd_info'

#12076: "lazy" leads to undefined reference to `stg_ap_0_upd_info' -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1-rc2 (CodeGen) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- This is basically the same thing as #11155 but triggered differently. {{{ -- M.hs {-# OPTIONS_GHC -O0 #-} module M(f) where import GHC.Exts {-# NOINLINE z #-} z = () f :: () -> () f _ = let x = lazy z in g x x {-# NOINLINE g #-} g :: () -> () -> () g _ _ = () -- MM.hs import M main = f `seq` return () }}} On GHC 8.0, I get: {{{ ezyang@sabre:~$ ghc-8.0 --make MM.hs -fforce-recomp [1 of 2] Compiling M ( M.hs, M.o ) [2 of 2] Compiling Main ( MM.hs, MM.o ) Linking MM ... ./M.o: In function `r2aD_info': (.text+0x4a): undefined reference to `stg_ap_0_upd_info' collect2: error: ld returned 1 exit status `gcc' failed in phase `Linker'. (Exit code: 1) }}} Error goes away when you turn on optimization. My understanding is that removing `lazy` in `CorePrep` is too late, because there's no pass afterwards that eliminates the trivial thunk assignment. This is blocking Phab:D2211, where the insertion of a `noinline` (which is optimized out similarly to `lazy`) triggers a stage 2 linker failure when you don't compile with optimization (unfortunately, this is NOT caught validate since we build GHC with optimization... but with this test it will be!) Perhaps there should be an ASSERT in the codegen so it doesn't create this symbol? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12076 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12076: "lazy" leads to undefined reference to `stg_ap_0_upd_info' -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1-rc2 (CodeGen) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by ezyang: @@ -41,1 +41,22 @@ - afterwards that eliminates the trivial thunk assignment. + afterwards that eliminates the trivial thunk assignment. Here's the STG: + + {{{ + z_r2aC :: () + [GblId, Caf=NoCafRefs, Str=DmdType, Unf=OtherCon []] = + NO_CCS ()! []; + + g_r2aD :: () -> () -> () + [GblId, Arity=2, Caf=NoCafRefs, Str=DmdType, Unf=OtherCon []] = + sat-only \r srt:SRT:[] [ds_s2rW ds1_s2rX] () []; + + M.f :: () -> () + [GblId, Arity=1, Caf=NoCafRefs, Str=DmdType, Unf=OtherCon []] = + \r srt:SRT:[] [ds_s2rY] + let { + x_s2rZ :: () + [LclId, Str=DmdType, Unf=OtherCon []] = + \u srt:SRT:[] [] z_r2aC; + } in g_r2aD x_s2rZ x_s2rZ; + }}} + + so we need, instead, something like `x_s2rZ = z_r2aC`. New description: This is basically the same thing as #11155 but triggered differently. {{{ -- M.hs {-# OPTIONS_GHC -O0 #-} module M(f) where import GHC.Exts {-# NOINLINE z #-} z = () f :: () -> () f _ = let x = lazy z in g x x {-# NOINLINE g #-} g :: () -> () -> () g _ _ = () -- MM.hs import M main = f `seq` return () }}} On GHC 8.0, I get: {{{ ezyang@sabre:~$ ghc-8.0 --make MM.hs -fforce-recomp [1 of 2] Compiling M ( M.hs, M.o ) [2 of 2] Compiling Main ( MM.hs, MM.o ) Linking MM ... ./M.o: In function `r2aD_info': (.text+0x4a): undefined reference to `stg_ap_0_upd_info' collect2: error: ld returned 1 exit status `gcc' failed in phase `Linker'. (Exit code: 1) }}} Error goes away when you turn on optimization. My understanding is that removing `lazy` in `CorePrep` is too late, because there's no pass afterwards that eliminates the trivial thunk assignment. Here's the STG: {{{ z_r2aC :: () [GblId, Caf=NoCafRefs, Str=DmdType, Unf=OtherCon []] = NO_CCS ()! []; g_r2aD :: () -> () -> () [GblId, Arity=2, Caf=NoCafRefs, Str=DmdType, Unf=OtherCon []] = sat-only \r srt:SRT:[] [ds_s2rW ds1_s2rX] () []; M.f :: () -> () [GblId, Arity=1, Caf=NoCafRefs, Str=DmdType, Unf=OtherCon []] = \r srt:SRT:[] [ds_s2rY] let { x_s2rZ :: () [LclId, Str=DmdType, Unf=OtherCon []] = \u srt:SRT:[] [] z_r2aC; } in g_r2aD x_s2rZ x_s2rZ; }}} so we need, instead, something like `x_s2rZ = z_r2aC`. This is blocking Phab:D2211, where the insertion of a `noinline` (which is optimized out similarly to `lazy`) triggers a stage 2 linker failure when you don't compile with optimization (unfortunately, this is NOT caught validate since we build GHC with optimization... but with this test it will be!) Perhaps there should be an ASSERT in the codegen so it doesn't create this symbol? -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12076#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

Perhaps there should be an ASSERT in the codegen so it doesn't create
#12076: "lazy" leads to undefined reference to `stg_ap_0_upd_info' -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1-rc2 (CodeGen) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: => 8.0.2 Comment: this symbol? +1. It's silly that we get all the way to linking with this code. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12076#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12076: "lazy" leads to undefined reference to `stg_ap_0_upd_info'
-------------------------------------+-------------------------------------
Reporter: ezyang | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 8.0.2
Component: Compiler | Version: 8.0.1-rc2
(CodeGen) |
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#12076: "lazy" leads to undefined reference to `stg_ap_0_upd_info' -------------------------------------+------------------------------------- Reporter: ezyang | Owner: ezyang Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1-rc2 (CodeGen) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by ezyang): * owner: => ezyang -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12076#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12076: "lazy" leads to undefined reference to `stg_ap_0_upd_info' -------------------------------------+------------------------------------- Reporter: ezyang | Owner: ezyang Type: bug | Status: patch Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1-rc2 (CodeGen) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2309 Wiki Page: | -------------------------------------+------------------------------------- Changes (by ezyang): * status: new => patch * differential: => Phab:D2309 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12076#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12076: "lazy" leads to undefined reference to `stg_ap_0_upd_info'
-------------------------------------+-------------------------------------
Reporter: ezyang | Owner: ezyang
Type: bug | Status: patch
Priority: normal | Milestone: 8.0.2
Component: Compiler | Version: 8.0.1-rc2
(CodeGen) |
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D2309
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Edward Z. Yang

#12076: "lazy" leads to undefined reference to `stg_ap_0_upd_info' -------------------------------------+------------------------------------- Reporter: ezyang | Owner: ezyang Type: bug | Status: merge Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1-rc2 (CodeGen) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2309 Wiki Page: | -------------------------------------+------------------------------------- Changes (by ezyang): * status: patch => merge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12076#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12076: "lazy" leads to undefined reference to `stg_ap_0_upd_info' -------------------------------------+------------------------------------- Reporter: ezyang | Owner: ezyang Type: bug | Status: merge Priority: high | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1-rc2 (CodeGen) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2309 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * priority: normal => high Comment: This actually seems to affect a number of packages (e.g. `servant- server`), especially when built with `-O0`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12076#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12076: "lazy" leads to undefined reference to `stg_ap_0_upd_info' -------------------------------------+------------------------------------- Reporter: ezyang | Owner: ezyang Type: bug | Status: closed Priority: high | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1-rc2 (CodeGen) | Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2309 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Merged as 2a9767ed596679ddf21b7edfa9fc6410443c2a01. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12076#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12076: "lazy" leads to undefined reference to `stg_ap_0_upd_info' -------------------------------------+------------------------------------- Reporter: ezyang | Owner: ezyang Type: bug | Status: merge Priority: high | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1-rc2 (CodeGen) | Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2309 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: closed => merge Comment: Phab:D2471 fixes a performance regression in the `binary-tree` nofib test introduced by comment:6. It was merged to `master` as 83b326cda759cfd4c538595cf38ee23eb81a4c76. It should likely be merged to `ghc-8.0`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12076#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12076: "lazy" leads to undefined reference to `stg_ap_0_upd_info' -------------------------------------+------------------------------------- Reporter: ezyang | Owner: ezyang Type: bug | Status: closed Priority: high | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1-rc2 (CodeGen) | Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2309 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed Comment: comment:6 was merged to `ghc-8.0` as 2a9767ed596679ddf21b7edfa9fc6410443c2a01. The `binary-trees` regression fix was merged as 47d589ef52ded1ab3f81994f6567dac666e08587. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12076#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC