diff --git a/Cabal/Distribution/Simple/Program/Types.hs b/Cabal/Distribution/Simple/Program/Types.hs index 6eb0695017b..5ba00de6d37 100644 --- a/Cabal/Distribution/Simple/Program/Types.hs +++ b/Cabal/Distribution/Simple/Program/Types.hs @@ -74,10 +74,14 @@ data Program = Program { -- | A function to do any additional configuration after we have -- located the program (and perhaps identified its version). For example -- it could add args, or environment vars. - programPostConf :: Verbosity -> ConfiguredProgram -> IO ConfiguredProgram + programPostConf :: Verbosity -> ConfiguredProgram -> IO ConfiguredProgram, + -- | A function that filters any arguments that don't impact the output + -- from a commandline. Used to limit the volatility of dependency hashes + -- when using new-build. + programFilterArgs :: Maybe Version -> [String] -> [String] } instance Show Program where - show (Program name _ _ _) = "Program: " ++ name + show (Program name _ _ _ _) = "Program: " ++ name type ProgArg = String @@ -161,7 +165,8 @@ simpleProgram name = Program { programName = name, programFindLocation = \v p -> findProgramOnSearchPath v p name, programFindVersion = \_ _ -> return Nothing, - programPostConf = \_ p -> return p + programPostConf = \_ p -> return p, + programFilterArgs = const id } -- | Make a simple 'ConfiguredProgram'. diff --git a/cabal-install/Distribution/Client/ProjectPlanning.hs b/cabal-install/Distribution/Client/ProjectPlanning.hs index 45b0a9efc6d..1495a9e0ff2 100644 --- a/cabal-install/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/Distribution/Client/ProjectPlanning.hs @@ -3522,13 +3522,21 @@ packageHashConfigInputs pkgHashStripLibs = elabStripLibs, pkgHashStripExes = elabStripExes, pkgHashDebugInfo = elabDebugInfo, - pkgHashProgramArgs = elabProgramArgs, + pkgHashProgramArgs = Map.mapWithKey lookupFilter elabProgramArgs, pkgHashExtraLibDirs = elabExtraLibDirs, pkgHashExtraFrameworkDirs = elabExtraFrameworkDirs, pkgHashExtraIncludeDirs = elabExtraIncludeDirs, pkgHashProgPrefix = elabProgPrefix, pkgHashProgSuffix = elabProgSuffix } + where + lookupFilter :: String -> [String] -> [String] + lookupFilter n = case lookupKnownProgram n pkgConfigCompilerProgs of + Just p -> programFilterArgs p (getVersion p) + Nothing -> id + + getVersion :: Program -> Maybe Version + getVersion p = lookupProgram p pkgConfigCompilerProgs >>= programVersion -- | Given the 'InstalledPackageIndex' for a nix-style package store, and an