Commit 6a090270 authored by Ben Gamari's avatar Ben Gamari 🐢 Committed by Marge Bot

hadrian: Define NOSMP when building rts unregisterised

It seems that NOSMP was previously only defined when compiling the
compiler, not the RTS. Fix this.

In addition do some spring-cleaning and make the logic match that of the
Make build system.
parent 8e5de15d
......@@ -150,6 +150,7 @@ target-has-gnu-nonexec-stack = @TargetHasGnuNonexecStack@
target-has-ident-directive = @TargetHasIdentDirective@
target-has-subsections-via-symbols = @TargetHasSubsectionsViaSymbols@
target-has-rts-linker = @TargetHasRTSLinker@
target-arm-version = @ARM_ISA@
# Include and library directories:
#=================================
......
{-# LANGUAGE MultiWayIf #-}
module Oracles.Flag (
Flag (..), flag, getFlag, platformSupportsSharedLibs, ghcWithSMP,
ghcWithNativeCodeGen
Flag (..), flag, getFlag, platformSupportsSharedLibs,
ghcWithNativeCodeGen, targetSupportsSMP
) where
import Hadrian.Oracles.TextFile
......@@ -57,11 +59,20 @@ platformSupportsSharedLibs = do
solarisBroken <- flag SolarisBrokenShld
return $ not (badPlatform || solaris && solarisBroken)
ghcWithSMP :: Action Bool
ghcWithSMP = do
goodArch <- anyTargetArch ["i386", "x86_64", "sparc", "powerpc", "arm", "s390x"]
ghcUnreg <- flag GhcUnregisterised
return $ goodArch && not ghcUnreg
-- | Does the target support the threaded runtime system?
targetSupportsSMP :: Action Bool
targetSupportsSMP = do
unreg <- flag GhcUnregisterised
armVer <- targetArmVersion
goodArch <- anyTargetArch ["i386", "x86_64", "sparc", "powerpc", "arm", "s390x"]
if -- The THREADED_RTS requires `BaseReg` to be in a register and the
-- Unregisterised mode doesn't allow that.
| unreg -> return False
-- We don't support load/store barriers pre-ARMv7. See #10433.
| Just ver <- armVer
, ver < ARMv7 -> return False
| goodArch -> return True
| otherwise -> return False
ghcWithNativeCodeGen :: Action Bool
ghcWithNativeCodeGen = do
......
module Oracles.Setting (
configFile, Setting (..), SettingList (..), setting, settingList, getSetting,
getSettingList, anyTargetPlatform, anyTargetOs, anyTargetArch, anyHostOs,
ghcWithInterpreter, useLibFFIForAdjustors,
configFile,
-- * Settings
Setting (..), SettingList (..), setting, settingList, getSetting,
getSettingList,
SettingsFileSetting (..), settingsFileSetting,
-- * Helpers
ghcCanonVersion, cmdLineLengthLimit, hostSupportsRPaths, topDirectory,
libsuf, ghcVersionStage, SettingsFileSetting (..), settingsFileSetting
libsuf, ghcVersionStage,
-- ** Target platform things
anyTargetPlatform, anyTargetOs, anyTargetArch, anyHostOs,
ArmVersion(..),
targetArmVersion,
ghcWithInterpreter, useLibFFIForAdjustors
) where
import Hadrian.Expression
......@@ -60,6 +70,7 @@ data Setting = BuildArch
| TargetVendor
| TargetArchHaskell
| TargetOsHaskell
| TargetArmVersion
-- TODO: Reduce the variety of similar flags (e.g. CPP and non-CPP versions).
-- | Each 'SettingList' comes from the file @hadrian/cfg/system.config@,
......@@ -140,6 +151,7 @@ setting key = lookupValueOrError configFile $ case key of
ProjectPatchLevel2 -> "project-patch-level2"
SystemGhc -> "system-ghc"
TargetArch -> "target-arch"
TargetArmVersion -> "target-arm-version"
TargetOs -> "target-os"
TargetPlatform -> "target-platform"
TargetPlatformFull -> "target-platform-full"
......@@ -233,6 +245,19 @@ ghcWithInterpreter = do
useLibFFIForAdjustors :: Action Bool
useLibFFIForAdjustors = notM $ anyTargetArch ["i386", "x86_64"]
-- | Variants of the ARM architecture.
data ArmVersion = ARMv5 | ARMv6 | ARMv7
deriving (Eq, Ord, Show, Read)
-- | Which variant of the ARM architecture is the target (or 'Nothing' if not
-- ARM)?
targetArmVersion :: Action (Maybe ArmVersion)
targetArmVersion = do
isArm <- anyTargetArch [ "arm" ]
if isArm
then Just . read <$> setting TargetArmVersion
else return Nothing
-- | Canonicalised GHC version number, used for integer version comparisons. We
-- expand 'GhcMinorVersion' to two digits by adding a leading zero if necessary.
ghcCanonVersion :: Action String
......
......@@ -315,7 +315,7 @@ generateSettings = do
, ("integer library", pkgName <$> getIntegerPackage)
, ("Use interpreter", expr $ yesNo <$> ghcWithInterpreter)
, ("Use native code generator", expr $ yesNo <$> ghcWithNativeCodeGen)
, ("Support SMP", expr $ yesNo <$> ghcWithSMP)
, ("Support SMP", expr $ yesNo <$> targetSupportsSMP)
, ("RTS ways", unwords . map show <$> getRtsWays)
, ("Tables next to code", expr $ yesNo <$> flag TablesNextToCode)
, ("Leading underscore", expr $ yesNo <$> flag LeadingUnderscore)
......
......@@ -45,5 +45,5 @@ includeCcArgs = do
, arg "-Irts"
, arg "-Iincludes"
, arg $ "-I" ++ libPath
, notM ghcWithSMP ? arg "-DNOSMP"
, notM targetSupportsSMP ? arg "-DNOSMP"
, arg "-fcommon" ]
......@@ -61,8 +61,8 @@ packageArgs = do
[ arg "--disable-library-for-ghci"
, anyTargetOs ["openbsd"] ? arg "--ld-options=-E"
, flag GhcUnregisterised ? arg "--ghc-option=-DNO_REGS"
, notM ghcWithSMP ? arg "--ghc-option=-DNOSMP"
, notM ghcWithSMP ? arg "--ghc-option=-optc-DNOSMP"
, notM targetSupportsSMP ? arg "--ghc-option=-DNOSMP"
, notM targetSupportsSMP ? arg "--ghc-option=-optc-DNOSMP"
, (any (wayUnit Threaded) rtsWays) ?
notStage0 ? arg "--ghc-option=-optc-DTHREADED_RTS"
, ghcWithInterpreter ?
......@@ -231,6 +231,8 @@ rtsPackageArgs = package rts ? do
, inputs ["**/RtsMessages.c", "**/Trace.c"] ?
arg ("-DProjectVersion=" ++ show projectVersion)
, notM targetSupportsSMP ? arg "-DNOSMP"
, input "**/RtsUtils.c" ? pure
[ "-DProjectVersion=" ++ show projectVersion
, "-DHostPlatform=" ++ show hostPlatform
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment