[commit: ghc] wip/nfs-locking: Implement appendCcArgs abstraction for passing arguments both to Gcc and GhcCabal. (ac4dab0)

git at git.haskell.org git at git.haskell.org
Thu Oct 26 23:11:44 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/nfs-locking
Link       : http://ghc.haskell.org/trac/ghc/changeset/ac4dab040a3eaeae26ed20198fce5fa00b0dda30/ghc

>---------------------------------------------------------------

commit ac4dab040a3eaeae26ed20198fce5fa00b0dda30
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Mon Jun 15 01:47:05 2015 +0100

    Implement appendCcArgs abstraction for passing arguments both to Gcc and GhcCabal.


>---------------------------------------------------------------

ac4dab040a3eaeae26ed20198fce5fa00b0dda30
 src/Settings/GhcCabal.hs | 12 +++++-------
 src/Settings/Util.hs     |  8 ++++++++
 src/Switches.hs          |  5 ++++-
 src/Targets.hs           | 16 +++++++++++-----
 4 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/src/Settings/GhcCabal.hs b/src/Settings/GhcCabal.hs
index db972ac..21ca0e0 100644
--- a/src/Settings/GhcCabal.hs
+++ b/src/Settings/GhcCabal.hs
@@ -58,13 +58,13 @@ librarySettings = do
 
 configureSettings :: Settings
 configureSettings = do
+    stage <- asks getStage
     let conf key = appendSubD $ "--configure-option=" ++ key
         cFlags   = mconcat [ ccSettings
                            , remove ["-Werror"]
                            , argStagedConfig "conf-cc-args" ]
         ldFlags  = ldSettings <> argStagedConfig "conf-gcc-linker-args"
         cppFlags = cppSettings <> argStagedConfig "conf-cpp-args"
-    stage <- asks getStage
     mconcat
         [ conf "CFLAGS"   cFlags
         , conf "LDFLAGS"  ldFlags
@@ -86,6 +86,7 @@ bootPackageDbSettings = do
 dllSettings :: Settings
 dllSettings = arg ""
 
+-- TODO: remove
 with' :: Builder -> Settings
 with' builder = appendM $ with builder
 
@@ -104,19 +105,16 @@ packageConstraints = do
                             ++ cabal ++ "'."
     args $ concatMap (\c -> ["--constraint", c]) $ constraints
 
+-- TODO: remove
 ccSettings :: Settings
-ccSettings = do
+ccSettings = validating ? do
     let gccGe46 = liftM not gccLt46
-    mconcat
-        [ package integerLibrary ? arg "-Ilibraries/integer-gmp2/gmp"
-        , validating ? mconcat
-            [ arg "-Werror"
+    mconcat [ arg "-Werror"
             , arg "-Wall"
             , gccIsClang ??
               ( arg "-Wno-unknown-pragmas" <>
                 gccGe46 ? windowsHost ? arg "-Werror=unused-but-set-variable"
               , gccGe46 ? arg "-Wno-error=inline" )]
-        ]
 
 ldSettings :: Settings
 ldSettings = mempty
diff --git a/src/Settings/Util.hs b/src/Settings/Util.hs
index dbd07c0..f73f0f7 100644
--- a/src/Settings/Util.hs
+++ b/src/Settings/Util.hs
@@ -4,6 +4,7 @@ module Settings.Util (
     -- Primitive settings elements
     arg, argM, args,
     argConfig, argStagedConfig, argConfigList, argStagedConfigList,
+    appendCcArgs,
     -- argBuilderPath, argStagedBuilderPath,
     -- argPackageKey, argPackageDeps, argPackageDepKeys, argSrcDirs,
     -- argIncludeDirs, argDepIncludeDirs,
@@ -46,6 +47,13 @@ argStagedConfigList key = do
     stage <- asks getStage
     argConfigList (stagedKey stage key)
 
+appendCcArgs :: [String] -> Settings
+appendCcArgs args = do
+    stage <- asks getStage
+    mconcat [ builder (Gcc stage) ? append args
+            , builder GhcCabal ? appendSub "--configure-option=CFLAGS" args
+            , builder GhcCabal ? appendSub "--gcc-options" args ]
+
 -- packageData :: Arity -> String -> Settings
 -- packageData arity key =
 --     return $ EnvironmentParameter $ PackageData arity key Nothing Nothing
diff --git a/src/Switches.hs b/src/Switches.hs
index b67d9fc..0433682 100644
--- a/src/Switches.hs
+++ b/src/Switches.hs
@@ -1,6 +1,6 @@
 module Switches (
     IntegerLibraryImpl (..), integerLibraryImpl,
-    notStage, stage0, stage1, stage2, notBuilder,
+    notStage, stage0, stage1, stage2, builders, notBuilder,
     supportsPackageKey, targetPlatforms, targetPlatform,
     targetOss, targetOs, notTargetOs,
     targetArchs, dynamicGhcPrograms, ghcWithInterpreter,
@@ -31,6 +31,9 @@ stage1 = stage Stage1
 stage2 :: Predicate
 stage2 = stage Stage2
 
+builders :: [Builder] -> Predicate
+builders = liftM or . sequence . map builder
+
 notBuilder :: Builder -> Predicate
 notBuilder = liftM not . builder
 
diff --git a/src/Targets.hs b/src/Targets.hs
index c8aeb22..1839112 100644
--- a/src/Targets.hs
+++ b/src/Targets.hs
@@ -12,6 +12,7 @@ import Base hiding (arg, args)
 import Package
 import Switches
 import Expression
+import Settings.Util
 import Oracles.Builder
 
 -- Build results will be placed into a target directory with the following
@@ -80,13 +81,18 @@ integerLibraryCabal = case integerLibraryImpl of
     IntegerGmp2   -> "integer-gmp.cabal" -- Indeed, why make life easier?
     IntegerSimple -> "integer-simple.cabal"
 
--- Custom package settings for packages
 customPackageSettings :: Settings
-customPackageSettings = builder GhcCabal ? mconcat
+customPackageSettings = mconcat
     [ package integerLibrary ?
-      windowsHost     ? append ["--configure-option=--with-intree-gmp"]
-    , package base    ? append ["--flags=" ++ integerLibraryName]
-    , package ghcPrim ? append ["--flag=include-ghc-prim"] ]
+      mconcat [ windowsHost ? builder GhcCabal ?
+                append ["--configure-option=--with-intree-gmp"]
+              , appendCcArgs ["-Ilibraries/integer-gmp2/gmp"] ]
+
+    , package base ?
+      builder GhcCabal ? append ["--flags=" ++ integerLibraryName]
+
+    , package ghcPrim ?
+      builder GhcCabal ? append ["--flag=include-ghc-prim"] ]
 
 -- Note [Cabal name weirdness]
 -- Find out if we can move the contents to just Cabal/



More information about the ghc-commits mailing list