File tree Expand file tree Collapse file tree 3 files changed +23
-2
lines changed
Cabal/src/Distribution/Simple Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,6 @@ import Prelude ()
8585
8686import Control.Arrow ((***) )
8787import Control.Monad (forM_ )
88- import Data.List (stripPrefix )
8988import qualified Data.Map as Map
9089import Distribution.CabalSpecVersion
9190import Distribution.InstalledPackageInfo (InstalledPackageInfo )
@@ -248,8 +247,14 @@ configure verbosity hcPath hcPkgPath conf0 = do
248247 compilerId :: CompilerId
249248 compilerId = CompilerId GHC ghcVersion
250249
250+ -- The @AbiTag@ is the @Project Unit Id@ but with redundant information from the compiler version removed.
251+ -- For development versions of the compiler these look like:
252+ -- @Project Unit Id@: "ghc-9.13-inplace"
253+ -- @compilerId@: "ghc-9.13.20250413"
254+ -- So, we need to be careful to only strip the /common/ prefix.
255+ -- In this example, @AbiTag@ is "inplace".
251256 compilerAbiTag :: AbiTag
252- compilerAbiTag = maybe NoAbiTag AbiTag (Map. lookup " Project Unit Id " ghcInfoMap >>= stripPrefix (prettyShow compilerId <> " - " ) )
257+ compilerAbiTag = maybe NoAbiTag AbiTag (dropWhile ( == ' - ' ) . stripCommonPrefix (prettyShow compilerId) <$> Map. lookup " Project Unit Id " ghcInfoMap )
253258
254259 let comp =
255260 Compiler
Original file line number Diff line number Diff line change @@ -195,6 +195,7 @@ module Distribution.Simple.Utils
195195 , unintersperse
196196 , wrapText
197197 , wrapLine
198+ , stripCommonPrefix
198199
199200 -- * FilePath stuff
200201 , isAbsoluteOnAnyPlatform
@@ -2062,3 +2063,10 @@ findHookedPackageDesc verbosity mbWorkDir dir = do
20622063
20632064buildInfoExt :: String
20642065buildInfoExt = " .buildinfo"
2066+
2067+ -- | @stripCommonPrefix xs ys@ gives you @ys@ without the common prefix with @xs@.
2068+ stripCommonPrefix :: String -> String -> String
2069+ stripCommonPrefix (x : xs) (y : ys)
2070+ | x == y = stripCommonPrefix xs ys
2071+ | otherwise = y : ys
2072+ stripCommonPrefix _ ys = ys
Original file line number Diff line number Diff line change 1+ synopsis: Fix parsing the AbiTag with development versions of GHC
2+ packages: Cabal
3+ prs: #10979
4+ issues: #10170
5+
6+ description: {
7+ - Allow parsing the AbiTag for developmement versions of GHC.
8+ }
You can’t perform that action at this time.
0 commit comments