diff options
author | Alp Mestanogullari <alpmestan@gmail.com> | 2019-05-06 18:49:33 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-06-11 18:40:37 -0400 |
commit | 39f50bff3ea913a7f4b1d915660bcf77b9327e2e (patch) | |
tree | 333057c89bb94838cd12cf03deb7e7a5dda83339 /ghc | |
parent | fe7e7e4a950a77326cc16f4ade30a67d20d7cdd5 (diff) | |
download | haskell-39f50bff3ea913a7f4b1d915660bcf77b9327e2e.tar.gz |
Refine the GHCI macro into HAVE[_{INTERNAL, EXTERNAL}]_INTERPRETER
As discussed in #16331, the GHCI macro, defined through 'ghci' flags
in ghc.cabal.in, ghc-bin.cabal.in and ghci.cabal.in, is supposed to indicate
whether GHC is built with support for an internal interpreter, that runs in
the same process. It is however overloaded in a few places to mean
"there is an interpreter available", regardless of whether it's an internal
or external interpreter.
For the sake of clarity and with the hope of more easily being able to
build stage 1 GHCs with external interpreter support, this patch splits
the previous GHCI macro into 3 different ones:
- HAVE_INTERNAL_INTERPRETER: GHC is built with an internal interpreter
- HAVE_EXTERNAL_INTERPRETER: GHC is built with support for external interpreters
- HAVE_INTERPRETER: HAVE_INTERNAL_INTERPRETER || HAVE_EXTERNAL_INTERPRETER
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/Main.hs | 12 | ||||
-rw-r--r-- | ghc/ghc-bin.cabal.in | 13 |
2 files changed, 18 insertions, 7 deletions
diff --git a/ghc/Main.hs b/ghc/Main.hs index f5836f5fe6..ce0aaec6e9 100644 --- a/ghc/Main.hs +++ b/ghc/Main.hs @@ -25,12 +25,12 @@ import HscMain ( newHscEnv ) import DriverPipeline ( oneShot, compileFile ) import DriverMkDepend ( doMkDependHS ) import DriverBkp ( doBackpack ) -#if defined(GHCI) +#if defined(HAVE_INTERNAL_INTERPRETER) import GHCi.UI ( interactiveUI, ghciWelcomeMsg, defaultGhciSettings ) #endif -- Frontend plugins -#if defined(GHCI) +#if defined(HAVE_INTERPRETER) import DynamicLoading ( loadFrontendPlugin, initializePlugins ) import Plugins #else @@ -271,7 +271,7 @@ main' postLoadMode dflags0 args flagWarnings = do ghciUI :: HscEnv -> DynFlags -> [(FilePath, Maybe Phase)] -> Maybe [String] -> Ghc () -#if !defined(GHCI) +#if !defined(HAVE_INTERNAL_INTERPRETER) ghciUI _ _ _ _ = throwGhcException (CmdLineError "not built for interactive use") #else @@ -521,7 +521,7 @@ isDoEvalMode :: Mode -> Bool isDoEvalMode (Right (Right (DoEval _))) = True isDoEvalMode _ = False -#if defined(GHCI) +#if defined(HAVE_INTERNAL_INTERPRETER) isInteractiveMode :: PostLoadMode -> Bool isInteractiveMode DoInteractive = True isInteractiveMode _ = False @@ -752,7 +752,7 @@ showBanner :: PostLoadMode -> DynFlags -> IO () showBanner _postLoadMode dflags = do let verb = verbosity dflags -#if defined(GHCI) +#if defined(HAVE_INTERNAL_INTERPRETER) -- Show the GHCi banner when (isInteractiveMode _postLoadMode && verb >= 1) $ putStrLn ghciWelcomeMsg #endif @@ -844,7 +844,7 @@ dumpPackagesSimple dflags = putMsg dflags (pprPackagesSimple dflags) -- Frontend plugin support doFrontend :: ModuleName -> [(String, Maybe Phase)] -> Ghc () -#if !defined(GHCI) +#if !defined(HAVE_INTERPRETER) doFrontend modname _ = pluginError [modname] #else doFrontend modname srcs = do diff --git a/ghc/ghc-bin.cabal.in b/ghc/ghc-bin.cabal.in index 0c2cb2db6d..cf5fde03e3 100644 --- a/ghc/ghc-bin.cabal.in +++ b/ghc/ghc-bin.cabal.in @@ -24,6 +24,11 @@ Flag ghci Default: False Manual: True +Flag ext-interp + Description: Build external interpreter support + Default: True + Manual: True + Flag threaded Description: Link the ghc executable against the threaded RTS Default: True @@ -63,7 +68,7 @@ Executable ghc haskeline == 0.7.*, time >= 1.8 && < 1.10, transformers == 0.5.* - CPP-Options: -DGHCI + CPP-Options: -DHAVE_INTERNAL_INTERPRETER GHC-Options: -fno-warn-name-shadowing Other-Modules: GHCi.Leak @@ -92,6 +97,12 @@ Executable ghc if flag(threaded) ghc-options: -threaded + if flag(ext-interp) + cpp-options: -DHAVE_EXTERNAL_INTERPRETER + + if flag(ghci) || flag(ext-interp) + cpp-options: -DHAVE_INTERPRETER + Other-Extensions: CPP NondecreasingIndentation |