diff options
Diffstat (limited to 'hadrian')
-rw-r--r-- | hadrian/cfg/system.config.in | 27 | ||||
-rw-r--r-- | hadrian/src/Oracles/Flag.hs | 24 | ||||
-rw-r--r-- | hadrian/src/Oracles/Setting.hs | 2 | ||||
-rw-r--r-- | hadrian/src/Rules.hs | 1 | ||||
-rw-r--r-- | hadrian/src/Rules/Generate.hs | 71 | ||||
-rw-r--r-- | hadrian/src/Settings/Packages.hs | 4 |
6 files changed, 109 insertions, 20 deletions
diff --git a/hadrian/cfg/system.config.in b/hadrian/cfg/system.config.in index 0541d90138..78f66df02f 100644 --- a/hadrian/cfg/system.config.in +++ b/hadrian/cfg/system.config.in @@ -90,13 +90,14 @@ ghc-patch-level = @GhcPatchLevel@ bootstrap-threaded-rts = @GhcThreadedRts@ -project-name = @ProjectName@ -project-version = @ProjectVersion@ -project-version-int = @ProjectVersionInt@ -project-patch-level = @ProjectPatchLevel@ -project-patch-level1 = @ProjectPatchLevel1@ -project-patch-level2 = @ProjectPatchLevel2@ -project-git-commit-id = @ProjectGitCommitId@ +project-name = @ProjectName@ +project-version = @ProjectVersion@ +project-version-munged = @ProjectVersionMunged@ +project-version-int = @ProjectVersionInt@ +project-patch-level = @ProjectPatchLevel@ +project-patch-level1 = @ProjectPatchLevel1@ +project-patch-level2 = @ProjectPatchLevel2@ +project-git-commit-id = @ProjectGitCommitId@ # Compilation and linking flags: #=============================== @@ -201,6 +202,12 @@ libnuma-lib-dir = @LibNumaLibDir@ # Optional Dependencies: #======================= -with-libdw = @UseLibdw@ -with-libnuma = @UseLibNuma@ -have-lib-mingw-ex = @HaveLibMingwEx@ +use-lib-dw = @UseLibdw@ +use-lib-numa = @UseLibNuma@ +use-lib-mingw-ex = @HaveLibMingwEx@ +use-lib-m = @UseLibm@ +use-lib-rt = @UseLibrt@ +use-lib-dl = @UseLibdl@ +use-lib-bfd = @UseLibbfd@ +use-lib-pthread = @UseLibpthread@ +need-libatomic = @NeedLibatomic@ diff --git a/hadrian/src/Oracles/Flag.hs b/hadrian/src/Oracles/Flag.hs index 37f675b5e8..a929b77e68 100644 --- a/hadrian/src/Oracles/Flag.hs +++ b/hadrian/src/Oracles/Flag.hs @@ -27,13 +27,19 @@ data Flag = ArSupportsAtFile | GmpFrameworkPref | LeadingUnderscore | SolarisBrokenShld - | WithLibdw - | WithLibnuma - | HaveLibMingwEx | UseSystemFfi | BootstrapThreadedRts | BootstrapEventLoggingRts | UseLibffiForAdjustors + | UseLibdw + | UseLibnuma + | UseLibmingwex + | UseLibm + | UseLibrt + | UseLibdl + | UseLibbfd + | UseLibpthread + | NeedLibatomic -- Note, if a flag is set to empty string we treat it as set to NO. This seems -- fragile, but some flags do behave like this. @@ -51,13 +57,19 @@ flag f = do GmpFrameworkPref -> "gmp-framework-preferred" LeadingUnderscore -> "leading-underscore" SolarisBrokenShld -> "solaris-broken-shld" - WithLibdw -> "with-libdw" - WithLibnuma -> "with-libnuma" - HaveLibMingwEx -> "have-lib-mingw-ex" UseSystemFfi -> "use-system-ffi" BootstrapThreadedRts -> "bootstrap-threaded-rts" BootstrapEventLoggingRts -> "bootstrap-event-logging-rts" UseLibffiForAdjustors -> "use-libffi-for-adjustors" + UseLibdw -> "use-lib-dw" + UseLibnuma -> "use-lib-numa" + UseLibmingwex -> "use-lib-mingw-ex" + UseLibm -> "use-lib-m" + UseLibrt -> "use-lib-rt" + UseLibdl -> "use-lib-dl" + UseLibbfd -> "use-lib-bfd" + UseLibpthread -> "use-lib-pthread" + NeedLibatomic -> "need-libatomic" value <- lookupSystemConfig key when (value `notElem` ["YES", "NO", ""]) . error $ "Configuration flag " ++ quote (key ++ " = " ++ value) ++ " cannot be parsed." diff --git a/hadrian/src/Oracles/Setting.hs b/hadrian/src/Oracles/Setting.hs index dca0861869..28926c7763 100644 --- a/hadrian/src/Oracles/Setting.hs +++ b/hadrian/src/Oracles/Setting.hs @@ -65,6 +65,7 @@ data Setting = BuildArch | ProjectName | ProjectVersion | ProjectVersionInt + | ProjectVersionMunged | ProjectPatchLevel | ProjectPatchLevel1 | ProjectPatchLevel2 @@ -165,6 +166,7 @@ setting key = lookupSystemConfig $ case key of ProjectGitCommitId -> "project-git-commit-id" ProjectName -> "project-name" ProjectVersion -> "project-version" + ProjectVersionMunged -> "project-version-munged" ProjectVersionInt -> "project-version-int" ProjectPatchLevel -> "project-patch-level" ProjectPatchLevel1 -> "project-patch-level1" diff --git a/hadrian/src/Rules.hs b/hadrian/src/Rules.hs index 8c65f471a7..7cfeb65e5a 100644 --- a/hadrian/src/Rules.hs +++ b/hadrian/src/Rules.hs @@ -130,6 +130,7 @@ buildRules = do Rules.BinaryDist.bindistRules Rules.Generate.copyRules Rules.Generate.generateRules + Rules.Generate.templateRules Rules.Gmp.gmpRules Rules.Libffi.libffiRules Rules.Library.libraryRules diff --git a/hadrian/src/Rules/Generate.hs b/hadrian/src/Rules/Generate.hs index c41b6eed8f..a44ca510d2 100644 --- a/hadrian/src/Rules/Generate.hs +++ b/hadrian/src/Rules/Generate.hs @@ -1,7 +1,8 @@ module Rules.Generate ( isGeneratedCmmFile, compilerDependencies, generatePackageCode, generateRules, copyRules, generatedDependencies, - ghcPrimDependencies + ghcPrimDependencies, + templateRules ) where import qualified Data.Set as Set @@ -225,6 +226,72 @@ emptyTarget :: Context emptyTarget = vanillaContext (error "Rules.Generate.emptyTarget: unknown stage") (error "Rules.Generate.emptyTarget: unknown package") +-- | Files generated by query-replace from a template +templateResults :: [FilePath] +templateResults = + [ "compiler/ghc.cabal" + , "rts/rts.cabal" + , "driver/ghci/ghci-wrapper.cabal" + , "ghc/ghc-bin.cabal" + , "utils/iserv/iserv.cabal" + , "utils/iserv-proxy/iserv-proxy.cabal" + , "utils/remote-iserv/remote-iserv.cabal" + , "utils/runghc/runghc.cabal" + , "libraries/ghc-boot/ghc-boot.cabal" + , "libraries/ghc-boot-th/ghc-boot-th.cabal" + , "libraries/ghci/ghci.cabal" + , "libraries/ghc-heap/ghc-heap.cabal" + , "utils/ghc-pkg/ghc-pkg.cabal" + , "libraries/libiserv/libiserv.cabal" + , "libraries/template-haskell/template-haskell.cabal" + , "libraries/prologue.txt" + ] + +templateRules :: Rules () +templateRules = do + templateResults |%> \out -> do + let settingWord :: Setting -> Action Word + settingWord s = read <$> setting s + + project_version <- setting ProjectVersion + project_version_munged <- setting ProjectVersionMunged + target_word_size <- settingWord TargetWordSize + lib_dw <- flag UseLibdw + lib_numa <- flag UseLibnuma + lib_mingwex <- flag UseLibmingwex + lib_m <- flag UseLibm + lib_rt <- flag UseLibrt + lib_dl <- flag UseLibdl + lib_ffi <- flag UseSystemFfi + lib_ffi_adjustors <- flag UseLibffiForAdjustors + lib_bfd <- flag UseLibbfd + lib_pthread <- flag UseLibpthread + leading_underscore <- flag LeadingUnderscore + need_libatomic <- flag NeedLibatomic + + let cabal_bool True = "True" + cabal_bool False = "False" + + subst = replace "@ProjectVersion@" project_version + . replace "@ProjectVersionMunged@" project_version_munged + . replace "@Cabal64bit@" (cabal_bool (target_word_size == 8)) + . replace "@CabalMingwex@" (cabal_bool lib_mingwex) + . replace "@CabalHaveLibdw@" (cabal_bool lib_dw) + . replace "@CabalHaveLibm@" (cabal_bool lib_m) + . replace "@CabalHaveLibrt@" (cabal_bool lib_rt) + . replace "@CabalHaveLibdl@" (cabal_bool lib_dl) + . replace "@CabalUseSystemLibFFI@" (cabal_bool lib_ffi) + . replace "@CabalLibffiAdjustors@" (cabal_bool lib_ffi_adjustors) + . replace "@CabalNeedLibpthread@" (cabal_bool lib_pthread) + . replace "@CabalHaveLibbfd@" (cabal_bool lib_bfd) + . replace "@CabalHaveLibNuma@" (cabal_bool lib_numa) + . replace "@CabalLeadingUnderscore@" (cabal_bool leading_underscore) + . replace "@CabalNeedLibatomic@" (cabal_bool need_libatomic) + + s <- readFile' (out <.> "in") + writeFile' out (subst s) + putSuccess ("| Successfully generated " ++ out ++ " from its template") + -- Generators -- | GHC wrapper scripts used for passing the path to the right package database @@ -353,7 +420,7 @@ generateSettings = do , ("Tables next to code", expr $ yesNo <$> flag TablesNextToCode) , ("Leading underscore", expr $ yesNo <$> flag LeadingUnderscore) , ("Use LibFFI", expr $ yesNo <$> useLibffiForAdjustors) - , ("RTS expects libdw", yesNo <$> getFlag WithLibdw) + , ("RTS expects libdw", yesNo <$> getFlag UseLibdw) ] let showTuple (k, v) = "(" ++ show k ++ ", " ++ show v ++ ")" pure $ case settings of diff --git a/hadrian/src/Settings/Packages.hs b/hadrian/src/Settings/Packages.hs index b6ba1e94ff..e99e639eb8 100644 --- a/hadrian/src/Settings/Packages.hs +++ b/hadrian/src/Settings/Packages.hs @@ -403,8 +403,8 @@ rtsPackageArgs = package rts ? do , builder HsCpp ? pure [ "-DTOP=" ++ show top ] - , builder HsCpp ? flag WithLibdw ? arg "-DUSE_LIBDW" - , builder HsCpp ? flag HaveLibMingwEx ? arg "-DHAVE_LIBMINGWEX" ] + , builder HsCpp ? flag UseLibdw ? arg "-DUSE_LIBDW" + , builder HsCpp ? flag UseLibmingwex ? arg "-DHAVE_LIBMINGWEX" ] -- Compile various performance-critical pieces *without* -fPIC -dynamic -- even when building a shared library. If we don't do this, then the |