[GHC] #14335: Annotations aren't supported with -fexternal-interpreter

#14335: Annotations aren't supported with -fexternal-interpreter -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.2.1 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: -------------------------------------+------------------------------------- It seems that using `{-# ANN #-}` pragmas from a plugin cause GHC to crash when run with `-fexternal-interpreter` with {{{ ghc: this operation requires -fno-external-interpreter }}} It seems that the culprit is likely the use of `wormhole` in `convertAnnotationWrapper`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14335 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14335: Annotations aren't supported with -fexternal-interpreter -------------------------------------+------------------------------------- Reporter: bgamari | Owner: bgamari Type: bug | Status: new Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.2.1 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): * owner: (none) => bgamari Comment: Looking at the implementation more carefully it actually looks like this should work. I'll investigate. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14335#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14335: Annotations aren't supported with -fexternal-interpreter -------------------------------------+------------------------------------- Reporter: bgamari | Owner: bgamari Type: bug | Status: new Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.2.1 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 gnezdo): I hit this problem with ghc 8.0 as well. There also seems to be some evidence that -fplugin similarly requires -fno-external-interpreter. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14335#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14335: Annotations aren't supported with -fexternal-interpreter -------------------------------------+------------------------------------- Reporter: bgamari | Owner: bgamari Type: bug | Status: new Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.2.1 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 bgamari): Indeed reproducing this appears to be fairly straightfoward {{{ $ cabal install ghc-typelits-natnormalise $ cat << EOF > hi.hs {-# OPTIONS_GHC -fplugin GHC.TypeLits.Normalise #-} module Hi where EOF $ ghc hi.hs -fforce-recomp -fexternal-interpreter [1 of 1] Compiling Hi ( hi.hs, hi.o ) ghc: this operation requires -fno-external-interpreter }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14335#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14335: Annotations aren't supported with -fexternal-interpreter -------------------------------------+------------------------------------- Reporter: bgamari | Owner: bgamari Type: bug | Status: closed Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.2.1 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): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => fixed Comment: Well, for better or worse I actually can't reproduce this on master. I'll assume this is fixed. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14335#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14335: Annotations aren't supported with -fexternal-interpreter -------------------------------------+------------------------------------- Reporter: bgamari | Owner: bgamari Type: bug | Status: closed Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.2.1 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): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Would a regression test be appropriate, to ensure it doesn't recur? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14335#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14335: Annotations aren't supported with -fexternal-interpreter -------------------------------------+------------------------------------- Reporter: bgamari | Owner: bgamari Type: bug | Status: closed Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.2.1 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): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): It looks like running `plugins01` with `-fexternal-interpreter` should do the trick. I'll add one. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14335#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14335: Annotations aren't supported with -fexternal-interpreter -------------------------------------+------------------------------------- Reporter: bgamari | Owner: bgamari Type: bug | Status: closed Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.2.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: T14335 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * testcase: => T14335 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14335#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14335: Annotations aren't supported with -fexternal-interpreter -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: T14335 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * owner: bgamari => (none) * status: closed => new * resolution: fixed => Comment: Hmm, actually the test I add in Phab:D4202 seems to reproduce this afterall. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14335#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14335: Annotations aren't supported with -fexternal-interpreter
-------------------------------------+-------------------------------------
Reporter: bgamari | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.4.1
Component: Compiler | Version: 8.2.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case: T14335
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#14335: Annotations aren't supported with -fexternal-interpreter -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: T14335 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by osa1): As suggested in comment:2, this doesn't require `ANN`, `-fplugin` simply doesn't work with `-fexternal-interpreter`. Reproducer: {{{ $ cat plugin/src/Plugin.hs module Plugin where import GhcPlugins plugin :: Plugin plugin = defaultPlugin{ installCoreToDos = install } install :: [CommandLineOption] -> [CoreToDo] -> CoreM [CoreToDo] install _ todo = do return (CoreDoPluginPass "test plugin" pass : todo) pass :: ModGuts -> CoreM ModGuts pass g = return g $ cat test.hs {-# OPTIONS_GHC -fplugin Plugin #-} module Test where $ ghc-stage2 test.hs -fforce-recomp -fexternal-interpreter [1 of 1] Compiling Test ( test.hs, test.o ) getHValueSafely plugin (Plugin) CallStack (from HasCallStack): wormholeRef, called at compiler/ghci/GHCi.hs:622:21 in ghc:GHCi wormhole, called at compiler/main/DynamicLoading.hs:189:56 in ghc:DynamicLoading getHValueSafely, called at compiler/main/DynamicLoading.hs:161:44 in ghc:DynamicLoading getValueSafely, called at compiler/main/DynamicLoading.hs:107:24 in ghc:DynamicLoading loadPlugin', called at compiler/main/DynamicLoading.hs:87:14 in ghc:DynamicLoading ghc-stage2: this operation requires -fno-external-interpreter }}} The call stack is added by me to debug. `getHValueSafely` is being called to get `plugin :: Plugin` from the plugin module. The problem is we're trying to dereference a `HValueRef` returned by the external GHCi process. If we want plugins to work with `-fexternal- interpreter` I guess we have to let GHCi run the plugin passes and somehow return results to `TcRnDriver` (and `SimplCore` for Core plugins). I just started reading the relevant code, but I think we may need new GHCi messages for these? As parameter we need to pass the whole `TcM` (and `CoreM` for Core plugins) context. @bgamari @simonmar does this make sense? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14335#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14335: Annotations aren't supported with -fexternal-interpreter -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: T14335 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonmar): * cc: JaffaCake (removed) * cc: simonmar (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14335#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14335: Annotations aren't supported with -fexternal-interpreter -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: T14335 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonmar): Conclusion from offline discussion: * Probably not easy to make this work, because a lot of stuff would have to be serialized to be able to run the plugin in the external interpreter (Core, typechecker state, etc.) * We should document the limitation and emit a better error message * Possibly for the future: run the plugin with the internal interpreter while using the external interpreter for other things. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14335#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14335: Plugins don't work with -fexternal-interpreter -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: T14335 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by osa1: Old description:
It seems that using `{-# ANN #-}` pragmas from a plugin cause GHC to crash when run with `-fexternal-interpreter` with {{{ ghc: this operation requires -fno-external-interpreter }}} It seems that the culprit is likely the use of `wormhole` in `convertAnnotationWrapper`.
New description: Original description: ~~It seems that using `{-# ANN #-}` pragmas from a plugin cause GHC to crash when run with `-fexternal-interpreter` with {{{ ghc: this operation requires -fno-external-interpreter }}} It seems that the culprit is likely the use of `wormhole` in `convertAnnotationWrapper`.~~ It turns out this is an issue with `ANN`, as suggested by comment:2 and comment:11, plugins simply don't work with -fexternal-interpreter. -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14335#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14335: Plugins don't work with -fexternal-interpreter -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: T14335 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by osa1: Old description:
Original description:
~~It seems that using `{-# ANN #-}` pragmas from a plugin cause GHC to crash when run with `-fexternal-interpreter` with {{{ ghc: this operation requires -fno-external-interpreter }}} It seems that the culprit is likely the use of `wormhole` in `convertAnnotationWrapper`.~~
It turns out this is an issue with `ANN`, as suggested by comment:2 and comment:11, plugins simply don't work with -fexternal-interpreter.
New description: Original description: ~~It seems that using `{-# ANN #-}` pragmas from a plugin cause GHC to crash when run with `-fexternal-interpreter` with~~ {{{ ghc: this operation requires -fno-external-interpreter }}} ~~It seems that the culprit is likely the use of `wormhole` in `convertAnnotationWrapper`.~~ It turns out this is an issue with `ANN`, as suggested by comment:2 and comment:11, plugins simply don't work with -fexternal-interpreter. -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14335#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14335: Plugins don't work with -fexternal-interpreter -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: T14335 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4456 Wiki Page: | -------------------------------------+------------------------------------- Changes (by osa1): * status: new => patch * differential: => Phab:D4456 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14335#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14335: Plugins don't work with -fexternal-interpreter
-------------------------------------+-------------------------------------
Reporter: bgamari | Owner: (none)
Type: bug | Status: patch
Priority: normal | Milestone: 8.6.1
Component: Compiler | Version: 8.2.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case: T14335
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D4456
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#14335: Plugins don't work with -fexternal-interpreter -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.2.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: T14335 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4456 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14335#comment:18 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC