From 4c6aa86d264b94485ee50b7d29fbabdf4fb3e939 Mon Sep 17 00:00:00 2001 From: Simon Hengel Date: Thu, 12 Oct 2023 13:58:36 +0700 Subject: [PATCH] Include the compiler ABI tag in nix-style package hashes --- Cabal/src/Distribution/Simple/GHC.hs | 12 ++++++++++-- cabal-install/src/Distribution/Client/PackageHash.hs | 8 ++++++++ .../src/Distribution/Client/ProjectPlanning.hs | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Cabal/src/Distribution/Simple/GHC.hs b/Cabal/src/Distribution/Simple/GHC.hs index 3c380a41a86..c06fd7bdfc3 100644 --- a/Cabal/src/Distribution/Simple/GHC.hs +++ b/Cabal/src/Distribution/Simple/GHC.hs @@ -1,6 +1,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE MultiWayIf #-} +{-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE TupleSections #-} @@ -83,6 +84,7 @@ import Prelude () import Control.Monad (forM_, msum) import Data.Char (isLower) +import Data.List (stripPrefix) import qualified Data.Map as Map import Distribution.CabalSpecVersion import Distribution.InstalledPackageInfo (InstalledPackageInfo) @@ -246,10 +248,16 @@ configure verbosity hcPath hcPkgPath conf0 = do filterExt ext = filter ((/= EnableExtension ext) . fst) + compilerId :: CompilerId + compilerId = CompilerId GHC ghcVersion + + compilerAbiTag :: AbiTag + compilerAbiTag = maybe NoAbiTag AbiTag (Map.lookup "Project Unit Id" ghcInfoMap >>= stripPrefix (prettyShow compilerId <> "-")) + let comp = Compiler - { compilerId = CompilerId GHC ghcVersion - , compilerAbiTag = NoAbiTag + { compilerId + , compilerAbiTag , compilerCompat = [] , compilerLanguages = languages , compilerExtensions = extensions diff --git a/cabal-install/src/Distribution/Client/PackageHash.hs b/cabal-install/src/Distribution/Client/PackageHash.hs index 18be444cde7..c5291de2a8e 100644 --- a/cabal-install/src/Distribution/Client/PackageHash.hs +++ b/cabal-install/src/Distribution/Client/PackageHash.hs @@ -39,6 +39,7 @@ import Distribution.Package ) import Distribution.Simple.Compiler ( CompilerId + , AbiTag(..) , DebugInfoLevel (..) , OptimisationLevel (..) , PackageDB @@ -191,6 +192,7 @@ type PackageSourceHash = HashValue -- package hash. data PackageHashConfigInputs = PackageHashConfigInputs { pkgHashCompilerId :: CompilerId + , pkgHashCompilerAbiTag :: AbiTag , pkgHashPlatform :: Platform , pkgHashFlagAssignment :: FlagAssignment -- complete not partial , pkgHashConfigureScriptArgs :: [String] -- just ./configure for build-type Configure @@ -301,6 +303,7 @@ renderPackageHashInputs pkgHashDirectDeps , -- and then all the config entry "compilerid" prettyShow pkgHashCompilerId + , entry "compiler-abi-tag" renderAbiTag pkgHashCompilerAbiTag , entry "platform" prettyShow pkgHashPlatform , opt "flags" mempty showFlagAssignment pkgHashFlagAssignment , opt "configure-script" [] unwords pkgHashConfigureScriptArgs @@ -352,3 +355,8 @@ renderPackageHashInputs opt key def format value | value == def = Nothing | otherwise = entry key format value + +renderAbiTag :: AbiTag -> String +renderAbiTag abiTag = case abiTag of + NoAbiTag -> "unknown" + AbiTag tag -> tag diff --git a/cabal-install/src/Distribution/Client/ProjectPlanning.hs b/cabal-install/src/Distribution/Client/ProjectPlanning.hs index 1b92a8aa54b..9b7b73f6c81 100644 --- a/cabal-install/src/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/src/Distribution/Client/ProjectPlanning.hs @@ -4569,6 +4569,7 @@ packageHashConfigInputs packageHashConfigInputs shared@ElaboratedSharedConfig{..} pkg = PackageHashConfigInputs { pkgHashCompilerId = compilerId pkgConfigCompiler + , pkgHashCompilerAbiTag = compilerAbiTag pkgConfigCompiler , pkgHashPlatform = pkgConfigPlatform , pkgHashFlagAssignment = elabFlagAssignment , pkgHashConfigureScriptArgs = elabConfigureScriptArgs