summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCheng Shao <astrohavoc@gmail.com>2022-10-28 16:12:56 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-11-11 00:26:55 -0500
commit2e6ab4537ff5a2d496de44a0475efb274867317a (patch)
treeb6c424f48d7e498dd76b9839f7c0ab9567aedabe
parentf5dfd1b48f82d08d7346a1988ec08ec3544c940c (diff)
downloadhaskell-2e6ab4537ff5a2d496de44a0475efb274867317a.tar.gz
hadrian: add targetSupportsThreadedRts flag
This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32.
-rw-r--r--hadrian/src/Oracles/Flag.hs9
-rw-r--r--hadrian/src/Settings/Default.hs10
-rw-r--r--hadrian/src/Settings/Flavours/Benchmark.hs4
-rw-r--r--hadrian/src/Settings/Flavours/Development.hs3
-rw-r--r--hadrian/src/Settings/Flavours/GhcInGhci.hs3
-rw-r--r--hadrian/src/Settings/Flavours/Quick.hs9
-rw-r--r--hadrian/src/Settings/Flavours/QuickCross.hs9
-rw-r--r--hadrian/src/Settings/Flavours/Quickest.hs3
-rw-r--r--hadrian/src/Settings/Flavours/Validate.hs7
9 files changed, 39 insertions, 18 deletions
diff --git a/hadrian/src/Oracles/Flag.hs b/hadrian/src/Oracles/Flag.hs
index bf0aa62383..a17b788c33 100644
--- a/hadrian/src/Oracles/Flag.hs
+++ b/hadrian/src/Oracles/Flag.hs
@@ -4,6 +4,7 @@ module Oracles.Flag (
Flag (..), flag, getFlag,
platformSupportsSharedLibs,
platformSupportsGhciObjects,
+ targetSupportsThreadedRts,
targetSupportsSMP,
useLibffiForAdjustors,
arSupportsDashL
@@ -84,7 +85,13 @@ platformSupportsSharedLibs = do
solarisBroken <- flag SolarisBrokenShld
return $ not (windows || ppc_linux || solaris && solarisBroken)
--- | Does the target support the threaded runtime system?
+-- | Does the target support threaded RTS?
+targetSupportsThreadedRts :: Action Bool
+targetSupportsThreadedRts = do
+ wasm <- anyTargetArch [ "wasm32" ]
+ return $ not wasm
+
+-- | Does the target support the -N RTS flag?
targetSupportsSMP :: Action Bool
targetSupportsSMP = do
unreg <- flag GhcUnregisterised
diff --git a/hadrian/src/Settings/Default.hs b/hadrian/src/Settings/Default.hs
index 8e8729544b..312747141b 100644
--- a/hadrian/src/Settings/Default.hs
+++ b/hadrian/src/Settings/Default.hs
@@ -176,14 +176,16 @@ defaultLibraryWays = Set.fromList <$>
defaultRtsWays :: Ways
defaultRtsWays = Set.fromList <$>
mconcat
- [ pure [vanilla, threaded]
+ [ pure [vanilla]
, notStage0 ? pure
- [ profiling, threadedProfiling, debugProfiling, threadedDebugProfiling
- , debug, threadedDebug
+ [ profiling, debugProfiling
+ , debug
]
+ , notStage0 ? targetSupportsThreadedRts ? pure [threaded, threadedProfiling, threadedDebugProfiling, threadedDebug]
, notStage0 ? platformSupportsSharedLibs ? pure
- [ dynamic, threadedDynamic, debugDynamic, threadedDebugDynamic
+ [ dynamic, debugDynamic
]
+ , notStage0 ? platformSupportsSharedLibs ? targetSupportsThreadedRts ? pure [ threadedDynamic, threadedDebugDynamic ]
]
-- TODO: Move C source arguments here
diff --git a/hadrian/src/Settings/Flavours/Benchmark.hs b/hadrian/src/Settings/Flavours/Benchmark.hs
index 4e5cea0635..3715e6505d 100644
--- a/hadrian/src/Settings/Flavours/Benchmark.hs
+++ b/hadrian/src/Settings/Flavours/Benchmark.hs
@@ -3,6 +3,7 @@ module Settings.Flavours.Benchmark (benchmarkFlavour) where
import qualified Data.Set as Set
import Expression
import Flavour
+import Oracles.Flag
import {-# SOURCE #-} Settings.Default
-- Please update doc/flavours.md when changing this file.
@@ -11,7 +12,7 @@ benchmarkFlavour = defaultFlavour
{ name = "bench"
, args = defaultBuilderArgs <> benchmarkArgs <> defaultPackageArgs
, libraryWays = pure $ Set.fromList [vanilla]
- , rtsWays = pure $ Set.fromList [vanilla, threaded] }
+ , rtsWays = Set.fromList <$> mconcat [pure [vanilla], targetSupportsThreadedRts ? pure [threaded]] }
benchmarkArgs :: Args
benchmarkArgs = sourceArgs SourceArgs
@@ -22,4 +23,3 @@ benchmarkArgs = sourceArgs SourceArgs
-- to benchmark. This has to happen in sync with the Makefile build, though.
, hsCompiler = mconcat [stage0 ? arg "-O2", notStage0 ? arg "-O0"]
, hsGhc = pure ["-O2"] }
-
diff --git a/hadrian/src/Settings/Flavours/Development.hs b/hadrian/src/Settings/Flavours/Development.hs
index 835584d3eb..715532e08a 100644
--- a/hadrian/src/Settings/Flavours/Development.hs
+++ b/hadrian/src/Settings/Flavours/Development.hs
@@ -4,6 +4,7 @@ import qualified Data.Set as Set
import Expression
import Flavour
+import Oracles.Flag
import Packages
import {-# SOURCE #-} Settings.Default
@@ -13,7 +14,7 @@ developmentFlavour ghcStage = defaultFlavour
{ name = "devel" ++ stageString ghcStage
, args = defaultBuilderArgs <> developmentArgs ghcStage <> defaultPackageArgs
, libraryWays = pure $ Set.fromList [vanilla]
- , rtsWays = pure $ Set.fromList [vanilla, debug, threaded, threadedDebug]
+ , rtsWays = Set.fromList <$> mconcat [pure [vanilla, debug], targetSupportsThreadedRts ? pure [threaded, threadedDebug]]
, dynamicGhcPrograms = return False
, ghcDebugAssertions = (>= Stage2) }
where
diff --git a/hadrian/src/Settings/Flavours/GhcInGhci.hs b/hadrian/src/Settings/Flavours/GhcInGhci.hs
index b0859ffc56..fc956518f9 100644
--- a/hadrian/src/Settings/Flavours/GhcInGhci.hs
+++ b/hadrian/src/Settings/Flavours/GhcInGhci.hs
@@ -4,6 +4,7 @@ import qualified Data.Set as Set
import Expression
import Flavour
+import Oracles.Flag
import {-# SOURCE #-} Settings.Default
-- Please update doc/flavours.md when changing this file.
@@ -15,7 +16,7 @@ ghcInGhciFlavour = defaultFlavour
-- include the dynamic way when we have a dynamic host GHC, but just
-- checking for Windows seems simpler for now.
, libraryWays = pure (Set.fromList [vanilla]) <> pure (Set.fromList [ dynamic | not windowsHost ])
- , rtsWays = pure (Set.fromList [vanilla, threaded]) <> pure (Set.fromList [ dynamic | not windowsHost ])
+ , rtsWays = pure (Set.fromList [vanilla]) <> (targetSupportsThreadedRts ? pure (Set.fromList [threaded])) <> pure (Set.fromList [ dynamic | not windowsHost ])
, dynamicGhcPrograms = return False }
ghciArgs :: Args
diff --git a/hadrian/src/Settings/Flavours/Quick.hs b/hadrian/src/Settings/Flavours/Quick.hs
index fa668bf1ba..25a5624b9b 100644
--- a/hadrian/src/Settings/Flavours/Quick.hs
+++ b/hadrian/src/Settings/Flavours/Quick.hs
@@ -23,10 +23,13 @@ quickFlavour = defaultFlavour
, rtsWays = Set.fromList <$>
mconcat
[ pure
- [ vanilla, threaded, debug
- , threadedDebug, threaded ]
+ [ vanilla, debug ]
+ , targetSupportsThreadedRts ? pure [ threaded, threadedDebug ]
, notStage0 ? platformSupportsSharedLibs ? pure
- [ dynamic, debugDynamic, threadedDynamic, threadedDebugDynamic ]
+ [ dynamic, debugDynamic ]
+ , notStage0 ? platformSupportsSharedLibs ? targetSupportsThreadedRts ? pure [
+ threadedDynamic, threadedDebugDynamic
+ ]
] }
quickArgs :: Args
diff --git a/hadrian/src/Settings/Flavours/QuickCross.hs b/hadrian/src/Settings/Flavours/QuickCross.hs
index 45e23402e4..152a3c5641 100644
--- a/hadrian/src/Settings/Flavours/QuickCross.hs
+++ b/hadrian/src/Settings/Flavours/QuickCross.hs
@@ -20,10 +20,13 @@ quickCrossFlavour = defaultFlavour
, rtsWays = Set.fromList <$>
mconcat
[ pure
- [ vanilla, threaded, debug, threadedDebug, threaded ]
+ [ vanilla, debug ]
+ , targetSupportsThreadedRts ? pure [threaded, threadedDebug]
, notStage0 ? platformSupportsSharedLibs ? pure
- [ dynamic, debugDynamic, threadedDynamic
- , threadedDebugDynamic ]
+ [ dynamic, debugDynamic ]
+ , notStage0 ? platformSupportsSharedLibs ? targetSupportsThreadedRts ? pure [
+ threadedDynamic, threadedDebugDynamic
+ ]
] }
quickCrossArgs :: Args
diff --git a/hadrian/src/Settings/Flavours/Quickest.hs b/hadrian/src/Settings/Flavours/Quickest.hs
index ee695d99b1..318e7c8359 100644
--- a/hadrian/src/Settings/Flavours/Quickest.hs
+++ b/hadrian/src/Settings/Flavours/Quickest.hs
@@ -4,6 +4,7 @@ import qualified Data.Set as Set
import Expression
import Flavour
+import Oracles.Flag
import {-# SOURCE #-} Settings.Default
-- Please update doc/flavours.md when changing this file.
@@ -12,7 +13,7 @@ quickestFlavour = defaultFlavour
{ name = "quickest"
, args = defaultBuilderArgs <> quickestArgs <> defaultPackageArgs
, libraryWays = pure (Set.fromList [vanilla])
- , rtsWays = pure (Set.fromList [vanilla, threaded])
+ , rtsWays = pure (Set.fromList [vanilla]) <> (targetSupportsThreadedRts ? pure (Set.fromList [threaded]))
, dynamicGhcPrograms = return False }
quickestArgs :: Args
diff --git a/hadrian/src/Settings/Flavours/Validate.hs b/hadrian/src/Settings/Flavours/Validate.hs
index 7ecc97cf37..f70e33cb98 100644
--- a/hadrian/src/Settings/Flavours/Validate.hs
+++ b/hadrian/src/Settings/Flavours/Validate.hs
@@ -18,10 +18,13 @@ validateFlavour = enableLinting $ werror $ defaultFlavour
, notStage0 ? platformSupportsSharedLibs ? pure [dynamic]
]
, rtsWays = Set.fromList <$>
- mconcat [ pure [vanilla, threaded, debug, threadedDebug]
+ mconcat [ pure [vanilla, debug]
+ , targetSupportsThreadedRts ? pure [threaded, threadedDebug]
, notStage0 ? platformSupportsSharedLibs ? pure
- [ dynamic, threadedDynamic, debugDynamic, threadedDebugDynamic
+ [ dynamic, debugDynamic
]
+ , notStage0 ? platformSupportsSharedLibs ? targetSupportsThreadedRts ? pure
+ [ threadedDynamic, threadedDebugDynamic ]
]
, ghcDebugAssertions = (<= Stage1)
}