
#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