summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-01-15 14:57:08 -0500
committerBen Gamari <ben@well-typed.com>2020-01-17 19:25:57 -0500
commit9182367ac3d0775ef22a926c84f88184675cb354 (patch)
tree705c74dbd9420dba9cbe70156607a8b282fc89fb
parenta71323ffebf7663c50025d2731bf9de2d04f82c3 (diff)
downloadhaskell-wip/T17692.tar.gz
Fix GhcThreaded settingwip/T17692
This adopts a patch from NetBSD's packaging fixing the `GhcThreaded` option of the make build system. In addition we introduce a `ghcThreaded` option in hadrian's `Flavour` type. Also fix Hadrian's treatment of the `Use Threaded` entry in `settings`. Previously it would incorrectly claim `Use Threaded = True` if we were building the `threaded` runtime way. However, this is inconsistent with the `make` build system, which defines it to be whether the `ghc` executable is linked against the threaded runtime. Fixes #17692.
-rw-r--r--ghc/ghc.mk6
-rw-r--r--hadrian/doc/user-settings.md2
-rw-r--r--hadrian/src/Flavour.hs2
-rw-r--r--hadrian/src/Rules/Generate.hs2
-rw-r--r--hadrian/src/Settings/Default.hs1
-rw-r--r--hadrian/src/Settings/Packages.hs4
6 files changed, 15 insertions, 2 deletions
diff --git a/ghc/ghc.mk b/ghc/ghc.mk
index 3bff2f58c9..8c112a054f 100644
--- a/ghc/ghc.mk
+++ b/ghc/ghc.mk
@@ -61,7 +61,13 @@ ifeq "$(GhcThreaded)" "YES"
# Use threaded RTS with GHCi, so threads don't get blocked at the prompt.
ghc_stage2_MORE_HC_OPTS += -threaded
ghc_stage3_MORE_HC_OPTS += -threaded
+else
+# Opt out from threaded GHC. See ghc-bin.cabal.in
+ghc_stage2_CONFIGURE_OPTS += -f-threaded
+ghc_stage3_CONFIGURE_OPTS += -f-threaded
endif
+# Stage-0 compiler isn't guaranteed to have a threaded RTS.
+ghc_stage1_CONFIGURE_OPTS += -f-threaded
ifeq "$(GhcProfiled)" "YES"
ghc_stage2_PROGRAM_WAY = p
diff --git a/hadrian/doc/user-settings.md b/hadrian/doc/user-settings.md
index 04a526605d..02b6ddf9ea 100644
--- a/hadrian/doc/user-settings.md
+++ b/hadrian/doc/user-settings.md
@@ -35,6 +35,8 @@ data Flavour = Flavour {
ghcProfiled :: Bool,
-- | Build GHC with debug information.
ghcDebugged :: Bool
+ -- | Build the GHC executable against the threaded runtime system.
+ ghcThreaded :: Bool,
-- | Whether to build docs and which ones
-- (haddocks, user manual, haddock manual)
ghcDocs :: Action DocTargets }
diff --git a/hadrian/src/Flavour.hs b/hadrian/src/Flavour.hs
index dd203ea88e..64ce931e78 100644
--- a/hadrian/src/Flavour.hs
+++ b/hadrian/src/Flavour.hs
@@ -39,6 +39,8 @@ data Flavour = Flavour {
ghcProfiled :: Bool,
-- | Build GHC with debugging assertions.
ghcDebugged :: Bool,
+ -- | Build the GHC executable against the threaded runtime system.
+ ghcThreaded :: Bool,
-- | Whether to build docs and which ones
-- (haddocks, user manual, haddock manual)
ghcDocs :: Action DocTargets }
diff --git a/hadrian/src/Rules/Generate.hs b/hadrian/src/Rules/Generate.hs
index 74759be20e..c65d852931 100644
--- a/hadrian/src/Rules/Generate.hs
+++ b/hadrian/src/Rules/Generate.hs
@@ -320,7 +320,7 @@ generateSettings = do
, ("Tables next to code", expr $ yesNo <$> flag TablesNextToCode)
, ("Leading underscore", expr $ yesNo <$> flag LeadingUnderscore)
, ("Use LibFFI", expr $ yesNo <$> useLibFFIForAdjustors)
- , ("Use Threads", yesNo . any (wayUnit Threaded) <$> getRtsWays)
+ , ("Use Threads", expr $ yesNo . ghcThreaded <$> flavour)
, ("Use Debugging", expr $ yesNo . ghcDebugged <$> flavour)
, ("RTS expects libdw", yesNo <$> getFlag WithLibdw)
]
diff --git a/hadrian/src/Settings/Default.hs b/hadrian/src/Settings/Default.hs
index 7279023e82..5bf9ea7e7c 100644
--- a/hadrian/src/Settings/Default.hs
+++ b/hadrian/src/Settings/Default.hs
@@ -215,6 +215,7 @@ defaultFlavour = Flavour
, ghciWithDebugger = False
, ghcProfiled = False
, ghcDebugged = False
+ , ghcThreaded = True
, ghcDocs = cmdDocsArgs }
-- | Default logic for determining whether to build
diff --git a/hadrian/src/Settings/Packages.hs b/hadrian/src/Settings/Packages.hs
index 9e43459a0f..d0dbabde99 100644
--- a/hadrian/src/Settings/Packages.hs
+++ b/hadrian/src/Settings/Packages.hs
@@ -96,7 +96,9 @@ packageArgs = do
-- the 'threaded' flag is True by default, but
-- let's record explicitly that we link all ghc
-- executables with the threaded runtime.
- , arg "threaded" ] ]
+ , stage0 ? arg "-threaded"
+ , notStage0 ? ifM (ghcThreaded <$> expr flavour) (arg "threaded") (arg "-threaded") ]
+ ]
-------------------------------- ghcPkg --------------------------------
, package ghcPkg ?