Skip to content

Commit

Permalink
Include the compiler ABI hash in the package hash
Browse files Browse the repository at this point in the history
This complements the previous commit in order to fix haskell#9326
  • Loading branch information
alt-romes committed Jan 17, 2024
1 parent a0eec76 commit 129ec22
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/Simple/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ module Distribution.Simple.GHC
import Distribution.Compat.Prelude
import Prelude ()

import Control.Monad (forM_, msum)
import Control.Monad (forM_)
import Data.List (stripPrefix)
import qualified Data.Map as Map
import Distribution.CabalSpecVersion
Expand Down
7 changes: 6 additions & 1 deletion cabal-install/src/Distribution/Client/PackageHash.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
-- * the package tarball
-- * the ids of all the direct dependencies
-- * other local configuration (flags, profiling, etc)
--
-- See 'PackageHashInputs' for a detailed list of what determines the hash.
module Distribution.Client.PackageHash
( -- * Calculating package hashes
PackageHashInputs (..)
Expand Down Expand Up @@ -38,7 +40,8 @@ import Distribution.Package
, mkComponentId
)
import Distribution.Simple.Compiler
( CompilerId
( AbiTag (..)
, CompilerId
, DebugInfoLevel (..)
, OptimisationLevel (..)
, PackageDB
Expand Down Expand Up @@ -191,6 +194,7 @@ type PackageSourceHash = HashValue
-- package hash.
data PackageHashConfigInputs = PackageHashConfigInputs
{ pkgHashCompilerId :: CompilerId
, pkgHashCompilerABI :: AbiTag
, pkgHashPlatform :: Platform
, pkgHashFlagAssignment :: FlagAssignment -- complete not partial
, pkgHashConfigureScriptArgs :: [String] -- just ./configure for build-type Configure
Expand Down Expand Up @@ -301,6 +305,7 @@ renderPackageHashInputs
pkgHashDirectDeps
, -- and then all the config
entry "compilerid" prettyShow pkgHashCompilerId
, entry "compilerabi" prettyShow pkgHashCompilerABI
, entry "platform" prettyShow pkgHashPlatform
, opt "flags" mempty showFlagAssignment pkgHashFlagAssignment
, opt "configure-script" [] unwords pkgHashConfigureScriptArgs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ import Distribution.Simple.BuildPaths (haddockDirName)
import Distribution.Simple.Command (CommandUI)
import Distribution.Simple.Compiler
( PackageDBStack
, compilerId
)
import qualified Distribution.Simple.InstallDirs as InstallDirs
import Distribution.Simple.LocalBuildInfo
Expand Down
1 change: 1 addition & 0 deletions cabal-install/src/Distribution/Client/ProjectPlanning.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4310,6 +4310,7 @@ packageHashConfigInputs
packageHashConfigInputs shared@ElaboratedSharedConfig{..} pkg =
PackageHashConfigInputs
{ pkgHashCompilerId = compilerId pkgConfigCompiler
, pkgHashCompilerABI = compilerAbiTag pkgConfigCompiler
, pkgHashPlatform = pkgConfigPlatform
, pkgHashFlagAssignment = elabFlagAssignment
, pkgHashConfigureScriptArgs = elabConfigureScriptArgs
Expand Down
4 changes: 2 additions & 2 deletions cabal-testsuite/src/Test/Cabal/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import Test.Cabal.TestCode
import Distribution.Pretty (prettyShow)
import Distribution.Simple.Compiler
( PackageDBStack, PackageDB(..), compilerFlavor
, Compiler, compilerVersion, showCompilerId )
, Compiler, compilerVersion, showCompilerIdWithAbi )
import Distribution.System
import Distribution.Simple.Program.Db
import Distribution.Simple.Program
Expand Down Expand Up @@ -582,7 +582,7 @@ testLibInstallDir env = libDir </> compilerDir
libDir = case os of
Windows -> testPrefixDir env
_ -> testPrefixDir env </> "lib"
compilerDir = prettyShow platform ++ "-" ++ showCompilerId (testCompiler env)
compilerDir = prettyShow platform ++ "-" ++ showCompilerIdWithAbi (testCompiler env)

-- | The absolute path to the build directory that should be used
-- for the current package in a test.
Expand Down
13 changes: 9 additions & 4 deletions cabal-testsuite/src/Test/Cabal/OutputNormalizer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,15 @@ normalizeOutput nenv =
-- which will pick up the install ghc library (which doesn't have the
-- date glob).
. (if normalizerGhcVersion nenv /= nullVersion
then resub (posixRegexEscape (display (normalizerGhcVersion nenv))
-- Also glob the date, for nightly GHC builds
++ "(\\.[0-9]+)?")
"<GHCVER>"
then
let ghcver = posixRegexEscape (display (normalizerGhcVersion nenv))
-- Also glob the date, for nightly GHC builds
++ "(\\.[0-9]+)?"
in resub ghcver "<GHCVER>"
. resub (ghcver
-- Also glob the GHC ABI hash, which is used from ghc 9.8
++ "-[a-z0-9]+")
(ghcver ++ "<GHCABI>")
else id)
-- hackage-security locks occur non-deterministically
. resub "(Released|Acquired|Waiting) .*hackage-security-lock\n" ""
Expand Down

0 comments on commit 129ec22

Please sign in to comment.