Skip to content
Merged
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
9 changes: 7 additions & 2 deletions Cabal/src/Distribution/Simple/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ import Prelude ()

import Control.Arrow ((***))
import Control.Monad (forM_)
import Data.List (stripPrefix)
import qualified Data.Map as Map
import Distribution.CabalSpecVersion
import Distribution.InstalledPackageInfo (InstalledPackageInfo)
Expand Down Expand Up @@ -248,8 +247,14 @@ configure verbosity hcPath hcPkgPath conf0 = do
compilerId :: CompilerId
compilerId = CompilerId GHC ghcVersion

-- The @AbiTag@ is the @Project Unit Id@ but with redundant information from the compiler version removed.
-- For development versions of the compiler these look like:
-- @Project Unit Id@: "ghc-9.13-inplace"
-- @compilerId@: "ghc-9.13.20250413"
-- So, we need to be careful to only strip the /common/ prefix.
-- In this example, @AbiTag@ is "inplace".
compilerAbiTag :: AbiTag
compilerAbiTag = maybe NoAbiTag AbiTag (Map.lookup "Project Unit Id" ghcInfoMap >>= stripPrefix (prettyShow compilerId <> "-"))
compilerAbiTag = maybe NoAbiTag AbiTag (dropWhile (== '-') . stripCommonPrefix (prettyShow compilerId) <$> Map.lookup "Project Unit Id" ghcInfoMap)

let comp =
Compiler
Expand Down
8 changes: 8 additions & 0 deletions Cabal/src/Distribution/Simple/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ module Distribution.Simple.Utils
, unintersperse
, wrapText
, wrapLine
, stripCommonPrefix

-- * FilePath stuff
, isAbsoluteOnAnyPlatform
Expand Down Expand Up @@ -2062,3 +2063,10 @@ findHookedPackageDesc verbosity mbWorkDir dir = do

buildInfoExt :: String
buildInfoExt = ".buildinfo"

-- | @stripCommonPrefix xs ys@ gives you @ys@ without the common prefix with @xs@.
stripCommonPrefix :: String -> String -> String
stripCommonPrefix (x : xs) (y : ys)
| x == y = stripCommonPrefix xs ys
| otherwise = y : ys
stripCommonPrefix _ ys = ys
8 changes: 8 additions & 0 deletions changelog.d/pr-10979
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
synopsis: Fix parsing the AbiTag with development versions of GHC
packages: Cabal
prs: #10979
issues: #10170

description: {
- Allow parsing the AbiTag for developmement versions of GHC.
}
Loading