Sven Tennie pushed to branch wip/supersven/interpreter-flags at Glasgow Haskell Compiler / GHC
Commits:
-
9efefc8c
by Sven Tennie at 2026-04-26T13:11:24+02:00
6 changed files:
- + changelog.d/T19174.md
- ghc/GHC/Driver/Session/Mode.hs
- ghc/GHCi/UI.hs
- ghc/Main.hs
- ghc/ghc-bin.cabal.in
- hadrian/src/Settings/Packages.hs
Changes:
| 1 | +section: compiler
|
|
| 2 | +issues: #19174
|
|
| 3 | +mrs: !15714
|
|
| 4 | +synopsis:
|
|
| 5 | + Introduce HAVE_INTERPRETER flag separate from HAVE_INTERNAL_INTERPRETER
|
|
| 6 | +description:
|
|
| 7 | + GHC now distinguishes between having any interpreter support (internal or
|
|
| 8 | + external) via the `HAVE_INTERPRETER` CPP flag, and having specifically
|
|
| 9 | + an internal interpreter via `HAVE_INTERNAL_INTERPRETER`. The `ghc-bin`
|
|
| 10 | + package now has separate `interpreter` and `internal-interpreter` cabal
|
|
| 11 | + flags. Interactive mode and GHCi UI features now check `HAVE_INTERPRETER`
|
|
| 12 | + instead of `HAVE_INTERNAL_INTERPRETER`, while internal interpreter-specific
|
|
| 13 | + code (like the directory change handler in GHCi) remains guarded by
|
|
| 14 | + `HAVE_INTERNAL_INTERPRETER`. In cross-compilation builds, the
|
|
| 15 | + `internal-interpreter` flag is disabled while the `interpreter` flag can
|
|
| 16 | + still be enabled for external interpreter support.
|
|
| 17 | + This does not change current behaviour, but prevents compiler warnings. |
| ... | ... | @@ -132,7 +132,7 @@ isDoEvalMode :: Mode -> Bool |
| 132 | 132 | isDoEvalMode (Right (Right (DoEval _))) = True
|
| 133 | 133 | isDoEvalMode _ = False
|
| 134 | 134 | |
| 135 | -#if defined(HAVE_INTERNAL_INTERPRETER)
|
|
| 135 | +#if defined(HAVE_INTERPRETER)
|
|
| 136 | 136 | isInteractiveMode :: PostLoadMode -> Bool
|
| 137 | 137 | isInteractiveMode DoInteractive = True
|
| 138 | 138 | isInteractiveMode _ = False
|
| ... | ... | @@ -1909,7 +1909,9 @@ changeDirectory dir = do |
| 1909 | 1909 | fhv <- compileGHCiExpr $
|
| 1910 | 1910 | "System.Directory.setCurrentDirectory " ++ show dir'
|
| 1911 | 1911 | liftIO $ evalIO interp fhv
|
| 1912 | +#if defined(HAVE_INTERNAL_INTERPRETER)
|
|
| 1912 | 1913 | _ -> pure ()
|
| 1914 | +#endif
|
|
| 1913 | 1915 | |
| 1914 | 1916 | trySuccess :: GhciMonad m => m SuccessFlag -> m SuccessFlag
|
| 1915 | 1917 | trySuccess act =
|
| ... | ... | @@ -36,7 +36,7 @@ import GHC.Driver.Config.Diagnostic |
| 36 | 36 | import GHC.Platform
|
| 37 | 37 | import GHC.Platform.Host
|
| 38 | 38 | |
| 39 | -#if defined(HAVE_INTERNAL_INTERPRETER)
|
|
| 39 | +#if defined(HAVE_INTERPRETER)
|
|
| 40 | 40 | import GHCi.UI ( interactiveUI, ghciWelcomeMsg, defaultGhciSettings, languageEditionMsg )
|
| 41 | 41 | #endif
|
| 42 | 42 | |
| ... | ... | @@ -288,7 +288,7 @@ doRun units srcs args = do |
| 288 | 288 | args' = drop 1 $ dropWhile (/= "--") $ map unLoc args
|
| 289 | 289 | |
| 290 | 290 | ghciUI :: [String] -> [(FilePath, Maybe Phase)] -> Maybe [String] -> Ghc ()
|
| 291 | -#if !defined(HAVE_INTERNAL_INTERPRETER)
|
|
| 291 | +#if !defined(HAVE_INTERPRETER)
|
|
| 292 | 292 | ghciUI _ _ _ =
|
| 293 | 293 | throwGhcException (CmdLineError "not built for interactive use")
|
| 294 | 294 | #else
|
| ... | ... | @@ -332,7 +332,7 @@ showBanner :: PostLoadMode -> DynFlags -> IO () |
| 332 | 332 | showBanner _postLoadMode dflags = do
|
| 333 | 333 | let verb = verbosity dflags
|
| 334 | 334 | |
| 335 | -#if defined(HAVE_INTERNAL_INTERPRETER)
|
|
| 335 | +#if defined(HAVE_INTERPRETER)
|
|
| 336 | 336 | -- Show the GHCi banner
|
| 337 | 337 | when (isInteractiveMode _postLoadMode && verb >= 1) $
|
| 338 | 338 | do putStrLn ghciWelcomeMsg
|
| ... | ... | @@ -22,6 +22,11 @@ Flag internal-interpreter |
| 22 | 22 | Default: False
|
| 23 | 23 | Manual: True
|
| 24 | 24 | |
| 25 | +Flag interpreter
|
|
| 26 | + Description: Build with interpreter support, both internal and external.
|
|
| 27 | + Default: False
|
|
| 28 | + Manual: True
|
|
| 29 | + |
|
| 25 | 30 | Flag threaded
|
| 26 | 31 | Description: Link the ghc executable against the threaded RTS
|
| 27 | 32 | Default: True
|
| ... | ... | @@ -56,7 +61,7 @@ Executable ghc |
| 56 | 61 | -rtsopts=all
|
| 57 | 62 | "-with-rtsopts=-K512M -H -I5 -T"
|
| 58 | 63 | |
| 59 | - if flag(internal-interpreter)
|
|
| 64 | + if flag(interpreter)
|
|
| 60 | 65 | -- NB: this is never built by the bootstrapping GHC+libraries
|
| 61 | 66 | Build-depends:
|
| 62 | 67 | deepseq >= 1.4 && < 1.6,
|
| ... | ... | @@ -65,7 +70,7 @@ Executable ghc |
| 65 | 70 | haskeline == 0.8.*,
|
| 66 | 71 | exceptions == 0.10.*,
|
| 67 | 72 | time >= 1.8 && < 1.16
|
| 68 | - CPP-Options: -DHAVE_INTERNAL_INTERPRETER
|
|
| 73 | + CPP-Options: -DHAVE_INTERPRETER
|
|
| 69 | 74 | Other-Modules:
|
| 70 | 75 | GHCi.Leak
|
| 71 | 76 | GHCi.UI
|
| ... | ... | @@ -82,6 +87,9 @@ Executable ghc |
| 82 | 87 | UnboxedTuples
|
| 83 | 88 | ViewPatterns
|
| 84 | 89 | |
| 90 | + if flag(internal-interpreter)
|
|
| 91 | + CPP-Options: -DHAVE_INTERNAL_INTERPRETER
|
|
| 92 | + |
|
| 85 | 93 | if flag(threaded)
|
| 86 | 94 | ghc-options: -threaded
|
| 87 | 95 |
| ... | ... | @@ -114,7 +114,8 @@ packageArgs = do |
| 114 | 114 | , compilerStageOption ghcDebugAssertions ? arg "-DDEBUG" ]
|
| 115 | 115 | |
| 116 | 116 | , builder (Cabal Flags) ? mconcat
|
| 117 | - [ (expr (ghcWithInterpreter stage)) `cabalFlag` "internal-interpreter"
|
|
| 117 | + [ expr (ghcWithInterpreter stage) `cabalFlag` "interpreter"
|
|
| 118 | + , andM [expr (ghcWithInterpreter stage), notCross] `cabalFlag` "internal-interpreter"
|
|
| 118 | 119 | , ifM stage0
|
| 119 | 120 | -- We build a threaded stage 1 if the bootstrapping compiler
|
| 120 | 121 | -- supports it.
|