diff options
author | Ben Gamari <ben@smart-cactus.org> | 2019-10-22 13:26:28 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-10-29 03:48:20 -0400 |
commit | 6a0902702d64ce683c81c04069f46f6e1078a094 (patch) | |
tree | fe3b669b038f570b67b3bd450d37cb3da9b9634e | |
parent | 8e5de15da1ded1909e10483c7ae3ba1ae3e87b17 (diff) | |
download | haskell-6a0902702d64ce683c81c04069f46f6e1078a094.tar.gz |
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.
-rw-r--r-- | hadrian/cfg/system.config.in | 1 | ||||
-rw-r--r-- | hadrian/src/Oracles/Flag.hs | 25 | ||||
-rw-r--r-- | hadrian/src/Oracles/Setting.hs | 33 | ||||
-rw-r--r-- | hadrian/src/Rules/Generate.hs | 2 | ||||
-rw-r--r-- | hadrian/src/Settings/Builders/DeriveConstants.hs | 2 | ||||
-rw-r--r-- | hadrian/src/Settings/Packages.hs | 6 |
6 files changed, 54 insertions, 15 deletions
diff --git a/hadrian/cfg/system.config.in b/hadrian/cfg/system.config.in index 80fc3a3043..6c78f43ccb 100644 --- a/hadrian/cfg/system.config.in +++ b/hadrian/cfg/system.config.in @@ -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: #================================= diff --git a/hadrian/src/Oracles/Flag.hs b/hadrian/src/Oracles/Flag.hs index 134edc706e..90b25eef42 100644 --- a/hadrian/src/Oracles/Flag.hs +++ b/hadrian/src/Oracles/Flag.hs @@ -1,6 +1,8 @@ +{-# 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 diff --git a/hadrian/src/Oracles/Setting.hs b/hadrian/src/Oracles/Setting.hs index c84400ac69..2fa729413e 100644 --- a/hadrian/src/Oracles/Setting.hs +++ b/hadrian/src/Oracles/Setting.hs @@ -1,9 +1,19 @@ 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 diff --git a/hadrian/src/Rules/Generate.hs b/hadrian/src/Rules/Generate.hs index e185a46ea5..d0b7f1015a 100644 --- a/hadrian/src/Rules/Generate.hs +++ b/hadrian/src/Rules/Generate.hs @@ -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) diff --git a/hadrian/src/Settings/Builders/DeriveConstants.hs b/hadrian/src/Settings/Builders/DeriveConstants.hs index 0747162f43..0e7a1c1c11 100644 --- a/hadrian/src/Settings/Builders/DeriveConstants.hs +++ b/hadrian/src/Settings/Builders/DeriveConstants.hs @@ -45,5 +45,5 @@ includeCcArgs = do , arg "-Irts" , arg "-Iincludes" , arg $ "-I" ++ libPath - , notM ghcWithSMP ? arg "-DNOSMP" + , notM targetSupportsSMP ? arg "-DNOSMP" , arg "-fcommon" ] diff --git a/hadrian/src/Settings/Packages.hs b/hadrian/src/Settings/Packages.hs index 349c6518fb..014b1283c3 100644 --- a/hadrian/src/Settings/Packages.hs +++ b/hadrian/src/Settings/Packages.hs @@ -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 |