Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
-
69e0ab59
by Cheng Shao at 2026-01-06T19:37:56-05:00
-
25a0ab94
by Cheng Shao at 2026-01-06T19:37:56-05:00
-
92404a2b
by Cheng Shao at 2026-01-06T19:37:56-05:00
8 changed files:
- compiler/GHC.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Runtime/Interpreter/C.hs
- compiler/GHC/Runtime/Interpreter/Init.hs
- hadrian/src/Packages.hs
- hadrian/src/Settings/Packages.hs
- − utils/iserv/cbits/iservmain.c
- utils/iserv/iserv.cabal.in
Changes:
| ... | ... | @@ -719,7 +719,7 @@ setTopSessionDynFlags dflags = do |
| 719 | 719 | { interpCreateProcess = createIservProcessHook (hsc_hooks hsc_env)
|
| 720 | 720 | }
|
| 721 | 721 | |
| 722 | - interp <- liftIO $ initInterpreter tmpfs logger platform finder_cache unit_env interp_opts
|
|
| 722 | + interp <- liftIO $ initInterpreter dflags tmpfs logger platform finder_cache unit_env interp_opts
|
|
| 723 | 723 | |
| 724 | 724 | modifySession $ \h -> hscSetFlags dflags
|
| 725 | 725 | h{ hsc_IC = (hsc_IC h){ ic_dflags = dflags }
|
| ... | ... | @@ -197,6 +197,8 @@ module GHC.Driver.Session ( |
| 197 | 197 | -- * Compiler configuration suitable for display to the user
|
| 198 | 198 | compilerInfo,
|
| 199 | 199 | |
| 200 | + targetHasRTSWays,
|
|
| 201 | + |
|
| 200 | 202 | wordAlignment,
|
| 201 | 203 | |
| 202 | 204 | setUnsafeGlobalDynFlags,
|
| ... | ... | @@ -3635,6 +3637,15 @@ compilerInfo dflags |
| 3635 | 3637 | queryCmdMaybe p f = expandDirectories (query (maybe "" (prgPath . p) . f))
|
| 3636 | 3638 | queryFlagsMaybe p f = query (maybe "" (unwords . map escapeArg . prgFlags . p) . f)
|
| 3637 | 3639 | |
| 3640 | +-- | Query if the target RTS has the given 'Ways'. It's computed from
|
|
| 3641 | +-- the @"RTS ways"@ field in the settings file.
|
|
| 3642 | +targetHasRTSWays :: DynFlags -> Ways -> Bool
|
|
| 3643 | +targetHasRTSWays dflags ways
|
|
| 3644 | + | Just ws <- lookup "RTS ways" $ compilerInfo dflags =
|
|
| 3645 | + waysTag ways
|
|
| 3646 | + `elem` words ws
|
|
| 3647 | + | otherwise = panic "RTS ways not found in settings"
|
|
| 3648 | + |
|
| 3638 | 3649 | -- Note [Special unit-ids]
|
| 3639 | 3650 | -- ~~~~~~~~~~~~~~~~~~~~~~~
|
| 3640 | 3651 | -- Certain units are special to the compiler:
|
| ... | ... | @@ -8,7 +8,9 @@ where |
| 8 | 8 | |
| 9 | 9 | import GHC.Prelude
|
| 10 | 10 | import GHC.Platform
|
| 11 | +import GHC.Platform.Ways
|
|
| 11 | 12 | import GHC.Data.FastString
|
| 13 | +import GHC.Driver.Session
|
|
| 12 | 14 | import GHC.Utils.Logger
|
| 13 | 15 | import GHC.Utils.TmpFs
|
| 14 | 16 | import GHC.Unit.Types
|
| ... | ... | @@ -18,11 +20,10 @@ import GHC.Unit.State |
| 18 | 20 | import GHC.Utils.Panic.Plain
|
| 19 | 21 | import GHC.Linker.Executable
|
| 20 | 22 | import GHC.Linker.Config
|
| 21 | -import GHC.Utils.CliOption
|
|
| 22 | 23 | |
| 23 | 24 | -- | Generate iserv program for the target
|
| 24 | -generateIservC :: Logger -> TmpFs -> ExecutableLinkOpts -> UnitEnv -> IO FilePath
|
|
| 25 | -generateIservC logger tmpfs opts unit_env = do
|
|
| 25 | +generateIservC :: DynFlags -> Logger -> TmpFs -> ExecutableLinkOpts -> UnitEnv -> IO FilePath
|
|
| 26 | +generateIservC dflags logger tmpfs opts unit_env = do
|
|
| 26 | 27 | -- get the unit-id of the ghci package. We need this to load the
|
| 27 | 28 | -- interpreter code.
|
| 28 | 29 | let unit_state = ue_homeUnitState unit_env
|
| ... | ... | @@ -60,6 +61,12 @@ generateIservC logger tmpfs opts unit_env = do |
| 60 | 61 | -- must retain CAFs for running interpreted code.
|
| 61 | 62 | , leKeepCafs = True
|
| 62 | 63 | |
| 64 | + -- link with -threaded if target has threaded RTS
|
|
| 65 | + , leWays =
|
|
| 66 | + let ways = leWays opts
|
|
| 67 | + ways' = addWay WayThreaded ways
|
|
| 68 | + in if targetHasRTSWays dflags ways' then ways' else ways
|
|
| 69 | + |
|
| 63 | 70 | -- enable all rts options
|
| 64 | 71 | , leRtsOptsEnabled = RtsOptsAll
|
| 65 | 72 |
| ... | ... | @@ -9,6 +9,7 @@ where |
| 9 | 9 | |
| 10 | 10 | |
| 11 | 11 | import GHC.Prelude
|
| 12 | +import GHC.Driver.DynFlags
|
|
| 12 | 13 | import GHC.Platform
|
| 13 | 14 | import GHC.Platform.Ways
|
| 14 | 15 | import GHC.Settings
|
| ... | ... | @@ -57,14 +58,15 @@ data InterpOpts = InterpOpts |
| 57 | 58 | |
| 58 | 59 | -- | Initialize code interpreter
|
| 59 | 60 | initInterpreter
|
| 60 | - :: TmpFs
|
|
| 61 | + :: DynFlags
|
|
| 62 | + -> TmpFs
|
|
| 61 | 63 | -> Logger
|
| 62 | 64 | -> Platform
|
| 63 | 65 | -> FinderCache
|
| 64 | 66 | -> UnitEnv
|
| 65 | 67 | -> InterpOpts
|
| 66 | 68 | -> IO (Maybe Interp)
|
| 67 | -initInterpreter tmpfs logger platform finder_cache unit_env opts = do
|
|
| 69 | +initInterpreter dflags tmpfs logger platform finder_cache unit_env opts = do
|
|
| 68 | 70 | |
| 69 | 71 | lookup_cache <- liftIO $ mkInterpSymbolCache
|
| 70 | 72 | |
| ... | ... | @@ -125,7 +127,7 @@ initInterpreter tmpfs logger platform finder_cache unit_env opts = do |
| 125 | 127 | dynamic = interpWays opts `hasWay` WayDyn
|
| 126 | 128 | prog <- case interpProg opts of
|
| 127 | 129 | -- build iserv program if none specified
|
| 128 | - "" -> generateIservC logger tmpfs (interpExecutableLinkOpts opts) unit_env
|
|
| 130 | + "" -> generateIservC dflags logger tmpfs (interpExecutableLinkOpts opts) unit_env
|
|
| 129 | 131 | _ -> pure (interpProg opts ++ flavour)
|
| 130 | 132 | where
|
| 131 | 133 | flavour
|
| ... | ... | @@ -217,7 +217,7 @@ timeoutPath = "testsuite/timeout/install-inplace/bin/timeout" <.> exe |
| 217 | 217 | -- TODO: Can we extract this information from Cabal files?
|
| 218 | 218 | -- | Some program packages should not be linked with Haskell main function.
|
| 219 | 219 | nonHsMainPackage :: Package -> Bool
|
| 220 | -nonHsMainPackage = (`elem` [hp2ps, iserv, unlit, ghciWrapper])
|
|
| 220 | +nonHsMainPackage = (`elem` [hp2ps, unlit, ghciWrapper])
|
|
| 221 | 221 | |
| 222 | 222 | |
| 223 | 223 | {-
|
| ... | ... | @@ -41,6 +41,8 @@ packageArgs = do |
| 41 | 41 | libzstdLibraryDir <- getSetting LibZstdLibDir
|
| 42 | 42 | stageVersion <- readVersion <$> (expr $ ghcVersionStage stage)
|
| 43 | 43 | |
| 44 | + rtsWays <- getRtsWays
|
|
| 45 | + |
|
| 44 | 46 | mconcat
|
| 45 | 47 | --------------------------------- base ---------------------------------
|
| 46 | 48 | [ package base ? mconcat
|
| ... | ... | @@ -185,11 +187,15 @@ packageArgs = do |
| 185 | 187 | --
|
| 186 | 188 | -- The Solaris linker does not support --export-dynamic option. It also
|
| 187 | 189 | -- does not need it since it exports all dynamic symbols by default
|
| 188 | - , package iserv
|
|
| 189 | - ? expr isElfTarget
|
|
| 190 | + , package iserv ? mconcat [
|
|
| 191 | + expr isElfTarget
|
|
| 190 | 192 | ? notM (expr $ anyTargetOs [OSFreeBSD, OSSolaris2])? mconcat
|
| 191 | 193 | [ builder (Ghc LinkHs) ? arg "-optl-Wl,--export-dynamic" ]
|
| 192 | 194 | |
| 195 | + -- Link iserv with -threaded if possible
|
|
| 196 | + , builder (Cabal Flags) ? any (wayUnit Threaded) rtsWays `cabalFlag` "threaded"
|
|
| 197 | + ]
|
|
| 198 | + |
|
| 193 | 199 | -------------------------------- haddock -------------------------------
|
| 194 | 200 | , package haddockApi ?
|
| 195 | 201 | builder (Cabal Flags) ? arg "in-ghc-tree"
|
| 1 | -#include <ghcversion.h>
|
|
| 2 | -# include <rts/PosixSource.h>
|
|
| 3 | -#include <Rts.h>
|
|
| 4 | - |
|
| 5 | -#include <HsFFI.h>
|
|
| 6 | - |
|
| 7 | -int main (int argc, char *argv[])
|
|
| 8 | -{
|
|
| 9 | - RtsConfig conf = defaultRtsConfig;
|
|
| 10 | - |
|
| 11 | - // We never know what symbols GHC will look up in the future, so
|
|
| 12 | - // we must retain CAFs for running interpreted code.
|
|
| 13 | - conf.keep_cafs = 1;
|
|
| 14 | - |
|
| 15 | - conf.rts_opts_enabled = RtsOptsAll;
|
|
| 16 | - extern StgClosure ZCMain_main_closure;
|
|
| 17 | - hs_main(argc, argv, &ZCMain_main_closure, conf);
|
|
| 18 | -} |
| ... | ... | @@ -23,11 +23,17 @@ Category: Development |
| 23 | 23 | build-type: Simple
|
| 24 | 24 | cabal-version: >=1.10
|
| 25 | 25 | |
| 26 | +Flag threaded
|
|
| 27 | + Description: Link the iserv executable against the threaded RTS
|
|
| 28 | + Default: True
|
|
| 29 | + Manual: True
|
|
| 30 | + |
|
| 26 | 31 | Executable iserv
|
| 27 | 32 | Default-Language: Haskell2010
|
| 28 | - ghc-options: -no-hs-main
|
|
| 33 | + ghc-options: -fkeep-cafs -rtsopts
|
|
| 34 | + if flag(threaded)
|
|
| 35 | + ghc-options: -threaded
|
|
| 29 | 36 | Main-Is: Main.hs
|
| 30 | - C-Sources: cbits/iservmain.c
|
|
| 31 | 37 | Hs-Source-Dirs: src
|
| 32 | 38 | include-dirs: .
|
| 33 | 39 | Build-Depends:
|