Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include the compiler ABI tag in nix-style package hashes #9325

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Cabal/src/Distribution/Simple/GHC.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TupleSections #-}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 <> "-"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bgamari is "Project Unit Id" the proper ABI identifier?

I see ghc-9.8.1-f7d8 in mine.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me understand. GHC does not actually offer anything called ABI tag/identifier/hash? We are going to use this Project Unit Id? Is this the right thing to do?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Project Unit Id is indeed a reasonable thing to use here. Indeed it was specifically added to avoid mixing compilation artifacts from different compilers.


let comp =
Compiler
{ compilerId = CompilerId GHC ghcVersion
, compilerAbiTag = NoAbiTag
{ compilerId
, compilerAbiTag
, compilerCompat = []
, compilerLanguages = languages
, compilerExtensions = extensions
Expand Down
10 changes: 9 additions & 1 deletion cabal-install/src/Distribution/Client/PackageHash.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ import Distribution.Package
, mkComponentId
)
import Distribution.Simple.Compiler
( CompilerId
( AbiTag (..)
, CompilerId
, DebugInfoLevel (..)
, OptimisationLevel (..)
, PackageDB
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
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 @@ -4569,6 +4569,7 @@ packageHashConfigInputs
packageHashConfigInputs shared@ElaboratedSharedConfig{..} pkg =
PackageHashConfigInputs
{ pkgHashCompilerId = compilerId pkgConfigCompiler
, pkgHashCompilerAbiTag = compilerAbiTag pkgConfigCompiler
, pkgHashPlatform = pkgConfigPlatform
, pkgHashFlagAssignment = elabFlagAssignment
, pkgHashConfigureScriptArgs = elabConfigureScriptArgs
Expand Down
3 changes: 3 additions & 0 deletions changelog.d/pr-9325
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
synopsis: Include the compiler ABI tag in nix-style package hashes
packages: Cabal cabal-install
prs: #9325
Loading