[Git][ghc/ghc][wip/romes/hardwire-ghc-unit-id] 3 commits: fixes
Rodrigo Mesquita (@alt-romes)
gitlab at gitlab.haskell.org
Mon Apr 3 16:39:41 UTC 2023
Rodrigo Mesquita pushed to branch wip/romes/hardwire-ghc-unit-id at Glasgow Haskell Compiler / GHC
Commits:
94015f4b by Matthew Pickering at 2023-04-03T17:39:19+01:00
fixes
- - - - -
29d874e9 by Matthew Pickering at 2023-04-03T17:39:24+01:00
add flag
- - - - -
c689e100 by Matthew Pickering at 2023-04-03T17:39:24+01:00
Use hash-unit-ids in release jobs
- - - - -
21 changed files:
- .gitlab/gen_ci.hs
- .gitlab/jobs.yaml
- hadrian/src/CommandLine.hs
- hadrian/src/Flavour.hs
- hadrian/src/Flavour/Type.hs
- hadrian/src/Hadrian/Builder/Git.hs
- hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
- hadrian/src/Hadrian/Haskell/Hash.hs
- hadrian/src/Settings.hs
- hadrian/src/Settings/Builders/Ghc.hs
- hadrian/src/Settings/Default.hs
- hadrian/src/Settings/Default.hs-boot
- hadrian/src/Settings/Flavours/Benchmark.hs
- hadrian/src/Settings/Flavours/Development.hs
- hadrian/src/Settings/Flavours/GhcInGhci.hs
- hadrian/src/Settings/Flavours/Performance.hs
- hadrian/src/Settings/Flavours/Quick.hs
- hadrian/src/Settings/Flavours/QuickCross.hs
- hadrian/src/Settings/Flavours/Quickest.hs
- hadrian/src/Settings/Flavours/Validate.hs
- utils/ghc-pkg/Main.hs
Changes:
=====================================
.gitlab/gen_ci.hs
=====================================
@@ -760,7 +760,7 @@ nightly arch opsys bc =
release :: Arch -> Opsys -> BuildConfig -> NamedJob Job
release arch opsys bc =
let NamedJob n j = job arch opsys (bc { buildFlavour = Release })
- in NamedJob { name = "release-" ++ n, jobInfo = addJobRule ReleaseOnly . keepArtifacts "1 year" . ignorePerfFailures . highCompression $ j}
+ in NamedJob { name = "release-" ++ n, jobInfo = addJobRule ReleaseOnly . keepArtifacts "1 year" . ignorePerfFailures . useHashUnitIds . highCompression $ j}
-- Specific job modification functions
@@ -785,6 +785,9 @@ ignorePerfFailures = addVariable "IGNORE_PERF_FAILURES" "all"
highCompression :: Job -> Job
highCompression = addVariable "XZ_OPT" "-9"
+useHashUnitIds :: Job -> Job
+useHashUnitIds = addVariable "HADRIAN_ARGS" "--hash-unit-ids"
+
-- | Mark the validate job to run in fast-ci mode
fastCI :: JobGroup Job -> JobGroup Job
fastCI = modifyValidateJobs (addJobRule FastCI)
=====================================
.gitlab/jobs.yaml
=====================================
@@ -2222,7 +2222,7 @@
"BIN_DIST_NAME": "ghc-aarch64-darwin-release",
"BUILD_FLAVOUR": "release",
"CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi ",
- "HADRIAN_ARGS": "--docs=no-sphinx",
+ "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
"IGNORE_PERF_FAILURES": "all",
"LANG": "en_US.UTF-8",
"MACOSX_DEPLOYMENT_TARGET": "11.0",
@@ -2286,6 +2286,7 @@
"BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+no_split_sections",
"BUILD_FLAVOUR": "release+no_split_sections",
"CONFIGURE_ARGS": "",
+ "HADRIAN_ARGS": "--hash-unit-ids",
"IGNORE_PERF_FAILURES": "all",
"TEST_ENV": "aarch64-linux-deb10-release+no_split_sections",
"XZ_OPT": "-9"
@@ -2346,6 +2347,7 @@
"BIN_DIST_NAME": "ghc-i386-linux-deb9-release+no_split_sections",
"BUILD_FLAVOUR": "release+no_split_sections",
"CONFIGURE_ARGS": "",
+ "HADRIAN_ARGS": "--hash-unit-ids",
"IGNORE_PERF_FAILURES": "all",
"TEST_ENV": "i386-linux-deb9-release+no_split_sections",
"XZ_OPT": "-9"
@@ -2406,7 +2408,7 @@
"BIN_DIST_NAME": "ghc-x86_64-darwin-release",
"BUILD_FLAVOUR": "release",
"CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi ",
- "HADRIAN_ARGS": "--docs=no-sphinx",
+ "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
"IGNORE_PERF_FAILURES": "all",
"LANG": "en_US.UTF-8",
"MACOSX_DEPLOYMENT_TARGET": "10.10",
@@ -2473,7 +2475,7 @@
"BROKEN_TESTS": "encoding004 T10458 ghcilink002 linker_unload_native",
"BUILD_FLAVOUR": "release+fully_static",
"CONFIGURE_ARGS": "--disable-ld-override ",
- "HADRIAN_ARGS": "--docs=no-sphinx",
+ "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--disable-ld-override",
"TEST_ENV": "x86_64-linux-alpine3_12-int_native-release+fully_static",
@@ -2536,7 +2538,7 @@
"BROKEN_TESTS": "encoding004 T10458 ghcilink002 linker_unload_native",
"BUILD_FLAVOUR": "release+fully_static+no_split_sections",
"CONFIGURE_ARGS": "--disable-ld-override ",
- "HADRIAN_ARGS": "--docs=no-sphinx",
+ "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--disable-ld-override",
"TEST_ENV": "x86_64-linux-alpine3_12-release+fully_static+no_split_sections",
@@ -2598,7 +2600,7 @@
"BIN_DIST_NAME": "ghc-x86_64-linux-centos7-release+no_split_sections",
"BUILD_FLAVOUR": "release+no_split_sections",
"CONFIGURE_ARGS": "",
- "HADRIAN_ARGS": "--docs=no-sphinx",
+ "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
"IGNORE_PERF_FAILURES": "all",
"TEST_ENV": "x86_64-linux-centos7-release+no_split_sections",
"XZ_OPT": "-9"
@@ -2659,6 +2661,7 @@
"BIN_DIST_NAME": "ghc-x86_64-linux-deb10-release",
"BUILD_FLAVOUR": "release",
"CONFIGURE_ARGS": "",
+ "HADRIAN_ARGS": "--hash-unit-ids",
"IGNORE_PERF_FAILURES": "all",
"TEST_ENV": "x86_64-linux-deb10-release",
"XZ_OPT": "-9"
@@ -2719,6 +2722,7 @@
"BIN_DIST_NAME": "ghc-x86_64-linux-deb10-release+debug_info",
"BUILD_FLAVOUR": "release+debug_info",
"CONFIGURE_ARGS": "",
+ "HADRIAN_ARGS": "--hash-unit-ids",
"IGNORE_PERF_FAILURES": "all",
"TEST_ENV": "x86_64-linux-deb10-release+debug_info",
"XZ_OPT": "-9"
@@ -2779,6 +2783,7 @@
"BIN_DIST_NAME": "ghc-x86_64-linux-deb11-release",
"BUILD_FLAVOUR": "release",
"CONFIGURE_ARGS": "",
+ "HADRIAN_ARGS": "--hash-unit-ids",
"IGNORE_PERF_FAILURES": "all",
"TEST_ENV": "x86_64-linux-deb11-release",
"XZ_OPT": "-9"
@@ -2839,6 +2844,7 @@
"BIN_DIST_NAME": "ghc-x86_64-linux-deb11-release+boot_nonmoving_gc",
"BUILD_FLAVOUR": "release+boot_nonmoving_gc",
"CONFIGURE_ARGS": "",
+ "HADRIAN_ARGS": "--hash-unit-ids",
"IGNORE_PERF_FAILURES": "all",
"RUNTEST_ARGS": "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity",
"TEST_ENV": "x86_64-linux-deb11-release+boot_nonmoving_gc",
@@ -2900,6 +2906,7 @@
"BIN_DIST_NAME": "ghc-x86_64-linux-deb9-release+no_split_sections",
"BUILD_FLAVOUR": "release+no_split_sections",
"CONFIGURE_ARGS": "",
+ "HADRIAN_ARGS": "--hash-unit-ids",
"IGNORE_PERF_FAILURES": "all",
"TEST_ENV": "x86_64-linux-deb9-release+no_split_sections",
"XZ_OPT": "-9"
@@ -2960,6 +2967,7 @@
"BIN_DIST_NAME": "ghc-x86_64-linux-fedora33-release",
"BUILD_FLAVOUR": "release",
"CONFIGURE_ARGS": "",
+ "HADRIAN_ARGS": "--hash-unit-ids",
"IGNORE_PERF_FAILURES": "all",
"LLC": "/bin/false",
"OPT": "/bin/false",
@@ -3022,6 +3030,7 @@
"BIN_DIST_NAME": "ghc-x86_64-linux-fedora33-release+debug_info",
"BUILD_FLAVOUR": "release+debug_info",
"CONFIGURE_ARGS": "",
+ "HADRIAN_ARGS": "--hash-unit-ids",
"IGNORE_PERF_FAILURES": "all",
"LLC": "/bin/false",
"OPT": "/bin/false",
@@ -3084,7 +3093,7 @@
"BIN_DIST_NAME": "ghc-x86_64-linux-fedora33-release",
"BUILD_FLAVOUR": "release",
"CONFIGURE_ARGS": "",
- "HADRIAN_ARGS": "--haddock-base-url",
+ "HADRIAN_ARGS": "--haddock-base-url --hash-unit-ids",
"IGNORE_PERF_FAILURES": "all",
"LLC": "/bin/false",
"OPT": "/bin/false",
@@ -3147,7 +3156,7 @@
"BIN_DIST_NAME": "ghc-x86_64-linux-rocky8-release",
"BUILD_FLAVOUR": "release",
"CONFIGURE_ARGS": "",
- "HADRIAN_ARGS": "--docs=no-sphinx",
+ "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
"IGNORE_PERF_FAILURES": "all",
"TEST_ENV": "x86_64-linux-rocky8-release",
"XZ_OPT": "-9"
@@ -3208,6 +3217,7 @@
"BIN_DIST_NAME": "ghc-x86_64-linux-ubuntu18_04-release",
"BUILD_FLAVOUR": "release",
"CONFIGURE_ARGS": "",
+ "HADRIAN_ARGS": "--hash-unit-ids",
"IGNORE_PERF_FAILURES": "all",
"TEST_ENV": "x86_64-linux-ubuntu18_04-release",
"XZ_OPT": "-9"
@@ -3268,6 +3278,7 @@
"BIN_DIST_NAME": "ghc-x86_64-linux-ubuntu20_04-release",
"BUILD_FLAVOUR": "release",
"CONFIGURE_ARGS": "",
+ "HADRIAN_ARGS": "--hash-unit-ids",
"IGNORE_PERF_FAILURES": "all",
"TEST_ENV": "x86_64-linux-ubuntu20_04-release",
"XZ_OPT": "-9"
@@ -3325,7 +3336,7 @@
"CABAL_INSTALL_VERSION": "3.8.1.0",
"CONFIGURE_ARGS": "",
"GHC_VERSION": "9.4.3",
- "HADRIAN_ARGS": "--docs=no-sphinx",
+ "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
"IGNORE_PERF_FAILURES": "all",
"LANG": "en_US.UTF-8",
"MSYSTEM": "CLANG64",
@@ -3385,7 +3396,7 @@
"CABAL_INSTALL_VERSION": "3.8.1.0",
"CONFIGURE_ARGS": "",
"GHC_VERSION": "9.4.3",
- "HADRIAN_ARGS": "--docs=no-sphinx",
+ "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
"IGNORE_PERF_FAILURES": "all",
"LANG": "en_US.UTF-8",
"MSYSTEM": "CLANG64",
=====================================
hadrian/src/CommandLine.hs
=====================================
@@ -1,7 +1,7 @@
module CommandLine (
optDescrs, cmdLineArgsMap, cmdFlavour, lookupFreeze1, lookupFreeze2, lookupSkipDepends,
cmdBignum, cmdBignumCheck, cmdProgressInfo, cmdCompleteSetting,
- cmdDocsArgs, lookupBuildRoot, TestArgs(..), TestSpeed(..), defaultTestArgs,
+ cmdDocsArgs, cmdUnitIdHash, lookupBuildRoot, TestArgs(..), TestSpeed(..), defaultTestArgs,
cmdPrefix, DocArgs(..), defaultDocArgs
) where
@@ -28,6 +28,7 @@ data CommandLineArgs = CommandLineArgs
, freeze1 :: Bool
, freeze2 :: Bool
, skipDepends :: Bool
+ , unitIdHash :: Bool
, bignum :: Maybe String
, bignumCheck :: Bool
, progressInfo :: ProgressInfo
@@ -47,6 +48,7 @@ defaultCommandLineArgs = CommandLineArgs
, freeze1 = False
, freeze2 = False
, skipDepends = False
+ , unitIdHash = False
, bignum = Nothing
, bignumCheck = False
, progressInfo = Brief
@@ -141,6 +143,9 @@ readFreeze1 = Right $ \flags -> flags { freeze1 = True }
readFreeze2 = Right $ \flags -> flags { freeze1 = True, freeze2 = True }
readSkipDepends = Right $ \flags -> flags { skipDepends = True }
+readUnitIdHash :: Either String (CommandLineArgs -> CommandLineArgs)
+readUnitIdHash = Right $ \flags -> flags { unitIdHash = True }
+
readProgressInfo :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs)
readProgressInfo ms =
maybe (Left "Cannot parse progress-info") (Right . set) (go =<< lower <$> ms)
@@ -289,6 +294,8 @@ optDescrs =
"Freeze Stage1 GHC."
, Option [] ["freeze2"] (NoArg readFreeze2)
"Freeze Stage2 GHC."
+ , Option [] ["hash-unit-ids"] (NoArg readUnitIdHash)
+ "Include package hashes in unit ids."
, Option [] ["skip-depends"] (NoArg readSkipDepends)
"Skip rebuilding dependency information."
, Option [] ["bignum"] (OptArg readBignum "BACKEND")
@@ -400,6 +407,9 @@ lookupFreeze2 = freeze2 . lookupExtra defaultCommandLineArgs
lookupSkipDepends :: Map.HashMap TypeRep Dynamic -> Bool
lookupSkipDepends = skipDepends . lookupExtra defaultCommandLineArgs
+cmdUnitIdHash :: Action Bool
+cmdUnitIdHash = unitIdHash <$> cmdLineArgs
+
cmdBignum :: Action (Maybe String)
cmdBignum = bignum <$> cmdLineArgs
=====================================
hadrian/src/Flavour.hs
=====================================
@@ -112,7 +112,7 @@ parseFlavour baseFlavours transformers str =
-- | Add arguments to the 'args' of a 'Flavour'.
addArgs :: Args -> Flavour -> Flavour
-addArgs args' fl = fl { args = args fl <> args' }
+addArgs args' fl = fl { extraArgs = extraArgs fl <> args' }
-- | Turn on -Werror for packages built with the stage1 compiler.
-- It mimics the CI settings so is useful to turn on when developing.
@@ -468,7 +468,7 @@ applySetting (KeyVal ks op v) = case runSettingsM ks builderPredicate of
Left err -> throwError $
"error while setting `" ++ intercalate "`." ks ++ ": " ++ err
Right pred -> Right $ \flav -> flav
- { args = update (args flav) pred }
+ { extraArgs = update (extraArgs flav) pred }
where override arguments predicate = do
holds <- predicate
=====================================
hadrian/src/Flavour/Type.hs
=====================================
@@ -14,8 +14,8 @@ import Data.Set (Set)
data Flavour = Flavour {
-- | Flavour name, to select this flavour from command line.
name :: String,
- -- | Use these command line arguments.
- args :: Args,
+ -- | Use these extra command line arguments.
+ extraArgs :: Args,
-- | Build these packages.
packages :: Stage -> Action [Package],
-- | Bignum backend: 'native', 'gmp', 'ffi', etc.
=====================================
hadrian/src/Hadrian/Builder/Git.hs
=====================================
@@ -2,12 +2,13 @@ module Hadrian.Builder.Git (gitArgs) where
import Expression
--- | Default command line arguments for invoking the archiving utility @tar at .
+-- | Default command line arguments for invoking the archiving utility @git at .
gitArgs :: Args
gitArgs = mconcat
[ builder (Git ListFiles) ? mconcat
[ arg "ls-files"
, arg "--recurse-submodules"
, arg "-z"
+ , getInputs
]
]
=====================================
hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
=====================================
@@ -63,7 +63,6 @@ import Hadrian.Target
import Base
import Builder
import Context
-import Flavour
import Settings
import Distribution.Simple.LocalBuildInfo
import qualified Distribution.Simple.Register as C
@@ -158,9 +157,8 @@ configurePackage context at Context {..} = do
pure $ if configureExists then C.autoconfUserHooks else C.simpleUserHooks
-- Compute the list of flags, and the Cabal configuration arguments
- flavourArgs <- args <$> flavour
- flagList <- interpret (target context (Cabal Flags stage) [] []) flavourArgs
- argList <- interpret (target context (Cabal Setup stage) [] []) flavourArgs
+ flagList <- interpret (target context (Cabal Flags stage) [] []) getArgs
+ argList <- interpret (target context (Cabal Setup stage) [] []) getArgs
trackArgsHash (target context (Cabal Flags stage) [] [])
trackArgsHash (target context (Cabal Setup stage) [] [])
verbosity <- getVerbosity
=====================================
hadrian/src/Hadrian/Haskell/Hash.hs
=====================================
@@ -14,6 +14,7 @@ import Hadrian.Package
import qualified Crypto.Hash.SHA256 as SHA256
import qualified Data.ByteString.Base16 as Base16
import qualified Data.ByteString.Char8 as BS
+import Data.ByteString as BS (readFile)
import Data.Map (Map)
import qualified Data.Map as Map
import qualified Data.Set as Set
@@ -26,11 +27,15 @@ import Hadrian.Expression
import Builder
import Flavour.Type
import Settings
-import Way.Type
import Way
import Packages
import Development.Shake.Classes
import Control.Monad
+import Utilities
+import Base
+import Context
+import System.Directory.Extra (listFilesRecursive)
+import CommandLine
-- | Read a Cabal file and return the package identifier, e.g. @base-4.10.0.0-abcd at .
@@ -39,7 +44,7 @@ pkgUnitId :: Context -> Package -> Action String
pkgUnitId ctx' pkg = do
let ctx = ctx'{package = pkg}
pid <- pkgSimpleIdentifier (package ctx)
- phash <- pkgHash ctx
+ use_hash <- cmdUnitIdHash
if pkgName pkg == "rts"
-- The unit-id will change depending on the way, we need to treat the rts separately
then pure pid
@@ -48,7 +53,13 @@ pkgUnitId ctx' pkg = do
-- can have hadrian generate a different unit-id for them just as cabal does
-- because the boot packages unit-ids are overriden by setting -this-unit-id
-- in the cabal file
- pure $ pid <> "-" <> truncateHash 4 phash
+ hash <- if use_hash
+ then do
+ phash <- pkgHash ctx
+ return $ truncateHash 4 phash
+ else
+ return "inplace"
+ pure $ pid <> "-" <> hash
where
truncateHash :: Int -> String -> String
@@ -71,31 +82,31 @@ data PackageHashConfigInputs = PackageHashConfigInputs {
pkgHashCompilerId :: String,
pkgHashPlatform :: String,
pkgHashFlagAssignment :: [String], -- complete not partial
- -- pkgHashConfigureScriptArgs :: [String], -- just ./configure for build-type Configure
pkgHashVanillaLib :: Bool,
pkgHashSharedLib :: Bool,
pkgHashDynExe :: Bool,
- pkgHashFullyStaticExe :: Bool,
pkgHashGHCiLib :: Bool,
pkgHashProfLib :: Bool,
pkgHashProfExe :: Bool,
--- pkgHashProfLibDetail :: ProfDetailLevel,
--- pkgHashProfExeDetail :: ProfDetailLevel,
- pkgHashCoverage :: Bool,
- pkgHashOptimization :: Int,
pkgHashSplitObjs :: Bool,
pkgHashSplitSections :: Bool,
pkgHashStripLibs :: Bool,
pkgHashStripExes :: Bool,
--- pkgHashDebugInfo :: DebugInfoLevel,
- pkgHashProgramArgs :: Map String [String],
- pkgHashExtraLibDirs :: [FilePath],
- pkgHashExtraLibDirsStatic :: [FilePath],
- pkgHashExtraFrameworkDirs :: [FilePath],
- pkgHashExtraIncludeDirs :: [FilePath]
+ pkgHashProgramArgs :: Map String [String]
-- pkgHashProgPrefix :: Maybe PathTemplate,
-- pkgHashProgSuffix :: Maybe PathTemplate,
-- pkgHashPackageDbs :: [Maybe PackageDB]
+ -- Captured by extraArgs
+-- pkgHashDebugInfo :: DebugInfoLevel,
+-- pkgHashCoverage :: Bool,
+-- pkgHashFullyStaticExe :: Bool,
+-- pkgHashProfLibDetail :: ProfDetailLevel,
+-- pkgHashOptimization :: Int,
+-- pkgHashProfExeDetail :: ProfDetailLevel,
+-- pkgHashExtraLibDirs :: [FilePath],
+-- pkgHashExtraLibDirsStatic :: [FilePath],
+-- pkgHashExtraFrameworkDirs :: [FilePath],
+-- pkgHashExtraIncludeDirs :: [FilePath]
}
deriving Show
@@ -115,56 +126,92 @@ pkgHashOracle = void $ addOracleCache $ \(PkgHashKey ctx) -> do
stagePkgs <- stagePackages stag
depsHashes <- mapM (\pkg -> pkgHash (ctx { package = pkg })) [pkg | pkg <- packageDependencies pkg_data, pkg `elem` stagePkgs]
flav <- flavour
- let flavourArgs = args flav
+ let flavourArgs = extraArgs flav
targetOs <- setting TargetOs
- let pkgHashCompilerId = ""
+ projectVersion <- setting ProjectVersionInt
+ let pkgHashCompilerId = "ghc-" ++ projectVersion
pkgHashPlatform = targetOs
+
libWays <- interpretInContext ctx (libraryWays flav)
dyn_ghc <- dynamicGhcPrograms flav
- flags <- interpret (target ctx (Cabal Flags stag) [] []) flavourArgs
+ flags <- interpret (target ctx (Cabal Flags stag) [] []) getArgs
let pkgHashFlagAssignment = flags
- pkgHashConfigureScriptArgs = ""
pkgHashVanillaLib = vanilla `Set.member` libWays
pkgHashSharedLib = dynamic `Set.member` libWays
pkgHashDynExe = dyn_ghc
- pkgHashFullyStaticExe = False -- TODO: fullyStatic flavour transformer
pkgHashGHCiLib = False
pkgHashProfLib = profiling `Set.member` libWays
pkgHashProfExe = package ctx == ghc && ghcProfiled flav stag
- pkgHashCoverage = False -- Can't configure this
- pkgHashOptimization = 0 -- TODO: A bit tricky to configure
pkgHashSplitObjs = False -- Deprecated
pkgHashSplitSections = ghcSplitSections flav
pkgHashStripExes = False
pkgHashStripLibs = False
- pkgHashDebugInfo = undefined
- -- ghcArgs <- interpret (target ctx (Cabal Setup stag) [] []) flavourArgs
- let pkgHashProgramArgs = mempty -- TODO: Map.singleton "ghc" ghcArgs,
- -- but the above call to 'interpret' causes a
- -- build-time loop
- pkgHashExtraLibDirs = []
- pkgHashExtraLibDirsStatic = []
- pkgHashExtraFrameworkDirs = []
- pkgHashExtraIncludeDirs = []
+ ghcArgs <- interpret (target ctx (Ghc CompileHs stag) [] []) flavourArgs
+ ghcCArgs <- interpret (target ctx (Ghc CompileCWithGhc stag) [] []) flavourArgs
+ linkArgs <- interpret (target ctx (Ghc LinkHs stag) [] []) flavourArgs
+ ccArgs <- interpret (target ctx (Cc CompileC stag) [] []) flavourArgs
+ hsc2hsArgs <- interpret (target ctx (Hsc2Hs stag) [] []) flavourArgs
+ -- TODO: Other arguments for other things (a user could pass extra options to any
+ -- builder we know about and we need to enumerate them here)
+ let pkgHashProgramArgs = Map.fromList [("ghc", ghcArgs)
+ ,("ghc-c", ghcCArgs)
+ ,("ghc-link", linkArgs)
+ ,("hsc2hs", hsc2hsArgs)
+ ,("cc", ccArgs)
+ ]
let other_config = PackageHashConfigInputs{..}
+ files <- allFilesInDirectory (pkgPath (package ctx))
+ need files
+ files_hash <- liftIO (SHA256.finalize <$> hashFiles (SHA256.init) files)
+
return $ BS.unpack $ Base16.encode $ SHA256.hash $
renderPackageHashInputs $ PackageHashInputs
{
pkgHashPkgId = name
, pkgHashComponent = pkgType (package ctx)
- , pkgHashSourceHash = ""
+ , pkgHashSourceHash = files_hash
, pkgHashDirectDeps = Set.fromList depsHashes
, pkgHashOtherConfig = other_config
}
+-- Either use git ls-tree if we are in a git repo, otherwise just get all the
+-- files in the given directory.
+allFilesInDirectory :: FilePath -> Action [FilePath]
+allFilesInDirectory dir = do
+ git_tree <- isInGitTree
+ if git_tree
+ then do
+ let gitFiles = filter fileFilter . split (=='\NUL')
+ fileFilter file = not (null file) && ((dir ++ "/*") ?== file)
+ gitFiles <$> askWithResources [] (target (vanillaContext stage0Boot compiler) -- This value doesn't matter.
+ (Git ListFiles) [dir] [])
+ else
+ liftIO $ listFilesRecursive dir
+
+isInGitTree :: Action Bool
+isInGitTree = do
+ git_commit <- setting ProjectGitCommitId
+ -- git_commit is not set if we are in a source dist
+ return $ not ("" == git_commit)
+
+
prettyShow, showHashValue :: Show a => a -> String
prettyShow = show
showHashValue = show
+hashFiles :: SHA256.Ctx -> [FilePath] -> IO SHA256.Ctx
+hashFiles = foldM hashFile
+
+hashFile :: SHA256.Ctx -> FilePath -> IO SHA256.Ctx
+hashFile !ctx fp = do
+ contents <- BS.readFile fp
+ return $! SHA256.update ctx contents
+
+
renderPackageHashInputs :: PackageHashInputs -> BS.ByteString
renderPackageHashInputs PackageHashInputs{
pkgHashPkgId,
@@ -180,51 +227,27 @@ renderPackageHashInputs PackageHashInputs{
-- unnecessarily when new configuration inputs are added into the hash.
BS.pack $ unlines $ catMaybes $
[ entry "pkgid" prettyShow pkgHashPkgId
--- , mentry "component" show pkgHashComponent
+ , entry "component" show pkgHashComponent
, entry "src" showHashValue pkgHashSourceHash
- {-
- , entry "pkg-config-deps"
- (intercalate ", " . map (\(pn, mb_v) -> prettyShow pn ++
- case mb_v of
- Nothing -> ""
- Just v -> " " ++ prettyShow v)
- . Set.toList) pkgHashPkgConfigDeps
- -}
, entry "deps" (intercalate ", " . map prettyShow
. Set.toList) pkgHashDirectDeps
-- and then all the config
, entry "compilerid" prettyShow pkgHashCompilerId
, entry "platform" prettyShow pkgHashPlatform
, opt "flags" mempty show pkgHashFlagAssignment
--- , opt "configure-script" [] unwords pkgHashConfigureScriptArgs
, opt "vanilla-lib" True prettyShow pkgHashVanillaLib
, opt "shared-lib" False prettyShow pkgHashSharedLib
, opt "dynamic-exe" False prettyShow pkgHashDynExe
- , opt "fully-static-exe" False prettyShow pkgHashFullyStaticExe
, opt "ghci-lib" False prettyShow pkgHashGHCiLib
, opt "prof-lib" False prettyShow pkgHashProfLib
, opt "prof-exe" False prettyShow pkgHashProfExe
- -- , opt "prof-lib-detail" ProfDetailDefault showProfDetailLevel pkgHashProfLibDetail
- -- , opt "prof-exe-detail" ProfDetailDefault showProfDetailLevel pkgHashProfExeDetail
- , opt "hpc" False prettyShow pkgHashCoverage
- , opt "optimisation" 0 (show) pkgHashOptimization
, opt "split-objs" False prettyShow pkgHashSplitObjs
, opt "split-sections" False prettyShow pkgHashSplitSections
, opt "stripped-lib" False prettyShow pkgHashStripLibs
, opt "stripped-exe" True prettyShow pkgHashStripExes
--- , opt "debug-info" NormalDebugInfo (show . fromEnum) pkgHashDebugInfo
- , opt "extra-lib-dirs" [] unwords pkgHashExtraLibDirs
- , opt "extra-lib-dirs-static" [] unwords pkgHashExtraLibDirsStatic
- , opt "extra-framework-dirs" [] unwords pkgHashExtraFrameworkDirs
- , opt "extra-include-dirs" [] unwords pkgHashExtraIncludeDirs
--- , opt "prog-prefix" Nothing (maybe "" fromPathTemplate) pkgHashProgPrefix
--- , opt "prog-suffix" Nothing (maybe "" fromPathTemplate) pkgHashProgSuffix
--- , opt "package-dbs" [] (unwords . map show) pkgHashPackageDbs
-
] ++ Map.foldrWithKey (\prog args acc -> opt (prog ++ "-options") [] unwords args : acc) [] pkgHashProgramArgs
where
entry key format value = Just (key ++ ": " ++ format value)
- mentry key format value = fmap (\v -> key ++ ": " ++ format v) value
opt key def format value
| value == def = Nothing
| otherwise = entry key format value
=====================================
hadrian/src/Settings.hs
=====================================
@@ -1,7 +1,7 @@
{-# LANGUAGE TupleSections #-}
module Settings (
- getArgs, getLibraryWays, getRtsWays, flavour, knownPackages,
+ getExtraArgs, getArgs, getLibraryWays, getRtsWays, flavour, knownPackages,
findPackageByName, unsafeFindPackageByName, unsafeFindPackageByPath,
isLibrary, stagePackages, getBignumBackend, getBignumCheck, completeSetting
) where
@@ -25,8 +25,11 @@ import Settings.Flavours.Validate
import Settings.Flavours.Release
+getExtraArgs :: Args
+getExtraArgs = expr flavour >>= extraArgs
+
getArgs :: Args
-getArgs = expr flavour >>= args
+getArgs = mconcat [ defaultBuilderArgs, getExtraArgs, defaultPackageArgs ]
getLibraryWays :: Ways
getLibraryWays = expr flavour >>= libraryWays
=====================================
hadrian/src/Settings/Builders/Ghc.hs
=====================================
@@ -228,6 +228,8 @@ commonGhcArgs = do
-- input hash to avoid superfluous recompilation, avoiding
-- #18672.
arg "-fdiagnostics-color=always"
+ -- Important this is last.. as these options can override the default options
+ , getContextData hcOpts
]
-- TODO: Do '-ticky' in all debug ways?
=====================================
hadrian/src/Settings/Default.hs
=====================================
@@ -7,7 +7,7 @@ module Settings.Default (
-- * Default command line arguments for various builders
SourceArgs (..), sourceArgs, defaultBuilderArgs, defaultPackageArgs,
- defaultArgs,
+ defaultExtraArgs,
-- * Default build flavour and BigNum backend
defaultFlavour, defaultBignumBackend
@@ -17,7 +17,6 @@ import qualified Data.Set as Set
import qualified Hadrian.Builder.Sphinx
import qualified Hadrian.Builder.Tar
-import Hadrian.Haskell.Cabal.Type
import CommandLine
import Expression
@@ -206,9 +205,8 @@ data SourceArgs = SourceArgs
-- | Concatenate source arguments in appropriate order.
sourceArgs :: SourceArgs -> Args
-sourceArgs SourceArgs {..} = builder Ghc ? mconcat
+sourceArgs SourceArgs {..} = builder Ghc ? mconcat []
[ hsDefault
- , getContextData hcOpts
-- `compiler` is also a library but the specific arguments that we want
-- to apply to that are given by the hsCompiler option. `ghc` is an
-- executable so we don't have to exclude that.
@@ -217,11 +215,8 @@ sourceArgs SourceArgs {..} = builder Ghc ? mconcat
, package ghc ? hsGhc ]
-- | All default command line arguments.
-defaultArgs :: Args
-defaultArgs = mconcat
- [ defaultBuilderArgs
- , sourceArgs defaultSourceArgs
- , defaultPackageArgs ]
+defaultExtraArgs :: Args
+defaultExtraArgs = sourceArgs defaultSourceArgs
-- | Default source arguments, e.g. optimisation settings.
defaultSourceArgs :: SourceArgs
@@ -239,7 +234,7 @@ defaultSourceArgs = SourceArgs
defaultFlavour :: Flavour
defaultFlavour = Flavour
{ name = "default"
- , args = defaultArgs
+ , extraArgs = defaultExtraArgs
, packages = defaultPackages
, bignumBackend = defaultBignumBackend
, bignumCheck = False
=====================================
hadrian/src/Settings/Default.hs-boot
=====================================
@@ -1,6 +1,6 @@
module Settings.Default (
SourceArgs (..), sourceArgs, defaultBuilderArgs, defaultPackageArgs,
- defaultArgs, defaultLibraryWays, defaultRtsWays,
+ defaultExtraArgs, defaultLibraryWays, defaultRtsWays,
defaultFlavour, defaultBignumBackend
) where
@@ -15,7 +15,7 @@ data SourceArgs = SourceArgs
sourceArgs :: SourceArgs -> Args
-defaultBuilderArgs, defaultPackageArgs, defaultArgs :: Args
+defaultBuilderArgs, defaultPackageArgs, defaultExtraArgs :: Args
defaultLibraryWays, defaultRtsWays :: Ways
defaultFlavour :: Flavour
defaultBignumBackend :: String
=====================================
hadrian/src/Settings/Flavours/Benchmark.hs
=====================================
@@ -10,7 +10,7 @@ import {-# SOURCE #-} Settings.Default
benchmarkFlavour :: Flavour
benchmarkFlavour = defaultFlavour
{ name = "bench"
- , args = defaultBuilderArgs <> benchmarkArgs <> defaultPackageArgs
+ , extraArgs = benchmarkArgs
, libraryWays = pure $ Set.fromList [vanilla]
, rtsWays = Set.fromList <$> mconcat [pure [vanilla], targetSupportsThreadedRts ? pure [threaded]] }
=====================================
hadrian/src/Settings/Flavours/Development.hs
=====================================
@@ -12,7 +12,7 @@ import {-# SOURCE #-} Settings.Default
developmentFlavour :: Stage -> Flavour
developmentFlavour ghcStage = defaultFlavour
{ name = "devel" ++ stageString ghcStage
- , args = defaultBuilderArgs <> developmentArgs ghcStage <> defaultPackageArgs
+ , extraArgs = developmentArgs ghcStage
, libraryWays = pure $ Set.fromList [vanilla]
, rtsWays = Set.fromList <$> mconcat [pure [vanilla, debug], targetSupportsThreadedRts ? pure [threaded, threadedDebug]]
, dynamicGhcPrograms = return False
=====================================
hadrian/src/Settings/Flavours/GhcInGhci.hs
=====================================
@@ -11,7 +11,7 @@ import {-# SOURCE #-} Settings.Default
ghcInGhciFlavour :: Flavour
ghcInGhciFlavour = defaultFlavour
{ name = "ghc-in-ghci"
- , args = defaultBuilderArgs <> ghciArgs <> defaultPackageArgs
+ , extraArgs = ghciArgs
-- We can't build DLLs on Windows (yet). Actually we should only
-- include the dynamic way when we have a dynamic host GHC, but just
-- checking for Windows seems simpler for now.
=====================================
hadrian/src/Settings/Flavours/Performance.hs
=====================================
@@ -8,7 +8,7 @@ import {-# SOURCE #-} Settings.Default
performanceFlavour :: Flavour
performanceFlavour = splitSections $ defaultFlavour
{ name = "perf"
- , args = defaultBuilderArgs <> performanceArgs <> defaultPackageArgs }
+ , extraArgs = performanceArgs }
performanceArgs :: Args
performanceArgs = sourceArgs SourceArgs
=====================================
hadrian/src/Settings/Flavours/Quick.hs
=====================================
@@ -15,7 +15,7 @@ import {-# SOURCE #-} Settings.Default
quickFlavour :: Flavour
quickFlavour = defaultFlavour
{ name = "quick"
- , args = defaultBuilderArgs <> quickArgs <> defaultPackageArgs
+ , extraArgs = quickArgs
, libraryWays = Set.fromList <$>
mconcat
[ pure [vanilla]
=====================================
hadrian/src/Settings/Flavours/QuickCross.hs
=====================================
@@ -11,7 +11,7 @@ import {-# SOURCE #-} Settings.Default
quickCrossFlavour :: Flavour
quickCrossFlavour = defaultFlavour
{ name = "quick-cross"
- , args = defaultBuilderArgs <> quickCrossArgs <> defaultPackageArgs
+ , extraArgs = quickCrossArgs
, dynamicGhcPrograms = pure False
, libraryWays = Set.fromList <$>
mconcat
=====================================
hadrian/src/Settings/Flavours/Quickest.hs
=====================================
@@ -11,7 +11,7 @@ import {-# SOURCE #-} Settings.Default
quickestFlavour :: Flavour
quickestFlavour = defaultFlavour
{ name = "quickest"
- , args = defaultBuilderArgs <> quickestArgs <> defaultPackageArgs
+ , extraArgs = quickestArgs
, libraryWays = pure (Set.fromList [vanilla])
, rtsWays = pure (Set.fromList [vanilla]) <> (targetSupportsThreadedRts ? pure (Set.fromList [threaded]))
, dynamicGhcPrograms = return False }
=====================================
hadrian/src/Settings/Flavours/Validate.hs
=====================================
@@ -12,7 +12,7 @@ import {-# SOURCE #-} Settings.Default
validateFlavour :: Flavour
validateFlavour = enableLinting $ werror $ defaultFlavour
{ name = "validate"
- , args = defaultBuilderArgs <> validateArgs <> defaultPackageArgs
+ , extraArgs = validateArgs
, libraryWays = Set.fromList <$>
mconcat [ pure [vanilla]
, notStage0 ? platformSupportsSharedLibs ? pure [dynamic]
@@ -60,4 +60,4 @@ quickValidateArgs = sourceArgs SourceArgs
quickValidateFlavour :: Flavour
quickValidateFlavour = werror $ validateFlavour
{ name = "quick-validate"
- , args = defaultBuilderArgs <> quickValidateArgs <> defaultPackageArgs }
+ , extraArgs = quickValidateArgs }
=====================================
utils/ghc-pkg/Main.hs
=====================================
@@ -23,7 +23,6 @@
module Main (main) where
-import Debug.Trace
import qualified GHC.Unit.Database as GhcPkg
import GHC.Unit.Database hiding (mkMungePathUrl)
import GHC.HandleEncoding
@@ -1601,7 +1600,7 @@ listPackages verbosity my_flags mPackageName mModuleName = do
simplePackageList :: [Flag] -> [InstalledPackageInfo] -> IO ()
simplePackageList my_flags pkgs = do
let showPkg :: InstalledPackageInfo -> String
- showPkg | FlagShowUnitIds `elem` my_flags = traceId . display . installedUnitId
+ showPkg | FlagShowUnitIds `elem` my_flags = display . installedUnitId
| FlagNamesOnly `elem` my_flags = display . mungedName . mungedId
| otherwise = display . mungedId
strs = map showPkg pkgs
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5d179c5d73e643dd8457457b95f4666e288eaf5d...c689e100666bf5c9f41f49136b344a84d94c02a8
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5d179c5d73e643dd8457457b95f4666e288eaf5d...c689e100666bf5c9f41f49136b344a84d94c02a8
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230403/856ba20c/attachment-0001.html>
More information about the ghc-commits
mailing list