summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hadrian/doc/make.md11
-rw-r--r--hadrian/doc/user-settings.md14
-rw-r--r--hadrian/hadrian.cabal1
-rw-r--r--hadrian/src/CommandLine.hs29
-rw-r--r--hadrian/src/Flavour.hs6
-rw-r--r--hadrian/src/Packages.hs5
-rw-r--r--hadrian/src/Rules/Generate.hs8
-rw-r--r--hadrian/src/Rules/Gmp.hs16
-rw-r--r--hadrian/src/Rules/Library.hs11
-rw-r--r--hadrian/src/Rules/Register.hs12
-rwxr-xr-xhadrian/src/Settings.hs15
-rw-r--r--hadrian/src/Settings/Builders/RunTest.hs4
-rw-r--r--hadrian/src/Settings/Default.hs17
-rw-r--r--hadrian/src/Settings/Default.hs-boot3
-rw-r--r--hadrian/src/Settings/Flavours/Common.hs11
-rw-r--r--hadrian/src/Settings/Flavours/GhcInGhci.hs2
-rw-r--r--hadrian/src/Settings/Flavours/Profiled.hs2
-rw-r--r--hadrian/src/Settings/Flavours/Quick.hs2
-rw-r--r--hadrian/src/Settings/Flavours/QuickCross.hs2
-rw-r--r--hadrian/src/Settings/Flavours/Quickest.hs2
-rw-r--r--hadrian/src/Settings/Packages.hs92
-rw-r--r--hadrian/src/Settings/Warnings.hs4
22 files changed, 137 insertions, 132 deletions
diff --git a/hadrian/doc/make.md b/hadrian/doc/make.md
index b0e19e4721..318b736fa5 100644
--- a/hadrian/doc/make.md
+++ b/hadrian/doc/make.md
@@ -94,17 +94,6 @@ time you fire up a build. This is not possible with the Make build system.
```
See [flavours documentation](https://gitlab.haskell.org/ghc/ghc/blob/master/hadrian/doc/flavours.md) for info on flavours.
-- Building with `integer-simple` as the integer library
-
- ``` sh
- # Make
- echo "INTEGER_LIBRARY=integer-simple" >> mk/build.mk
- make
-
- # Hadrian
- build --integer-simple
- ```
-
- Freezing the stage 1 GHC compiler
``` sh
diff --git a/hadrian/doc/user-settings.md b/hadrian/doc/user-settings.md
index 9963bac5ed..ada2b98760 100644
--- a/hadrian/doc/user-settings.md
+++ b/hadrian/doc/user-settings.md
@@ -21,8 +21,10 @@ data Flavour = Flavour {
args :: Args,
-- | Build these packages.
packages :: Stage -> Action [Package],
- -- | Either 'integerGmp' or 'integerSimple'.
- integerLibrary :: Action Package,
+ -- | Bignum backend: 'native', 'gmp', 'ffi', etc.
+ bignumBackend :: String,
+ -- | Check bignum backend against native
+ bignumCheck :: Bool,
-- | Build libraries these ways.
libraryWays :: Ways,
-- | Build RTS these ways.
@@ -168,12 +170,12 @@ userPackage = library "user-package"
You will also need to add `userPackage` to a specific build stage by modifying
the `packages` setting of the user flavour as otherwise it will not be built.
-You can choose which integer library to use when building GHC using the
-`integerLibrary` setting of the build flavour. Possible values are: `integerGmp`
-(default) and `integerSimple`.
+You can choose which Bignum backend to use when buidling GHC using the
+`bignumBackend` setting of the build flavour. Possible values are: `gmp`
+(default), `native` or `ffi`.
```haskell
userFlavour :: Flavour
-userFlavour = defaultFlavour { name = "user", integerLibrary = pure integerSimple }
+userFlavour = defaultFlavour { name = "user", bignumBackend = "native" }
```
#### Specifying the final stage to build
diff --git a/hadrian/hadrian.cabal b/hadrian/hadrian.cabal
index 19ba672c09..11f34a26ba 100644
--- a/hadrian/hadrian.cabal
+++ b/hadrian/hadrian.cabal
@@ -102,7 +102,6 @@ executable hadrian
, Settings.Builders.Xelatex
, Settings.Default
, Settings.Flavours.Benchmark
- , Settings.Flavours.Common
, Settings.Flavours.Development
, Settings.Flavours.Llvm
, Settings.Flavours.Performance
diff --git a/hadrian/src/CommandLine.hs b/hadrian/src/CommandLine.hs
index 5446fda574..4582a8b258 100644
--- a/hadrian/src/CommandLine.hs
+++ b/hadrian/src/CommandLine.hs
@@ -1,6 +1,6 @@
module CommandLine (
optDescrs, cmdLineArgsMap, cmdFlavour, lookupFreeze1, lookupFreeze2,
- cmdIntegerSimple, cmdProgressInfo, cmdConfigure, cmdCompleteSetting,
+ cmdBignum, cmdBignumCheck, cmdProgressInfo, cmdConfigure, cmdCompleteSetting,
cmdDocsArgs, lookupBuildRoot, TestArgs(..), TestSpeed(..), defaultTestArgs,
cmdPrefix
) where
@@ -26,7 +26,8 @@ data CommandLineArgs = CommandLineArgs
, flavour :: Maybe String
, freeze1 :: Bool
, freeze2 :: Bool
- , integerSimple :: Bool
+ , bignum :: Maybe String
+ , bignumCheck :: Bool
, progressInfo :: ProgressInfo
, buildRoot :: BuildRoot
, testArgs :: TestArgs
@@ -42,7 +43,8 @@ defaultCommandLineArgs = CommandLineArgs
, flavour = Nothing
, freeze1 = False
, freeze2 = False
- , integerSimple = False
+ , bignum = Nothing
+ , bignumCheck = False
, progressInfo = Brief
, buildRoot = BuildRoot "_build"
, testArgs = defaultTestArgs
@@ -96,6 +98,13 @@ readConfigure = Right $ \flags -> flags { configure = True }
readFlavour :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs)
readFlavour ms = Right $ \flags -> flags { flavour = lower <$> ms }
+readBignum :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs)
+readBignum Nothing = Right id
+readBignum (Just ms) = Right $ \flags -> case break (== '-') (lower ms) of
+ (backend,"") -> flags { bignum = Just backend }
+ ("check",'-':backend) -> flags { bignum = Just backend, bignumCheck = True }
+ _ -> flags { bignum = Just (lower ms) }
+
readBuildRoot :: Maybe FilePath -> Either String (CommandLineArgs -> CommandLineArgs)
readBuildRoot ms =
maybe (Left "Cannot parse build-root") (Right . set) (go =<< ms)
@@ -109,9 +118,6 @@ readFreeze1, readFreeze2 :: Either String (CommandLineArgs -> CommandLineArgs)
readFreeze1 = Right $ \flags -> flags { freeze1 = True }
readFreeze2 = Right $ \flags -> flags { freeze1 = True, freeze2 = True }
-readIntegerSimple :: Either String (CommandLineArgs -> CommandLineArgs)
-readIntegerSimple = Right $ \flags -> flags { integerSimple = True }
-
readProgressInfo :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs)
readProgressInfo ms =
maybe (Left "Cannot parse progress-info") (Right . set) (go =<< lower <$> ms)
@@ -250,8 +256,8 @@ optDescrs =
"Freeze Stage1 GHC."
, Option [] ["freeze2"] (NoArg readFreeze2)
"Freeze Stage2 GHC."
- , Option [] ["integer-simple"] (NoArg readIntegerSimple)
- "Build GHC with integer-simple library."
+ , Option [] ["bignum"] (OptArg readBignum "BIGNUM")
+ "Select GHC BigNum backend: native, gmp, ffi."
, Option [] ["progress-info"] (OptArg readProgressInfo "STYLE")
"Progress info style (None, Brief, Normal or Unicorn)."
, Option [] ["docs"] (OptArg readDocsArg "TARGET")
@@ -355,8 +361,11 @@ lookupFreeze1 = freeze1 . lookupExtra defaultCommandLineArgs
lookupFreeze2 :: Map.HashMap TypeRep Dynamic -> Bool
lookupFreeze2 = freeze2 . lookupExtra defaultCommandLineArgs
-cmdIntegerSimple :: Action Bool
-cmdIntegerSimple = integerSimple <$> cmdLineArgs
+cmdBignum :: Action (Maybe String)
+cmdBignum = bignum <$> cmdLineArgs
+
+cmdBignumCheck :: Action Bool
+cmdBignumCheck = bignumCheck <$> cmdLineArgs
cmdProgressInfo :: Action ProgressInfo
cmdProgressInfo = progressInfo <$> cmdLineArgs
diff --git a/hadrian/src/Flavour.hs b/hadrian/src/Flavour.hs
index 64ce931e78..56488f0b0a 100644
--- a/hadrian/src/Flavour.hs
+++ b/hadrian/src/Flavour.hs
@@ -25,8 +25,10 @@ data Flavour = Flavour {
args :: Args,
-- | Build these packages.
packages :: Stage -> Action [Package],
- -- | Either 'integerGmp' or 'integerSimple'.
- integerLibrary :: Action Package,
+ -- | 'native', 'gmp', 'ffi'.
+ bignumBackend :: String,
+ -- | Check selected backend against native backend
+ bignumCheck :: Bool,
-- | Build libraries these ways.
libraryWays :: Ways,
-- | Build RTS these ways.
diff --git a/hadrian/src/Packages.hs b/hadrian/src/Packages.hs
index e65e8c9709..fa87d8edcd 100644
--- a/hadrian/src/Packages.hs
+++ b/hadrian/src/Packages.hs
@@ -3,7 +3,7 @@ module Packages (
-- * GHC packages
array, base, binary, bytestring, cabal, checkApiAnnotations, checkPpr,
compareSizes, compiler, containers, deepseq, deriveConstants, directory,
- exceptions, filepath, genapply, genprimopcode, ghc, ghcBoot, ghcBootTh,
+ exceptions, filepath, genapply, genprimopcode, ghc, ghcBignum, ghcBoot, ghcBootTh,
ghcCompact, ghcHeap, ghci, ghcPkg, ghcPrim, haddock, haskeline,
hsc2hs, hp2ps, hpc, hpcBin, integerGmp, integerSimple, iserv, iservProxy,
libffi, libiserv, mtl, parsec, pretty, primitive, process, remoteIserv, rts,
@@ -33,7 +33,7 @@ ghcPackages :: [Package]
ghcPackages =
[ array, base, binary, bytestring, cabal, checkPpr, checkApiAnnotations
, compareSizes, compiler, containers, deepseq, deriveConstants, directory
- , exceptions, filepath, genapply, genprimopcode, ghc, ghcBoot, ghcBootTh
+ , exceptions, filepath, genapply, genprimopcode, ghc, ghcBignum, ghcBoot, ghcBootTh
, ghcCompact, ghcHeap, ghci, ghcPkg, ghcPrim, haddock, haskeline, hsc2hs
, hp2ps, hpc, hpcBin, integerGmp, integerSimple, iserv, libffi, libiserv, mtl
, parsec, pretty, process, rts, runGhc, stm, templateHaskell
@@ -63,6 +63,7 @@ filepath = lib "filepath"
genapply = util "genapply"
genprimopcode = util "genprimopcode"
ghc = prg "ghc-bin" `setPath` "ghc"
+ghcBignum = lib "ghc-bignum"
ghcBoot = lib "ghc-boot"
ghcBootTh = lib "ghc-boot-th"
ghcCompact = lib "ghc-compact"
diff --git a/hadrian/src/Rules/Generate.hs b/hadrian/src/Rules/Generate.hs
index 32d29019a7..6222fcd3af 100644
--- a/hadrian/src/Rules/Generate.hs
+++ b/hadrian/src/Rules/Generate.hs
@@ -50,13 +50,13 @@ derivedConstantsFiles =
compilerDependencies :: Expr [FilePath]
compilerDependencies = do
stage <- getStage
- isGmp <- (== integerGmp) <$> getIntegerPackage
+ isGmp <- (== "gmp") <$> getBignumBackend
ghcPath <- expr $ buildPath (vanillaContext stage compiler)
- gmpPath <- expr $ buildPath (vanillaContext stage integerGmp)
+ ghcBignumPath <- expr $ buildPath (vanillaContext stage ghcBignum)
rtsPath <- expr (rtsBuildPath stage)
libDir <- expr $ stageLibPath stage
mconcat [ return $ (libDir -/-) <$> derivedConstantsFiles
- , notStage0 ? isGmp ? return [gmpPath -/- "include/ghc-gmp.h"]
+ , notStage0 ? isGmp ? return [ghcBignumPath -/- "include/ghc-gmp.h"]
, notStage0 ? return ((rtsPath -/-) <$> libffiHeaderFiles)
, return $ fmap (ghcPath -/-)
[ "primop-can-fail.hs-incl"
@@ -316,7 +316,7 @@ generateSettings = do
, ("LLVM opt command", expr $ settingsFileSetting SettingsFileSetting_OptCommand)
, ("LLVM clang command", expr $ settingsFileSetting SettingsFileSetting_ClangCommand)
- , ("integer library", pkgName <$> getIntegerPackage)
+ , ("BigNum backend", getBignumBackend)
, ("Use interpreter", expr $ yesNo <$> ghcWithInterpreter)
, ("Use native code generator", expr $ yesNo <$> ghcWithNativeCodeGen)
, ("Support SMP", expr $ yesNo <$> targetSupportsSMP)
diff --git a/hadrian/src/Rules/Gmp.hs b/hadrian/src/Rules/Gmp.hs
index 3fe45d251f..6d89a5b0e9 100644
--- a/hadrian/src/Rules/Gmp.hs
+++ b/hadrian/src/Rules/Gmp.hs
@@ -18,9 +18,9 @@ gmpObjects s = do
then return []
else do
-- Indirectly ensure object creation
- let ctx = vanillaContext s integerGmp
- integerGmpPath <- buildPath ctx
- need [integerGmpPath -/- "include/ghc-gmp.h"]
+ let ctx = vanillaContext s ghcBignum
+ ghcBignumPath <- buildPath ctx
+ need [ghcBignumPath -/- "include/ghc-gmp.h"]
gmpPath <- gmpIntreePath s
map (unifyPath . (gmpPath -/-)) <$>
@@ -49,13 +49,13 @@ gmpRules = do
let
-- Path to libraries/integer-gmp/gmp in the source tree
gmpBase :: FilePath
- gmpBase = pkgPath integerGmp -/- "gmp"
+ gmpBase = pkgPath ghcBignum -/- "gmp"
-- Build in-tree gmp if necessary
- -- Produce: integer-gmp/build/include/ghc-gmp.h
+ -- Produce: ghc-bignum/build/include/ghc-gmp.h
-- In-tree: copy gmp.h from in-tree build
-- External: copy ghc-gmp.h from base sources
- root -/- "stage*/libraries/integer-gmp/build/include/ghc-gmp.h" %> \header -> do
+ root -/- "stage*/libraries/ghc-bignum/build/include/ghc-gmp.h" %> \header -> do
let includeP = takeDirectory header
buildP = takeDirectory includeP
packageP = takeDirectory buildP
@@ -80,13 +80,13 @@ gmpRules = do
let
-- parse a path of the form "//stage*/gmp/xxx" and returns a vanilla
- -- context from it for integer-gmp package.
+ -- context from it for ghc-bignum package.
makeGmpPathContext gmpP = do
let
stageP = takeDirectory gmpP
stageS = takeFileName stageP
stage <- parsePath parseStage "<stage>" stageS
- pure (vanillaContext stage integerGmp)
+ pure (vanillaContext stage ghcBignum)
gmpPath = root -/- "stage*/gmp"
diff --git a/hadrian/src/Rules/Library.hs b/hadrian/src/Rules/Library.hs
index 066f609a49..805213d6ae 100644
--- a/hadrian/src/Rules/Library.hs
+++ b/hadrian/src/Rules/Library.hs
@@ -12,6 +12,7 @@ import Oracles.ModuleFiles
import Packages
import Rules.Gmp
import Rules.Register
+import Settings
import Target
import Utilities
@@ -131,11 +132,15 @@ cObjects context = do
-- | Return extra object files needed to build the given library context. The
-- resulting list is currently non-empty only when the package from the
--- 'Context' is @integer-gmp@.
+-- 'Context' is @ghc-bignum@ built with in-tree GMP backend.
extraObjects :: Context -> Action [FilePath]
extraObjects context
- | package context == integerGmp = gmpObjects (stage context)
- | otherwise = return []
+ | package context == ghcBignum = do
+ interpretInContext context getBignumBackend >>= \case
+ "gmp" -> gmpObjects (stage context)
+ _ -> return []
+
+ | otherwise = return []
-- | Return all the object files to be put into the library we're building for
-- the given 'Context'.
diff --git a/hadrian/src/Rules/Register.hs b/hadrian/src/Rules/Register.hs
index 51df69f116..6bbae7e0bd 100644
--- a/hadrian/src/Rules/Register.hs
+++ b/hadrian/src/Rules/Register.hs
@@ -39,8 +39,10 @@ configurePackageRules = do
let pkg = unsafeFindPackageByPath path
let ctx = Context stage pkg vanilla
buildP <- buildPath ctx
- when (pkg == integerGmp) $
- need [buildP -/- "include/ghc-gmp.h"]
+ when (pkg == ghcBignum) $ do
+ isGmp <- (== "gmp") <$> interpretInContext ctx getBignumBackend
+ when isGmp $
+ need [buildP -/- "include/ghc-gmp.h"]
needLibrary =<< contextDependencies ctx
Cabal.configurePackage ctx
@@ -129,8 +131,10 @@ buildConf _ context@Context {..} _conf = do
, path -/- "ghcversion.h" ]
-- we need to generate this file for GMP
- when (package == integerGmp) $
- need [path -/- "include/ghc-gmp.h"]
+ when (package == ghcBignum) $ do
+ bignum <- interpretInContext context getBignumBackend
+ when (bignum == "gmp") $
+ need [path -/- "include/ghc-gmp.h"]
-- Copy and register the package.
Cabal.copyPackage context
diff --git a/hadrian/src/Settings.hs b/hadrian/src/Settings.hs
index 7c6a24af27..373e976b44 100755
--- a/hadrian/src/Settings.hs
+++ b/hadrian/src/Settings.hs
@@ -1,7 +1,7 @@
module Settings (
getArgs, getLibraryWays, getRtsWays, flavour, knownPackages,
findPackageByName, unsafeFindPackageByName, unsafeFindPackageByPath,
- isLibrary, stagePackages, getIntegerPackage, completeSetting
+ isLibrary, stagePackages, getBignumBackend, getBignumCheck, completeSetting
) where
import CommandLine
@@ -35,6 +35,16 @@ getLibraryWays = expr flavour >>= libraryWays
getRtsWays :: Ways
getRtsWays = expr flavour >>= rtsWays
+getBignumBackend :: Expr String
+getBignumBackend = expr $ cmdBignum >>= \case
+ Nothing -> bignumBackend <$> flavour
+ Just b -> pure b
+
+getBignumCheck :: Expr Bool
+getBignumCheck = expr $ cmdBignum >>= \case
+ Nothing -> bignumCheck <$> flavour
+ Just _ -> cmdBignumCheck
+
stagePackages :: Stage -> Action [Package]
stagePackages stage = do
f <- flavour
@@ -67,9 +77,6 @@ flavour = do
[f] -> tweak f
_ -> error $ "Multiple build flavours named " ++ flavourName
-getIntegerPackage :: Expr Package
-getIntegerPackage = expr (integerLibrary =<< flavour)
-
-- TODO: switch to Set Package as the order of packages should not matter?
-- Otherwise we have to keep remembering to sort packages from time to time.
knownPackages :: [Package]
diff --git a/hadrian/src/Settings/Builders/RunTest.hs b/hadrian/src/Settings/Builders/RunTest.hs
index 293465b52b..c10e93aae0 100644
--- a/hadrian/src/Settings/Builders/RunTest.hs
+++ b/hadrian/src/Settings/Builders/RunTest.hs
@@ -87,6 +87,8 @@ runTestBuilderArgs = builder RunTest ? do
top <- expr $ topDirectory
ghcFlags <- expr runTestGhcFlags
cmdrootdirs <- expr (testRootDirs <$> userSetting defaultTestArgs)
+ bignumBackend <- getBignumBackend
+ bignumCheck <- getBignumCheck
let defaultRootdirs = ("testsuite" -/- "tests") : libTests
rootdirs | null cmdrootdirs = defaultRootdirs
| otherwise = cmdrootdirs
@@ -121,9 +123,11 @@ runTestBuilderArgs = builder RunTest ? do
, arg "-e", arg $ asBool "config.have_vanilla=" (hasLibWay vanilla)
, arg "-e", arg $ asBool "config.have_dynamic=" (hasLibWay dynamic)
, arg "-e", arg $ asBool "config.have_profiling=" (hasLibWay profiling)
+ , arg "-e", arg $ asBool "config.have_fast_bignum=" (bignumBackend /= "native" && not bignumCheck)
, arg "-e", arg $ asBool "ghc_with_smp=" withSMP
, arg "-e", arg $ asBool "ghc_with_llvm=" withLlvm
+
, arg "-e", arg $ "config.ghc_dynamic_by_default=" ++ show hasDynamicByDefault
, arg "-e", arg $ "config.ghc_dynamic=" ++ show hasDynamic
diff --git a/hadrian/src/Settings/Default.hs b/hadrian/src/Settings/Default.hs
index 5c6fb7254d..cb1222103b 100644
--- a/hadrian/src/Settings/Default.hs
+++ b/hadrian/src/Settings/Default.hs
@@ -9,8 +9,8 @@ module Settings.Default (
SourceArgs (..), sourceArgs, defaultBuilderArgs, defaultPackageArgs,
defaultArgs,
- -- * Default build flavour
- defaultFlavour
+ -- * Default build flavour and BigNum backend
+ defaultFlavour, defaultBignumBackend
) where
import qualified Hadrian.Builder.Ar
@@ -23,7 +23,6 @@ import Expression
import Flavour
import Oracles.Flag
import Packages
-import Settings
import Settings.Builders.Alex
import Settings.Builders.DeriveConstants
import Settings.Builders.Cabal
@@ -50,6 +49,10 @@ defaultPackages Stage1 = stage1Packages
defaultPackages Stage2 = stage2Packages
defaultPackages Stage3 = return []
+-- | Default bignum backend.
+defaultBignumBackend :: String
+defaultBignumBackend = "gmp"
+
-- | Packages built in 'Stage0' by default. You can change this in "UserSettings".
stage0Packages :: Action [Package]
stage0Packages = do
@@ -63,6 +66,7 @@ stage0Packages = do
, genapply
, genprimopcode
, ghc
+ , ghcBignum
, ghcBoot
, ghcBootTh
, ghcHeap
@@ -86,7 +90,6 @@ stage0Packages = do
-- | Packages built in 'Stage1' by default. You can change this in "UserSettings".
stage1Packages :: Action [Package]
stage1Packages = do
- intLib <- integerLibrary =<< flavour
libraries0 <- filter isLibrary <$> stage0Packages
cross <- flag CrossCompiling
return $ libraries0 -- Build all Stage0 libraries in Stage1
@@ -99,13 +102,14 @@ stage1Packages = do
, exceptions
, filepath
, ghc
+ , ghcBignum
, ghcCompact
, ghcPkg
, ghcPrim
, haskeline
, hp2ps
, hsc2hs
- , intLib
+ , integerGmp
, pretty
, process
, rts
@@ -202,7 +206,8 @@ defaultFlavour = Flavour
{ name = "default"
, args = defaultArgs
, packages = defaultPackages
- , integerLibrary = (\x -> if x then integerSimple else integerGmp) <$> cmdIntegerSimple
+ , bignumBackend = defaultBignumBackend
+ , bignumCheck = False
, libraryWays = defaultLibraryWays
, rtsWays = defaultRtsWays
, dynamicGhcPrograms = defaultDynamicGhcPrograms
diff --git a/hadrian/src/Settings/Default.hs-boot b/hadrian/src/Settings/Default.hs-boot
index e2996d9c71..a6585384a1 100644
--- a/hadrian/src/Settings/Default.hs-boot
+++ b/hadrian/src/Settings/Default.hs-boot
@@ -1,7 +1,7 @@
module Settings.Default (
SourceArgs (..), sourceArgs, defaultBuilderArgs, defaultPackageArgs,
defaultArgs, defaultLibraryWays, defaultRtsWays,
- defaultFlavour
+ defaultFlavour, defaultBignumBackend
) where
import Flavour
@@ -18,3 +18,4 @@ sourceArgs :: SourceArgs -> Args
defaultBuilderArgs, defaultPackageArgs, defaultArgs :: Args
defaultLibraryWays, defaultRtsWays :: Ways
defaultFlavour :: Flavour
+defaultBignumBackend :: String
diff --git a/hadrian/src/Settings/Flavours/Common.hs b/hadrian/src/Settings/Flavours/Common.hs
deleted file mode 100644
index cba0bcd978..0000000000
--- a/hadrian/src/Settings/Flavours/Common.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-module Settings.Flavours.Common where
-
-import Expression
-
--- See https://gitlab.haskell.org/ghc/ghc/issues/15286 and
--- https://phabricator.haskell.org/D4880
-naturalInBaseFixArgs :: Args
-naturalInBaseFixArgs = mconcat
- [ input "**/Natural.hs" ? pure ["-fno-omit-interface-pragmas"]
- , input "**/Num.hs" ? pure ["-fno-ignore-interface-pragmas"]
- ]
diff --git a/hadrian/src/Settings/Flavours/GhcInGhci.hs b/hadrian/src/Settings/Flavours/GhcInGhci.hs
index 8533172064..950b96f926 100644
--- a/hadrian/src/Settings/Flavours/GhcInGhci.hs
+++ b/hadrian/src/Settings/Flavours/GhcInGhci.hs
@@ -3,7 +3,6 @@ module Settings.Flavours.GhcInGhci (ghcInGhciFlavour) where
import Expression
import Flavour
import {-# SOURCE #-} Settings.Default
-import Settings.Flavours.Common
-- Please update doc/flavours.md when changing this file.
ghcInGhciFlavour :: Flavour
@@ -21,7 +20,6 @@ ghciArgs :: Args
ghciArgs = sourceArgs SourceArgs
{ hsDefault = mconcat $
[ pure ["-O0", "-H64m"]
- , naturalInBaseFixArgs
]
, hsLibrary = mempty
, hsCompiler = mempty
diff --git a/hadrian/src/Settings/Flavours/Profiled.hs b/hadrian/src/Settings/Flavours/Profiled.hs
index 7f222bf33c..49339f1446 100644
--- a/hadrian/src/Settings/Flavours/Profiled.hs
+++ b/hadrian/src/Settings/Flavours/Profiled.hs
@@ -3,7 +3,6 @@ module Settings.Flavours.Profiled (profiledFlavour) where
import Expression
import Flavour
import {-# SOURCE #-} Settings.Default
-import Settings.Flavours.Common (naturalInBaseFixArgs)
-- Please update doc/flavours.md when changing this file.
profiledFlavour :: Flavour
@@ -17,7 +16,6 @@ profiledArgs :: Args
profiledArgs = sourceArgs SourceArgs
{ hsDefault = mconcat
[ pure ["-O0", "-H64m"]
- , naturalInBaseFixArgs
]
, hsLibrary = notStage0 ? arg "-O"
, hsCompiler = mconcat [stage0 ? arg "-O2", notStage0 ? arg "-O"]
diff --git a/hadrian/src/Settings/Flavours/Quick.hs b/hadrian/src/Settings/Flavours/Quick.hs
index 16ff99a091..deea0c47dd 100644
--- a/hadrian/src/Settings/Flavours/Quick.hs
+++ b/hadrian/src/Settings/Flavours/Quick.hs
@@ -4,7 +4,6 @@ import Expression
import Flavour
import Oracles.Flag
import {-# SOURCE #-} Settings.Default
-import Settings.Flavours.Common
-- Please update doc/flavours.md when changing this file.
quickFlavour :: Flavour
@@ -27,7 +26,6 @@ quickArgs :: Args
quickArgs = sourceArgs SourceArgs
{ hsDefault = mconcat $
[ pure ["-O0", "-H64m"]
- , naturalInBaseFixArgs
]
, hsLibrary = notStage0 ? arg "-O"
, hsCompiler = stage0 ? arg "-O2"
diff --git a/hadrian/src/Settings/Flavours/QuickCross.hs b/hadrian/src/Settings/Flavours/QuickCross.hs
index 3f2776ed50..5e9dc05f08 100644
--- a/hadrian/src/Settings/Flavours/QuickCross.hs
+++ b/hadrian/src/Settings/Flavours/QuickCross.hs
@@ -4,7 +4,6 @@ import Expression
import Flavour
import Oracles.Flag
import {-# SOURCE #-} Settings.Default
-import Settings.Flavours.Common
-- Please update doc/flavours.md when changing this file.
quickCrossFlavour :: Flavour
@@ -28,7 +27,6 @@ quickCrossArgs :: Args
quickCrossArgs = sourceArgs SourceArgs
{ hsDefault = mconcat $
[ pure ["-O0", "-H64m"]
- , naturalInBaseFixArgs
]
, hsLibrary = notStage0 ? mconcat [ arg "-O", arg "-fllvm" ]
, hsCompiler = stage0 ? arg "-O2"
diff --git a/hadrian/src/Settings/Flavours/Quickest.hs b/hadrian/src/Settings/Flavours/Quickest.hs
index c0fd72764f..58a8c280da 100644
--- a/hadrian/src/Settings/Flavours/Quickest.hs
+++ b/hadrian/src/Settings/Flavours/Quickest.hs
@@ -3,7 +3,6 @@ module Settings.Flavours.Quickest (quickestFlavour) where
import Expression
import Flavour
import {-# SOURCE #-} Settings.Default
-import Settings.Flavours.Common
-- Please update doc/flavours.md when changing this file.
quickestFlavour :: Flavour
@@ -18,7 +17,6 @@ quickestArgs :: Args
quickestArgs = sourceArgs SourceArgs
{ hsDefault = mconcat $
[ pure ["-O0", "-H64m"]
- , naturalInBaseFixArgs
]
, hsLibrary = mempty
, hsCompiler = stage0 ? arg "-O"
diff --git a/hadrian/src/Settings/Packages.hs b/hadrian/src/Settings/Packages.hs
index 8bb0f13fc5..8c9d7875d4 100644
--- a/hadrian/src/Settings/Packages.hs
+++ b/hadrian/src/Settings/Packages.hs
@@ -13,7 +13,6 @@ packageArgs = do
stage <- getStage
rtsWays <- getRtsWays
path <- getBuildPath
- intLib <- getIntegerPackage
compilerPath <- expr $ buildPath (vanillaContext stage compiler)
let -- Do not bind the result to a Boolean: this forces the configure rule
-- immediately and may lead to cyclic dependencies.
@@ -27,16 +26,12 @@ packageArgs = do
mconcat
--------------------------------- base ---------------------------------
[ package base ? mconcat
- [ builder (Cabal Flags) ? notStage0 ? arg (pkgName intLib)
+ [ builder (Cabal Flags) ? notStage0 ? arg (pkgName ghcBignum)
-- This fixes the 'unknown symbol stat' issue.
-- See: https://github.com/snowleopard/hadrian/issues/259.
, builder (Ghc CompileCWithGhc) ? arg "-optc-O2" ]
- ------------------------------ bytestring ------------------------------
- , package bytestring ?
- builder (Cabal Flags) ? intLib == integerSimple ? arg "integer-simple"
-
--------------------------------- cabal --------------------------------
-- Cabal is a large library and slow to compile. Moreover, we build it
-- for Stage0 only so we can link ghc-pkg against it, so there is little
@@ -81,10 +76,7 @@ packageArgs = do
[ ghcWithNativeCodeGen ? arg "ncg"
, ghcWithInterpreter ? notStage0 ? arg "ghci"
, cross ? arg "-terminfo"
- , notStage0 ? intLib == integerGmp ?
- arg "integer-gmp"
- , notStage0 ? intLib == integerSimple ?
- arg "integer-simple" ]
+ ]
, builder (Haddock BuildPackage) ? arg ("--optghc=-I" ++ path) ]
@@ -193,8 +185,8 @@ packageArgs = do
, package hsc2hs ?
builder (Cabal Flags) ? arg "in-ghc-tree"
- ------------------------------ integerGmp ------------------------------
- , gmpPackageArgs
+ ------------------------------ ghc-bignum ------------------------------
+ , ghcBignumArgs
---------------------------------- rts ---------------------------------
, package rts ? rtsPackageArgs -- RTS deserves a separate function
@@ -203,40 +195,50 @@ packageArgs = do
, package runGhc ?
builder Ghc ? input "**/Main.hs" ?
(\version -> ["-cpp", "-DVERSION=" ++ show version]) <$> getSetting ProjectVersion
+ ]
- --------------------------------- text ---------------------------------
- -- The package @text@ is rather tricky. It's a boot library, and it
- -- tries to determine on its own if it should link against @integer-gmp@
- -- or @integer-simple@. For Stage0, we need to use the integer library
- -- that the bootstrap compiler has (since @interger@ is not a boot
- -- library) and therefore we copy it over into the Stage0 package-db.
- -- Maybe we should stop doing this? And subsequently @text@ for Stage1
- -- detects the same integer library again, even though we don't build it
- -- in Stage1, and at that point the configuration is just wrong.
- , package text ?
- builder (Cabal Flags) ? notStage0 ? intLib == integerSimple ?
- pure ["+integer-simple", "-bytestring-builder"] ]
-
-gmpPackageArgs :: Args
-gmpPackageArgs = do
- package integerGmp ? do
- -- These are only used for non-in-tree builds.
- librariesGmp <- getSetting GmpLibDir
- includesGmp <- getSetting GmpIncludeDir
-
- mconcat
- [ builder (Cabal Setup) ? mconcat
- [ flag GmpInTree ? arg "--configure-option=--with-intree-gmp"
- , flag GmpFrameworkPref ?
- arg "--configure-option=--with-gmp-framework-preferred"
-
- -- Ensure that the integer-gmp package registration includes
- -- knowledge of the system gmp's library and include directories.
- , notM (flag GmpInTree) ? mconcat
- [ if not (null librariesGmp) then arg ("--extra-lib-dirs=" ++ librariesGmp) else mempty
- , if not (null includesGmp) then arg ("--extra-include-dirs=" ++ includesGmp) else mempty
- ]
- ]
+ghcBignumArgs :: Args
+ghcBignumArgs = package ghcBignum ? do
+ -- These are only used for non-in-tree builds.
+ librariesGmp <- getSetting GmpLibDir
+ includesGmp <- getSetting GmpIncludeDir
+
+ backend <- getBignumBackend
+ check <- getBignumCheck
+
+ mconcat
+ [ -- select BigNum backend
+ builder (Cabal Flags) ? arg backend
+
+ , -- check the selected backend against native backend
+ builder (Cabal Flags) ? check ? arg "check"
+
+ -- backend specific
+ , case backend of
+ "gmp" -> mconcat
+ [ builder (Cabal Setup) ? mconcat
+
+ -- enable GMP backend: configure script will produce
+ -- `ghc-bignum.buildinfo` and `include/HsIntegerGmp.h`
+ [ arg "--configure-option=--with-gmp"
+
+ -- enable in-tree support: don't depend on external "gmp"
+ -- library
+ , flag GmpInTree ? arg "--configure-option=--with-intree-gmp"
+
+ -- prefer framework over library (on Darwin)
+ , flag GmpFrameworkPref ?
+ arg "--configure-option=--with-gmp-framework-preferred"
+
+ -- Ensure that the ghc-bignum package registration includes
+ -- knowledge of the system gmp's library and include directories.
+ , notM (flag GmpInTree) ? mconcat
+ [ if not (null librariesGmp) then arg ("--extra-lib-dirs=" ++ librariesGmp) else mempty
+ , if not (null includesGmp) then arg ("--extra-include-dirs=" ++ includesGmp) else mempty
+ ]
+ ]
+ ]
+ _ -> mempty
]
-- | RTS-specific command line arguments.
diff --git a/hadrian/src/Settings/Warnings.hs b/hadrian/src/Settings/Warnings.hs
index 5999822e71..717443ca19 100644
--- a/hadrian/src/Settings/Warnings.hs
+++ b/hadrian/src/Settings/Warnings.hs
@@ -3,7 +3,6 @@ module Settings.Warnings (defaultGhcWarningsArgs, ghcWarningsArgs) where
import Expression
import Oracles.Flag
import Packages
-import Settings
-- See @mk/warnings.mk@ for warning-related arguments in the Make build system.
@@ -17,7 +16,6 @@ defaultGhcWarningsArgs = mconcat
-- | Package-specific warnings-related arguments, mostly suppressing various warnings.
ghcWarningsArgs :: Args
ghcWarningsArgs = do
- isIntegerSimple <- (== integerSimple) <$> getIntegerPackage
mconcat
[ stage0 ? mconcat
[ libraryPackage ? pure [ "-fno-warn-deprecated-flags" ]
@@ -47,8 +45,6 @@ ghcWarningsArgs = do
, "-Wno-deprecations" ]
, package rts ? pure [ "-Wcpp-undef" ]
, package terminfo ? pure [ "-Wno-unused-imports" ]
- , isIntegerSimple ?
- package text ? pure [ "-Wno-unused-imports" ]
, package transformers ? pure [ "-Wno-unused-matches"
, "-Wno-unused-imports"
, "-Wno-redundant-constraints"