Commit dceecb09 authored by Sylvain Henry's avatar Sylvain Henry Committed by Ben Gamari

Update Hadrian

* support ghc-bignum backend selection in flavours and command-line

* support ghc-bignum "--check" flag (compare results of selected backend
  against results of the native one) in flavours and command-line (e.g.
  pass --bignum=check-gmp" to check the "gmp" backend)

* remove the hack to workaround #15286

* build GMP only when the gmp backend is used

* remove hacks to workaround `text` package flags about integer-*. We
  fix `text` to use ghc-bignum unconditionally in another patch
parent f817d816
......@@ -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
......
......@@ -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
......
......@@ -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
......
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
......
......@@ -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.
......
......@@ -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"
......
......@@ -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)
......
......@@ -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"
......
......@@ -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'.
......
......@@ -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
......
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]
......
......@@ -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
......
......@@ -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
......
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
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"]
]
......@@ -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
......
......@@ -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"]
......
......@@ -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"
......
......@@ -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"
......
......@@ -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"
......
......@@ -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.
......
......@@ -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"
......
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