diff options
Diffstat (limited to 'hadrian/src/Settings/Builders')
-rw-r--r-- | hadrian/src/Settings/Builders/Cabal.hs | 12 | ||||
-rw-r--r-- | hadrian/src/Settings/Builders/Common.hs | 5 | ||||
-rw-r--r-- | hadrian/src/Settings/Builders/DeriveConstants.hs | 25 | ||||
-rw-r--r-- | hadrian/src/Settings/Builders/Ghc.hs | 10 | ||||
-rw-r--r-- | hadrian/src/Settings/Builders/HsCpp.hs | 4 |
5 files changed, 35 insertions, 21 deletions
diff --git a/hadrian/src/Settings/Builders/Cabal.hs b/hadrian/src/Settings/Builders/Cabal.hs index 96f67b4abf..763f51636b 100644 --- a/hadrian/src/Settings/Builders/Cabal.hs +++ b/hadrian/src/Settings/Builders/Cabal.hs @@ -99,15 +99,16 @@ libraryArgs = do configureArgs :: Args configureArgs = do top <- expr topDirectory - root <- getBuildRoot pkg <- getPackage + stage <- getStage + libPath <- expr $ stageLibPath stage let conf key expr = do values <- unwords <$> expr not (null values) ? arg ("--configure-option=" ++ key ++ "=" ++ values) cFlags = mconcat [ remove ["-Werror"] cArgs , getStagedSettingList ConfCcArgs - , arg $ "-I" ++ top -/- root -/- generatedDir + , arg $ "-I" ++ libPath -- See https://github.com/snowleopard/hadrian/issues/523 , arg $ "-iquote" , arg $ top -/- pkgPath pkg @@ -127,7 +128,7 @@ configureArgs = do , conf "--with-curses-libraries" $ arg =<< getSetting CursesLibDir , flag CrossCompiling ? (conf "--host" $ arg =<< getSetting TargetPlatformFull) , conf "--with-cc" $ arg =<< getBuilderPath . (Cc CompileC) =<< getStage - , notStage0 ? (arg =<< ("--ghc-option=-ghcversion-file=" ++) <$> expr ((-/-) <$> topDirectory <*> ghcVersionH))] + , notStage0 ? (arg =<< ("--ghc-option=-ghcversion-file=" ++) <$> expr ((-/-) <$> topDirectory <*> ghcVersionH stage))] bootPackageConstraints :: Args bootPackageConstraints = stage0 ? do @@ -140,8 +141,9 @@ bootPackageConstraints = stage0 ? do cppArgs :: Args cppArgs = do - root <- getBuildRoot - arg $ "-I" ++ root -/- generatedDir + stage <- getStage + libPath <- expr $ stageLibPath stage + arg $ "-I" ++ libPath withBuilderKey :: Builder -> String withBuilderKey b = case b of diff --git a/hadrian/src/Settings/Builders/Common.hs b/hadrian/src/Settings/Builders/Common.hs index 5856935fb9..7d9e0fe716 100644 --- a/hadrian/src/Settings/Builders/Common.hs +++ b/hadrian/src/Settings/Builders/Common.hs @@ -22,15 +22,16 @@ import UserSettings cIncludeArgs :: Args cIncludeArgs = do pkg <- getPackage - root <- getBuildRoot path <- getBuildPath incDirs <- getContextData includeDirs depDirs <- getContextData depIncludeDirs + stage <- getStage iconvIncludeDir <- getSetting IconvIncludeDir gmpIncludeDir <- getSetting GmpIncludeDir ffiIncludeDir <- getSetting FfiIncludeDir + libPath <- expr $ stageLibPath stage mconcat [ notStage0 ||^ package compiler ? arg "-Iincludes" - , arg $ "-I" ++ root -/- generatedDir + , arg $ "-I" ++ libPath , arg $ "-I" ++ path , pure . map ("-I"++) . filter (/= "") $ [iconvIncludeDir, gmpIncludeDir] , flag UseSystemFfi ? arg ("-I" ++ ffiIncludeDir) diff --git a/hadrian/src/Settings/Builders/DeriveConstants.hs b/hadrian/src/Settings/Builders/DeriveConstants.hs index 90068b3c4a..0747162f43 100644 --- a/hadrian/src/Settings/Builders/DeriveConstants.hs +++ b/hadrian/src/Settings/Builders/DeriveConstants.hs @@ -1,8 +1,19 @@ -module Settings.Builders.DeriveConstants (deriveConstantsBuilderArgs) where +module Settings.Builders.DeriveConstants ( + deriveConstantsBuilderArgs, deriveConstantsPairs + ) where import Builder import Settings.Builders.Common +deriveConstantsPairs :: [(String, String)] +deriveConstantsPairs = + [ ("DerivedConstants.h", "--gen-header") + , ("GHCConstantsHaskellType.hs", "--gen-haskell-type") + , ("platformConstants", "--gen-haskell-value") + , ("GHCConstantsHaskellWrappers.hs", "--gen-haskell-wrappers") + , ("GHCConstantsHaskellExports.hs", "--gen-haskell-exports") + ] + -- TODO: do we need to support `includes_CC_OPTS += -DDYNAMIC_BY_DEFAULT`? deriveConstantsBuilderArgs :: Args deriveConstantsBuilderArgs = builder DeriveConstants ? do @@ -12,11 +23,8 @@ deriveConstantsBuilderArgs = builder DeriveConstants ? do [a, b] -> (a, b) _ -> error $ "DeriveConstants: expected two outputs, got " ++ show outs mconcat - [ output "**/DerivedConstants.h" ? arg "--gen-header" - , output "**/GHCConstantsHaskellType.hs" ? arg "--gen-haskell-type" - , output "**/platformConstants" ? arg "--gen-haskell-value" - , output "**/GHCConstantsHaskellWrappers.hs" ? arg "--gen-haskell-wrappers" - , output "**/GHCConstantsHaskellExports.hs" ? arg "--gen-haskell-exports" + [ mconcat $ flip fmap deriveConstantsPairs $ \(fileName, flag) -> + output ("**/" ++ fileName) ? arg flag , arg "-o", arg outputFile , arg "--tmpdir", arg tempDir , arg "--gcc-program", arg =<< getBuilderPath (Cc CompileC Stage1) @@ -28,13 +36,14 @@ deriveConstantsBuilderArgs = builder DeriveConstants ? do includeCcArgs :: Args includeCcArgs = do - root <- getBuildRoot + stage <- getStage + libPath <- expr $ stageLibPath stage mconcat [ cArgs , cWarnings , getSettingList $ ConfCcArgs Stage1 , flag GhcUnregisterised ? arg "-DUSE_MINIINTERPRETER" , arg "-Irts" , arg "-Iincludes" - , arg $ "-I" ++ root -/- generatedDir + , arg $ "-I" ++ libPath , notM ghcWithSMP ? arg "-DNOSMP" , arg "-fcommon" ] diff --git a/hadrian/src/Settings/Builders/Ghc.hs b/hadrian/src/Settings/Builders/Ghc.hs index 2db62aa4e1..54315484c1 100644 --- a/hadrian/src/Settings/Builders/Ghc.hs +++ b/hadrian/src/Settings/Builders/Ghc.hs @@ -161,7 +161,8 @@ commonGhcArgs :: Args commonGhcArgs = do way <- getWay path <- getBuildPath - ghcVersion <- expr ghcVersionH + stage <- getStage + ghcVersion <- expr $ ghcVersionH stage mconcat [ arg "-hisuf", arg $ hisuf way , arg "-osuf" , arg $ osuf way , arg "-hcsuf", arg $ hcsuf way @@ -208,10 +209,11 @@ includeGhcArgs :: Args includeGhcArgs = do pkg <- getPackage path <- getBuildPath - root <- getBuildRoot context <- getContext srcDirs <- getContextData srcDirs autogen <- expr $ autogenPath context + stage <- getStage + libPath <- expr $ stageLibPath stage let cabalMacros = autogen -/- "cabal_macros.h" expr $ need [cabalMacros] mconcat [ arg "-i" @@ -219,6 +221,6 @@ includeGhcArgs = do , arg $ "-i" ++ autogen , pure [ "-i" ++ pkgPath pkg -/- dir | dir <- srcDirs ] , cIncludeArgs - , arg $ "-I" ++ root -/- generatedDir - , arg $ "-optc-I" ++ root -/- generatedDir + , arg $ "-I" ++ libPath + , arg $ "-optc-I" ++ libPath , pure ["-optP-include", "-optP" ++ cabalMacros] ] diff --git a/hadrian/src/Settings/Builders/HsCpp.hs b/hadrian/src/Settings/Builders/HsCpp.hs index e33061c9d0..4595e2098e 100644 --- a/hadrian/src/Settings/Builders/HsCpp.hs +++ b/hadrian/src/Settings/Builders/HsCpp.hs @@ -6,12 +6,12 @@ import Settings.Builders.Common hsCppBuilderArgs :: Args hsCppBuilderArgs = builder HsCpp ? do stage <- getStage - root <- getBuildRoot ghcPath <- expr $ buildPath (vanillaContext stage compiler) + libPath <- expr $ stageLibPath stage mconcat [ getSettingList HsCppArgs , arg "-P" , arg "-Iincludes" - , arg $ "-I" ++ root -/- generatedDir + , arg $ "-I" ++ libPath , arg $ "-I" ++ ghcPath , arg "-x", arg "c" , arg =<< getInput ] |