[GHC] #9938: cryptarithm2 fails with undefined reference to `transzuH9c1w14lEUN3zzdWCTsn8jG_ControlziMonadziTransziStateziLazzy_zdwzdcp0Alternative_info'
#9938: cryptarithm2 fails with undefined reference to `transzuH9c1w14lEUN3zzdWCTsn8jG_ControlziMonadziTransziStateziLazzy_zdwzdcp0Alternative_info' -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Compile-time Unknown/Multiple | crash Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | -------------------------------------+------------------------------------- I am observing this right now: {{{ ==nofib== cryptarithm2: size of Main.o follows... text data bss dec hex filename 25423 1304 0 26727 6867 Main.o ==nofib== cryptarithm2: time to link cryptarithm2 follows... Main.o: In Funktion `c79k_info': (.text+0x1a5b): Nicht definierter Verweis auf `transzuH9c1w14lEUN3zzdWCTsn8jG_ControlziMonadziTransziStateziLazzy_zdwzdcp0Alternative_info' Main.o: In Funktion `c7cP_info': (.text+0x2283): Nicht definierter Verweis auf `transzuH9c1w14lEUN3zzdWCTsn8jG_ControlziMonadziTransziStateziLazzy_zdwzdcp0Alternative_info' Main.o: In Funktion `c7ll_info': (.text+0x2f53): Nicht definierter Verweis auf `transzuH9c1w14lEUN3zzdWCTsn8jG_ControlziMonadziTransziStateziLazzy_zdwzdcp0Alternative_info' Main.o: In Funktion `c7p2_info': (.text+0x37cb): Nicht definierter Verweis auf `transzuH9c1w14lEUN3zzdWCTsn8jG_ControlziMonadziTransziStateziLazzy_zdwzdcp0Alternative_info' collect2: error: ld returned 1 exit status <<ghc: 12447488 bytes, 13 GCs, 430760/691224 avg/max bytes residency (2 samples), 31M in use, 0.001 INIT (0.001 elapsed), 0.008 MUT (0.207 elapsed), 0.013 GC (0.013 elapsed) :ghc>> make[2]: *** [cryptarithm2] Fehler 1 Failed making all in cryptarithm2: 1 make[1]: *** [all] Fehler 1 Failed making all in spectral: 1 make: *** [all] Fehler 1 make: Verlasse Verzeichnis '/data1/ghc-builder/logs/ghc-tmp-REV/nofib' }}} Trying to minimize the problem, I came up with this file: {{{ module Main where import Control.Monad import Control.Monad.Trans.State solve :: Int -> StateT () [] () solve carry | carry > 0 = do guard (0 == carry) solve (carry -1) solve 0 = mzero main :: IO () main = return () }}} It only occurs when using this sequence (I’m also pasting the DEBUG output, in case it is useful): {{{ $ /home/jojo/build/haskell/ghc/inplace/bin/ghc-stage2 -O2 -c Main.hs WARNING: file compiler/specialise/Specialise.hs, line 677 specImport discarding: $w$cmany :: forall s_a1an (m_a1ao :: * -> *). MonadPlus m_a1ao => forall a_a1ap. StateT s_a1an m_a1ao a_a1ap -> StateT s_a1an m_a1ao [a_a1ap] want: False stable: False calls: $w$cmany _ @ [] $fMonadPlus[] WARNING: file compiler/specialise/Specialise.hs, line 677 specImport discarding: $w$csome :: forall s_a1ax (m_a1ay :: * -> *). MonadPlus m_a1ay => forall a_a1az. StateT s_a1ax m_a1ay a_a1az -> StateT s_a1ax m_a1ay [a_a1az] want: False stable: False calls: $w$csome _ @ [] $fMonadPlus[] WARNING: file compiler/specialise/Specialise.hs, line 677 specImport discarding: $w$cp0Alternative :: forall s_a1aT (m_a1aU :: * -> *). MonadPlus m_a1aU => (# Functor (StateT s_a1aT m_a1aU), forall a_a1aV. a_a1aV -> StateT s_a1aT m_a1aU a_a1aV, forall a_a1aW b_a1aX. StateT s_a1aT m_a1aU (a_a1aW -> b_a1aX) -> StateT s_a1aT m_a1aU a_a1aW -> StateT s_a1aT m_a1aU b_a1aX, forall a_a1aY b_a1aZ. StateT s_a1aT m_a1aU a_a1aY -> StateT s_a1aT m_a1aU b_a1aZ -> StateT s_a1aT m_a1aU b_a1aZ, forall a_a1b0 b_a1b1. StateT s_a1aT m_a1aU a_a1b0 -> StateT s_a1aT m_a1aU b_a1b1 -> StateT s_a1aT m_a1aU a_a1b0 #) want: False stable: False calls: $w$cp0Alternative _ @ [] $fMonadPlus[] WARNING: file compiler/specialise/Specialise.hs, line 1093 Missed specialisation opportunity for $fMonadStateT_$c>> [] 2 [] 1 [ALWAYS] $ /home/jojo/build/haskell/ghc/inplace/bin/ghc-stage2 -O2 -o cryptarithm2 Main.o Main.o: In function `r3He_info': (.text+0x52): undefined reference to `transzuH9c1w14lEUN3zzdWCTsn8jG_ControlziMonadziTransziStateziLazzy_zdwzdcp0Alternative_info' collect2: error: ld returned 1 exit status }}} It works fine if I compile directly using {{{ $ /home/jojo/build/haskell/ghc/inplace/bin/ghc-stage2 -O2 -o cryptarithm2 Main.hs }}} Changing the order of the cases in `solve` also makes the problem go away. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9938> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9938: cryptarithm2 fails with undefined reference to `transzuH9c1w14lEUN3zzdWCTsn8jG_ControlziMonadziTransziStateziLazzy_zdwzdcp0Alternative_info' -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by Joachim Breitner <mail@…>): In [changeset:"65e3e0b2ce125b906efca129c92673fc40cf79f6/ghc"]: {{{ #!CommitTicketReference repository="ghc" revision="65e3e0b2ce125b906efca129c92673fc40cf79f6" Test case for #9938 Marked as known_broken }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9938#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9938: cryptarithm2 fails with undefined reference to `transzuH9c1w14lEUN3zzdWCTsn8jG_ControlziMonadziTransziStateziLazzy_zdwzdcp0Alternative_info' -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by rwbarton): I'm confused, isn't your minimized test case showing the expected behavior? GHC doesn't really know what's in `Main.o` and that it needs to link against transformers, so you have to specify `-package transformers` at link time. I don't understand how changing the order of the cases in `solve` could affect anything, and I also can't reproduce it here. Not sure what is going on with cryptarithm2 then, did it somehow gain a link-time dependency on transformers (whereas previously, perhaps, all the functions in transformers had been inlined)? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9938#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9938: cryptarithm2 fails with undefined reference to `transzuH9c1w14lEUN3zzdWCTsn8jG_ControlziMonadziTransziStateziLazzy_zdwzdcp0Alternative_info' -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by Joachim Breitner <mail@…>): In [changeset:"9521a58a5f3ca38a0bde8b67be00a74e5fc3ccea/ghc"]: {{{ #!CommitTicketReference repository="ghc" revision="9521a58a5f3ca38a0bde8b67be00a74e5fc3ccea" Refine test case for #9938 By passing -O2, the bug appears depending on the order of clauses in "solve", hence adding T9938B as the other variant. Currently, T9938 is marked as broken, but maybe the bug is actually in T9938B, where something (possibly inlining, as suggested by rwbarton) affected the requirement to link against transformers. }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9938#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9938: cryptarithm2 fails with undefined reference to `transzuH9c1w14lEUN3zzdWCTsn8jG_ControlziMonadziTransziStateziLazzy_zdwzdcp0Alternative_info' -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by nomeata):
I don't understand how changing the order of the cases in solve could affect anything, and I also can't reproduce it here.
Right, I can’t either. But when I pass `-O2`, I can! I added the other variant as a separate test case. Maybe the successful compilation of that is the bug? I hope that successful linking should not depend on the particular optimizations that went through. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9938#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9938: GHC's link step needs to be told which packages to link -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by simonpj): Replying to [comment:4 nomeata]:
I hope that successful linking should not depend on the particular optimizations that went through.
I'm afraid I suspect it does! * When compiling a source module, GHC can find imports from any exposed packages, in this case `transformers`. * But when linking `.o` files, GHC doesn't know which packages to link. So you mus specify on the command line; e.g. `-package transformers`. * If you inline enough things so that there are no remaining references to things from a package, then you don't need to include that package in the link command. This is pretty unusual. The Right Thing is, I guess, when given a `.o` file on the command line, to read its interface file, to find what packages it needs, and include those in any link step. Patch welcome! Simon -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9938#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9938: GHC's link step needs to be told which packages to link -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by Joachim Breitner <mail@…>): In [changeset:"633814f5664f135b3648e2a0a6f37e41e2b54ea0/ghc"]: {{{ #!CommitTicketReference repository="ghc" revision="633814f5664f135b3648e2a0a6f37e41e2b54ea0" Mark T9938 as not broken either one of the two recent commits (d8d0031, fd97d2a) fixed it, or there is some nondeterminism here. See #9938. }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9938#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9938: GHC's link step needs to be told which packages to link -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by simonpj): It fails on my laptop. I don't understand why it (now) passes on the regression suite but fail on on my laptop. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9938#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9938: GHC's link step needs to be told which packages to link -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by nomeata): That’s strange. T9938 passes on Travis reliable now (four builds since that commit). -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9938#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9938: GHC's link step needs to be told which packages to link -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by Simon Peyton Jones <simonpj@…>): In [changeset:"471891cb774a58769018ed5df2120d15bddffd28/ghc"]: {{{ #!CommitTicketReference repository="ghc" revision="471891cb774a58769018ed5df2120d15bddffd28" Mark T9938 as expect_broken again It's failing reliable for me (as I think it should) and Edward. See Trac #9938. Reverts commit 633814f5 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9938#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9938: GHC's link step needs to be told which packages to link -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by rwbarton): * type: bug => feature request Comment: Replying to [comment:5 simonpj]:
The Right Thing is, I guess, when given a `.o` file on the command line, to read its interface file, to find what packages it needs, and include those in any link step.
A `.o` file on the command line could have come from anywhere, though; it might have been produced by compiling a C file and not have an associated interface file at all. We could record dependency information in the `.o` file in a special section, but that's a bit difficult and nonportable, and doing it just for this purpose seems a bit overkill. I believe GHC is behaving as expected here, and its behavior seems fine to me, so I turned this into a feature request ticket. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9938#comment:10> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9938: GHC's link step needs to be told which packages to link -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by rwbarton): T9938 is acting up (unexpectedly passing) again, presumably due to some optimizer change. I don't really see the value in a test that verifies the absence of a feature that we know GHC does not have (tracking dependencies of `.o` files that were produced by GHC), though I suppose it means we have already done the work of creating the test if the feature gets added (but that doesn't look too likely to happen in the near future). But if we want to keep the test, can we find a dependency that we can count on not getting inlined away? Something that involves a global variable would be a good bet, but the only ones I can think of are in base (always linked in anyways) and random (not necessarily always built?) -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9938#comment:11> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9938: GHC's link step needs to be told which packages to link -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by thoughtpolice): We can actually make the test contain a package and use that with whatever hacks we need, can't we? There are several Cabal based tests in the build system. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9938#comment:12> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9938: GHC's link step needs to be told which packages to link -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by rwbarton): Right, we definitely could do that too, just a bit more heavyweight, but if nothing simpler suggests itself then perhaps best. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9938#comment:13> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9938: GHC's link step needs to be told which packages to link -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by Austin Seipp <austin@…>): In [changeset:"942a074ccb441320daae74fadf37b44e636dc102/ghc"]: {{{ #!CommitTicketReference repository="ghc" revision="942a074ccb441320daae74fadf37b44e636dc102" testsuite: mark test T9938 (#9938) as passing again Signed-off-by: Austin Seipp <austin@well-typed.com> }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9938#comment:14> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9938: GHC's link step needs to be told which packages to link -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by thoughtpolice): As I said to Reid on IRC: I'm fine with either doing the cabal test thing, or just deleting this test outright. I see Reid marked it as feature request, and the history is in the ticket references. So I don't think we'll lose much here if we just remove it. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9938#comment:15> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC