[GHC] #10965: GHC Panic on import with 'OPTIONS_GHC -fobject-code -O'

#10965: GHC Panic on import with 'OPTIONS_GHC -fobject-code -O' --------------------------------------+--------------------------------- Reporter: Orome | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Keywords: | Operating System: MacOS X Architecture: x86_64 (amd64) | Type of failure: None/Unknown Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: --------------------------------------+--------------------------------- I get {{{
:l Test.hs [1 of 1] Compiling Main ( Test.hs, interpreted ) ghc: panic! (the 'impossible' happened) (GHC version 7.10.2 for x86_64-apple-darwin): floatExpr tick break<11>()
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} with Test.hs: {{{ {-# OPTIONS_GHC -fobject-code -O #-} import Control.Exception (assert) import Data.Char (ord) f :: String -> String f s = assert (all (`elem` letters) s) $ (letters!!) <$> (ix <$> s) where ix ch = (ord ch - ord 'A') letters = ['A'..'Z'] }}} OSX 10.11, GHC 7.10.2; uad-core 64-bit haswell; Homebrew GHC -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10965 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10965: GHC Panic on import with 'OPTIONS_GHC -fobject-code -O' ---------------------------------+-------------------------------------- Reporter: Orome | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Resolution: duplicate | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #10549 | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => duplicate * related: => #10549 Comment: Thanks for your report. This is a duplicate of #10549 which will be fixed in 7.10.3. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10965#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10965: GHC Panic on import with 'OPTIONS_GHC -fobject-code -O' ---------------------------------+-------------------------------------- Reporter: Orome | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1-rc2 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #10549 | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Changes (by slyfox): * status: closed => new * version: 7.10.2 => 8.0.1-rc2 * resolution: duplicate => Comment: Seems to be distinct from #10549. Still happens in today's -HEAD: {{{ $ inplace/bin/ghc-stage2 --interactive /tmp/z/G.hs GHCi, version 8.1.20160207: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/slyfox/.ghci [1 of 1] Compiling Main ( /tmp/z/G.hs, interpreted ) ghc-stage2: panic! (the 'impossible' happened) (GHC version 8.1.20160207 for x86_64-unknown-linux): floatExpr tick break<0>() Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10965#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10965: GHC Panic on import with 'OPTIONS_GHC -fobject-code -O' ---------------------------------+-------------------------------------- Reporter: Orome | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1-rc2 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #10549 | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Changes (by slyfox): * cc: slyfox, scpmw (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10965#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10965: GHC Panic on import with 'OPTIONS_GHC -fobject-code -O' ---------------------------------+-------------------------------------- Reporter: Orome | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1-rc2 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #10549 | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Comment (by rwbarton): The contents of the module aren't relevant, this module exhibits the same panic. {{{ {-# OPTIONS_GHC -fobject-code -O #-} f :: String -> String f = id }}} The difference is that this module has `-fobject-code`. `checkOptLevel` disallows `-O`, if the target is `HscInterpreted`. That was the fix for #10549. But here the target is `HscAsm`. But somewhere later the target must get set to `HscInterpreted`, as evidenced by the output {{{ [1 of 1] Compiling Main ( G.hs, interpreted ) }}} and the fact that the module contains breakpoints. (So as another issue, `{-# OPTIONS_GHC -fobject-code #-}` doesn't actually work. Seems it hasn't worked since at least 7.8.) Aha, found it! {{{ upsweep_mod hsc_env old_hpt (stable_obj, stable_bco) summary mod_index nmods = ... -- We're using the dflags for this module now, obtained by -- applying any options in its LANGUAGE & OPTIONS_GHC pragmas. dflags = ms_hspp_opts summary prevailing_target = hscTarget (hsc_dflags hsc_env) local_target = hscTarget dflags -- If OPTIONS_GHC contains -fasm or -fllvm, be careful that -- we don't do anything dodgy: these should only work to change -- from -fllvm to -fasm and vice-versa, otherwise we could -- end up trying to link object code to byte code. target = if prevailing_target /= local_target && (not (isObjectTarget prevailing_target) || not (isObjectTarget local_target)) then prevailing_target else local_target -- store the corrected hscTarget into the summary summary' = summary{ ms_hspp_opts = dflags { hscTarget = target } } ... }}} Assuming this stuff about linking object code and byte code is still relevant, I guess we should call `checkNewDynFlags` on `dflags { hscTarget = target }`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10965#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10965: GHC Panic on import with 'OPTIONS_GHC -fobject-code -O' ---------------------------------+-------------------------------------- Reporter: Orome | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1-rc2 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #10549 | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Comment (by rwbarton): I guess the issue is: we can't have an object code module import a byte code module, since how would we link the object file? And if we allowed `{-# OPTIONS_GHC -fobject-code #-}`, that could end up happening. The workaround is of course not to write `{-# OPTIONS_GHC -fobject-code #-}` since it doesn't work. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10965#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10965: GHC Panic on import with 'OPTIONS_GHC -fobject-code -O' ---------------------------------+-------------------------------------- Reporter: Orome | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.0.1-rc2 Resolution: fixed | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #10549 | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Changes (by RyanGlScott): * status: new => closed * resolution: => fixed * milestone: => 8.2.1 Comment: I cannot reproduce this issue with GHC 8.2 and later, so closing. Please reopen if this still happens for you. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10965#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC