[GHC] #11823: Undefined stg_sel_17_upd_info symbols on OS X

#11823: Undefined stg_sel_17_upd_info symbols on OS X -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Keywords: | Operating System: MacOS X Architecture: x86_64 | Type of failure: Building GHC (amd64) | failed Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Several people have reported that recent `ghc-8.0` and `master` snapshots fail to build on OS X, {{{ HC [stage 1] ghc/stage2/build/tmp/ghc-stage2 Warning: -rtsopts and -with-rtsopts have no effect with -no-hs-main. Call hs_init_ghc() from your main() function to set these options. Undefined symbols for architecture x86_64: "_stg_sel_17_upd_info", referenced from: _s1s8Z_info in UI.dyn_o _s1s9w_info in UI.dyn_o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) `gcc' failed in phase `Linker'. (Exit code: 1) }}} These were originally introduced in #11555, although this appears to be a much different beast from the original issue that ticket was reporting: the symbols in question here are update closures, not application closures like in #11555. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11823 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11823: Undefined stg_sel_17_upd_info symbols on OS X -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 Type of failure: Building GHC | (amd64) failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): It would be likely be helpful if someone affected by the issue could post the simplified Core and STG of `UI.hs` from their stage 2 build. Running the following should do the trick, {{{ $ touch ghc/GHCi/UI.hs $ make GhcStage2HcOpts='-ddump-to-file -ddump-simpl -ddump-stg' }}} You should then find `UI.dump-{simpl,stg}` files in `ghc/GHCi`. Be sure to also take note of which symbols appear in the "referenced from" list in the linker error. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11823#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11823: Undefined stg_sel_17_upd_info symbols on OS X -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 Type of failure: Building GHC | (amd64) failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by bgamari: @@ -17,1 +17,1 @@ - These were originally introduced in #11555, although this appears to be a + These were originally introduced in #11155, although this appears to be a @@ -20,1 +20,1 @@ - like in #11555. + like in #11155. New description: Several people have reported that recent `ghc-8.0` and `master` snapshots fail to build on OS X, {{{ HC [stage 1] ghc/stage2/build/tmp/ghc-stage2 Warning: -rtsopts and -with-rtsopts have no effect with -no-hs-main. Call hs_init_ghc() from your main() function to set these options. Undefined symbols for architecture x86_64: "_stg_sel_17_upd_info", referenced from: _s1s8Z_info in UI.dyn_o _s1s9w_info in UI.dyn_o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) `gcc' failed in phase `Linker'. (Exit code: 1) }}} These were originally introduced in #11155, although this appears to be a much different beast from the original issue that ticket was reporting: the symbols in question here are update closures, not application closures like in #11155. -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11823#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11823: Undefined stg_sel_17_upd_info symbols on OS X -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 Type of failure: Building GHC | (amd64) failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by bgamari: @@ -19,2 +19,2 @@ - the symbols in question here are update closures, not application closures - like in #11155. + the symbols in question here are updatable selector closures, not + application closures like in #11155. New description: Several people have reported that recent `ghc-8.0` and `master` snapshots fail to build on OS X, {{{ HC [stage 1] ghc/stage2/build/tmp/ghc-stage2 Warning: -rtsopts and -with-rtsopts have no effect with -no-hs-main. Call hs_init_ghc() from your main() function to set these options. Undefined symbols for architecture x86_64: "_stg_sel_17_upd_info", referenced from: _s1s8Z_info in UI.dyn_o _s1s9w_info in UI.dyn_o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) `gcc' failed in phase `Linker'. (Exit code: 1) }}} These were originally introduced in #11155, although this appears to be a much different beast from the original issue that ticket was reporting: the symbols in question here are updatable selector closures, not application closures like in #11155. -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11823#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11823: Undefined stg_sel_17_upd_info symbols on OS X -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 Type of failure: Building GHC | (amd64) failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): So the cause here is that we only generate special selector frames for up to arity 15 (see `rts/StgStdThunks.cmm`). For anything higher we are supposed to use the selector closure that we generate for the type in question. For consider the following, {{{#!hs module Test where data Hello = Hello { f1, f2, f3, f4 , f5, f6, f7, f8 , f9, f10, f11, f12 , f13, f14, f15, f16 , f17 :: String } juno :: Hello -> IO () juno = putStrLn . f16 turtle :: Hello -> IO () turtle = putStrLn . f17 }}} `juno` will produce code resembling, {{{ Hi.turtle1_entry() { ... // heap/stack check throat-clearing I64[Hp - 16] = stg_sel_15_noupd_info; P64[Hp] = R2; R4 = GHC.Types.True_closure+2; R3 = Hp - 16; R2 = GHC.IO.Handle.FD.stdout_closure; call GHC.IO.Handle.Text.hPutStr2_info(R4, R3, R2) args: 8, res: 0, upd: 8; } }}} Whereas `turtle` will use a helper function, {{{ Hi.turtle1_entry() { ... // heap/stack check throat-clearing I64[Hp - 16] = sat_s16u_info; P64[Hp] = _s16a::P64; _c1dl::P64 = Hp - 16; R4 = GHC.Types.True_closure+2; R3 = _c1dl::P64; R2 = GHC.IO.Handle.FD.stdout_closure; call GHC.IO.Handle.Text.hPutStr2_info(R4, R3, R2) args: 8, res: 0, upd: 8; } sat_s16u_entry() { ... // heap/stack check throat-clearing I64[Sp - 8] = c1dp; R1 = P64[R1 + 16]; Sp = Sp - 8; if (R1 & 7 != 0) goto c1dp; else goto c1dq; c1dq: call (I64[R1])(R1) returns to c1dp, args: 8, res: 8, upd: 8; c1dp: R1 = P64[R1 + 135] & (-8); Sp = Sp + 8; call (I64[R1])(R1) args: 8, res: 0, upd: 8; } }}} I haven't yet worked out where we decide which of these forms will be used. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11823#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11823: Undefined stg_sel_17_upd_info symbols on OS X -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 Type of failure: Building GHC | (amd64) failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): It seems like the check responsible for determining which of these selector schemes will be used is in `StgCmmBind.mkRhsClosure`, with the maximum size being `MAX_SPEC_SELECTEE_SIZE`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11823#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11823: Undefined stg_sel_17_upd_info symbols on OS X -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 Type of failure: Building GHC | (amd64) failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * cc: simonmar (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11823#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11823: Undefined stg_sel_17_upd_info symbols on OS X -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 Type of failure: Building GHC | (amd64) failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by gridaphobe): Here's a dump of the Core, STG, and C-- if you still need it. https://dl.dropboxusercontent.com/u/6177472/UI.dump.tar.gz -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11823#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11823: Undefined stg_sel_17_upd_info symbols on OS X -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 Type of failure: Building GHC | (amd64) failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by George): The error I am getting on rc3 is slightly different than the one in the description. Mine is: {{{ Undefined symbols for architecture x86_64: "_stg_sel_17_upd_info", referenced from: _s1xEL_info in UI.dyn_o _s1xG6_info in UI.dyn_o _s1xPC_info in UI.dyn_o _s1xQ9_info in UI.dyn_o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) `gcc' failed in phase `Linker'. (Exit code: 1) make[1]: *** [ghc/stage2/build/tmp/ghc-stage2] Error 1 make: *** [all] Error 2 }}} After doing {{{ $ touch ghc/GHCi/UI.hs $ make GhcStage2HcOpts='-ddump-to-file -ddump-simpl -ddump-stg -ddump-cmm' }}} I get: {{{ Undefined symbols for architecture x86_64: "_stg_sel_17_upd_info", referenced from: _s1rNh_info in UI.dyn_o _s1rNO_info in UI.dyn_o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) `gcc' failed in phase `Linker'. (Exit code: 1) make[1]: *** [ghc/stage2/build/tmp/ghc-stage2] Error 1 make: *** [all] Error 2 }}} Do you still want the UI.dump-{simpl,stg,cmm} files I get at this point? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11823#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11823: Undefined stg_sel_17_upd_info symbols on OS X -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 Type of failure: Building GHC | (amd64) failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): Great, thanks everyone who contributed dumps. This is quite bizarre: the pattern match in question appears to be selecting the 20th field of a `GHCiState` constructor (citing the STG), {{{#!hs let { sat_s1rNg :: [GHC.Types.Char] = \u srt:SRT:[] [] case ipv146_s1rMI of _ { GHCi.UI.Monad.GHCiState _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ds36_s1rNa _ _ _ _ _ -> ds36_s1rNa; }; } in GHC.CString.unpackAppendCString# "'\n"# sat_s1rNg; }}} Somehow this emits this C--, {{{ c1Mzv: _s1rMI::P64 = P64[_s1rNh::P64 + 16]; I64[Hp - 16] = stg_sel_17_upd_info; P64[Hp] = _s1rMI::P64; _c1Mzq::P64 = Hp - 16; R3 = _c1Mzq::P64; R2 = c1Mzr_str; call GHC.CString.unpackAppendCString#_info(R3, R2) args: 8, res: 0, upd: 8; }}} Which is truly strange in light of the check in `mkRhsClosure`, {{{#!hs mkRhsClosure dflags bndr _cc _bi [NonVoid the_fv] upd_flag [] expr | let strip = snd . stripStgTicksTop (not . tickishIsCode) , StgCase (StgApp scrutinee [{-no args-}]) _ -- ignore bndr (AlgAlt _) [(DataAlt _, params, sel_expr)] <- strip expr , StgApp selectee [{-no args-}] <- strip sel_expr , the_fv == scrutinee -- Scrutinee is the only free variable , let (_, _, params_w_offsets) = mkVirtConstrOffsets dflags (addIdReps params) -- Just want the layout , Just the_offset <- assocMaybe params_w_offsets (NonVoid selectee) , let offset_into_int = bytesToWordsRoundUp dflags the_offset - fixedHdrSizeW dflags , offset_into_int <= mAX_SPEC_SELECTEE_SIZE dflags -- Offset is small enough = let lf_info = mkSelectorLFInfo bndr offset_into_int (isUpdatable upd_flag) in cgRhsStdThunk bndr lf_info [StgVarArg the_fv] }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11823#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11823: Undefined stg_sel_17_upd_info symbols on OS X -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 Type of failure: Building GHC | (amd64) failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): gridaphobe, could you describe your environment a bit? Are you possibly using a similar toolchain to George? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11823#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11823: Undefined stg_sel_17_upd_info symbols on OS X -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 Type of failure: Building GHC | (amd64) failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by George): I think this may be a toolchain issue, IIRC, i had no build problems with RC2 when I was not using any of the current toolchain. I just tried rc2 with my current toolchain and get essentially the same error: {{{ "_stg_sel_17_upd_info", referenced from: _s1x56_info in UI.dyn_o _s1x6r_info in UI.dyn_o _s1xd1_info in UI.dyn_o _s1xem_info in UI.dyn_o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) `gcc' failed in phase `Linker'. (Exit code: 1) make[1]: *** [ghc/stage2/build/tmp/ghc-stage2] Error 1 make: *** [all] Error 2 }}} Replying to [comment:8 George]:
I am on MacOS 10.11.4, Xcode 7.3, and llvm 3.7.1. I didn't see this on RC2 but I don't think I was using Xcode 7.3 then.
The error I am getting on rc3 is slightly different than the one in the description. Mine is: {{{ Undefined symbols for architecture x86_64: "_stg_sel_17_upd_info", referenced from: _s1xEL_info in UI.dyn_o _s1xG6_info in UI.dyn_o _s1xPC_info in UI.dyn_o _s1xQ9_info in UI.dyn_o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) `gcc' failed in phase `Linker'. (Exit code: 1) make[1]: *** [ghc/stage2/build/tmp/ghc-stage2] Error 1 make: *** [all] Error 2 }}} After doing {{{ $ touch ghc/GHCi/UI.hs $ make GhcStage2HcOpts='-ddump-to-file -ddump-simpl -ddump-stg -ddump- cmm' }}} I get: {{{ Undefined symbols for architecture x86_64: "_stg_sel_17_upd_info", referenced from: _s1rNh_info in UI.dyn_o _s1rNO_info in UI.dyn_o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) `gcc' failed in phase `Linker'. (Exit code: 1) make[1]: *** [ghc/stage2/build/tmp/ghc-stage2] Error 1 make: *** [all] Error 2 }}} Dumpfiles at [https://drive.google.com/file/d/0B_TQiA8d1y6fXzR0aThvRzBkZHc/view?usp=sharin...]
-- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11823#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11823: Undefined stg_sel_17_upd_info symbols on OS X -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 Type of failure: Building GHC | (amd64) failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by gridaphobe): It looks like I have a very similar environment to George: - OSX 10.11.4 - XCode 7.3 - Apple LLVM version 7.3.0 (clang-703.0.29) - Bootstrapped with GHC 7.10.3 (via nixpkgs) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11823#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11823: Undefined stg_sel_17_upd_info symbols on OS X -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: closed Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Resolution: duplicate | Keywords: Operating System: MacOS X | Architecture: x86_64 Type of failure: Building GHC | (amd64) failed | Test Case: Blocked By: | Blocking: Related Tickets: #11744 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by gridaphobe): * status: new => closed * resolution: => duplicate * related: => #11744 Comment: It turns out this is a result of the latest XCode update, which broke `nm`. Specifically, the new `nm -P` outputs decimal instead of hex which causes GHC to set `mAX_SPEC_SELECTEE_SIZE = 21` instead of `15`. The fix is to `./configure --with-nm=$(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm-classic`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11823#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11823: Undefined stg_sel_17_upd_info symbols on OS X -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: closed Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 8.0.1-rc3 Resolution: duplicate | Keywords: Operating System: MacOS X | Architecture: x86_64 Type of failure: Building GHC | (amd64) failed | Test Case: Blocked By: | Blocking: Related Tickets: #11744 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): Thanks everyone who helped track this down! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11823#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC