Skip to content

Commit 1fc2e2a

Browse files
committed
Fix id generation in Backpack.
1 parent 7e50837 commit 1fc2e2a

File tree

7 files changed

+23
-8
lines changed

7 files changed

+23
-8
lines changed

Cabal-syntax/src/Distribution/Types/ComponentId.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ mkComponentId :: HasCallStack => String -> ComponentId
5959
mkComponentId s = case (simpleParsec s) of
6060
-- Just cid@ComponentId{ unitComp = c, unitId = i } | (fromShortText c) == "ghc-9.8.4", (fromShortText i) == "rts-1.0.3-cec100dd" -> trace ("### ComponentId: `" ++ (fromShortText c) ++ "' `" ++ (fromShortText i) ++ "' is a full one.\n" ++ prettyCallStack callStack) cid
6161
Just cid@ComponentId{} -> cid
62-
Just cid@PartialComponentId{} -> error $ "mkPartialComponentId: `" ++ s ++ "' is a partial component id, not a full one."
62+
Just cid@PartialComponentId{} -> error $ "mkPartialComponentId: `" ++ s ++ "' is a partial component id, not a full one.\n" ++ (prettyCallStack callStack)
6363
_ -> error $ "Unable to parse PartialComponentId: `" ++ s ++ "'."
6464

6565
mkComponentId' :: HasCallStack => String -> String -> Bool -> ComponentId

Cabal/src/Distribution/Backpack/Configure.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ configureComponentLocalBuildInfos
127127
deterministic
128128
ipid_flag
129129
cid_flag
130+
comp
130131
pkg_descr
131132
conf_pkg_map
132133
(map fst graph0)

Cabal/src/Distribution/Backpack/ConfiguredComponent.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import Distribution.CabalSpecVersion
2222
import Distribution.Package
2323
import Distribution.PackageDescription
2424
import Distribution.Simple.BuildToolDepends
25+
import Distribution.Simple.Compiler
2526
import Distribution.Simple.Flag (Flag)
2627
import Distribution.Simple.LocalBuildInfo
2728
import Distribution.Types.AnnotatedId
@@ -242,6 +243,7 @@ toConfiguredComponent pkg_descr this_cid lib_dep_map exe_dep_map component = do
242243
toConfiguredComponent'
243244
:: Bool -- use_external_internal_deps
244245
-> FlagAssignment
246+
-> Compiler
245247
-> PackageDescription
246248
-> Bool -- deterministic
247249
-> Flag String -- configIPID (todo: remove me)
@@ -252,6 +254,7 @@ toConfiguredComponent'
252254
toConfiguredComponent'
253255
use_external_internal_deps
254256
flags
257+
comp
255258
pkg_descr
256259
deterministic
257260
ipid_flag
@@ -276,6 +279,7 @@ toConfiguredComponent'
276279
deterministic
277280
ipid_flag
278281
cid_flag
282+
(compilerId comp)
279283
(package pkg_descr)
280284
(componentName component)
281285
(Just (deps, flags))
@@ -308,6 +312,7 @@ toConfiguredComponents
308312
-> Bool -- deterministic
309313
-> Flag String -- configIPID
310314
-> Flag ComponentId -- configCID
315+
-> Compiler
311316
-> PackageDescription
312317
-> ConfiguredComponentMap
313318
-> [Component]
@@ -318,6 +323,7 @@ toConfiguredComponents
318323
deterministic
319324
ipid_flag
320325
cid_flag
326+
comp
321327
pkg_descr
322328
dep_map
323329
comps =
@@ -328,6 +334,7 @@ toConfiguredComponents
328334
toConfiguredComponent'
329335
use_external_internal_deps
330336
flags
337+
comp
331338
pkg_descr
332339
deterministic
333340
ipid_flag

Cabal/src/Distribution/Backpack/Id.hs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ computeComponentId
3434
:: Bool -- deterministic mode
3535
-> Flag String
3636
-> Flag ComponentId
37+
-> CompilerId
3738
-> PackageIdentifier
3839
-> ComponentName
3940
-- This is used by cabal-install's legacy codepath
4041
-> Maybe ([ComponentId], FlagAssignment)
4142
-> ComponentId
42-
computeComponentId deterministic mb_ipid mb_cid pid cname mb_details =
43+
computeComponentId deterministic mb_ipid mb_cid compid pid cname mb_details =
4344
-- show is found to be faster than intercalate and then replacement of
4445
-- special character used in intercalating. We cannot simply hash by
4546
-- doubly concatenating list, as it just flatten out the nested list, so
@@ -67,6 +68,9 @@ computeComponentId deterministic mb_ipid mb_cid pid cname mb_details =
6768
-- Hack to reuse install dirs machinery
6869
-- NB: no real IPID available at this point
6970
env = packageTemplateEnv pid (mkUnitId "")
71+
-- can't use pkgCompiler pid here, because it's
72+
-- likely not set.
73+
compiler_prefix = prettyShow compid ++ "_"
7074
actual_base = case mb_ipid of
7175
Flag ipid0 -> explicit_base ipid0
7276
NoFlag
@@ -76,7 +80,9 @@ computeComponentId deterministic mb_ipid mb_cid pid cname mb_details =
7680
Flag cid -> cid
7781
NoFlag ->
7882
mkComponentId $
79-
actual_base
83+
(if compiler_prefix `isPrefixOf` actual_base
84+
then actual_base
85+
else compiler_prefix ++ actual_base)
8086
++ ( case componentNameString cname of
8187
Nothing -> ""
8288
Just s -> "-" ++ unUnqualComponentName s

cabal-install/src/Distribution/Client/Configure.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ configure
205205
(const (return configFlags))
206206
(const extraArgs)
207207
Right installPlan0 ->
208-
let installPlan = InstallPlan.configureInstallPlan configFlags installPlan0
208+
let installPlan = InstallPlan.configureInstallPlan comp configFlags installPlan0
209209
in case fst (InstallPlan.ready installPlan) of
210210
[ pkg@( ReadyPackage
211211
( ConfiguredPackage

cabal-install/src/Distribution/Client/Install.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ processInstallPlan
526526
-> IO ()
527527
processInstallPlan
528528
verbosity
529-
args@(_, _, _, _, _, _, configFlags, _, installFlags, _, _, _)
529+
args@(_, _, comp, _, _, _, configFlags, _, installFlags, _, _, _)
530530
( installedPkgIndex
531531
, sourcePkgDb
532532
, _
@@ -552,7 +552,7 @@ processInstallPlan
552552
installPlan
553553
postInstallActions verbosity args userTargets installPlan buildOutcomes
554554
where
555-
installPlan = InstallPlan.configureInstallPlan configFlags installPlan0
555+
installPlan = InstallPlan.configureInstallPlan comp configFlags installPlan0
556556
dryRun = fromFlag (installDryRun installFlags)
557557
nothingToInstall = null (fst (InstallPlan.ready installPlan))
558558

cabal-install/src/Distribution/Client/InstallPlan.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,8 +590,8 @@ fromSolverInstallPlanWithProgress f plan = do
590590

591591
-- | Conversion of 'SolverInstallPlan' to 'InstallPlan'.
592592
-- Similar to 'elaboratedInstallPlan'
593-
configureInstallPlan :: Cabal.ConfigFlags -> SolverInstallPlan -> InstallPlan
594-
configureInstallPlan configFlags solverPlan =
593+
configureInstallPlan :: Cabal.ConfigFlags -> Compiler -> SolverInstallPlan -> InstallPlan
594+
configureInstallPlan configFlags comp solverPlan =
595595
flip fromSolverInstallPlan solverPlan $ \mapDep planpkg ->
596596
[ case planpkg of
597597
SolverInstallPlan.PreExisting pkg ->
@@ -614,6 +614,7 @@ configureInstallPlan configFlags solverPlan =
614614
)
615615
Cabal.NoFlag
616616
Cabal.NoFlag
617+
(compilerId comp)
617618
(packageId spkg)
618619
(PD.CLibName PD.LMainLibName)
619620
( Just

0 commit comments

Comments
 (0)