Skip to content

Commit c2cdfc0

Browse files
mpickeringMikolaj
authored andcommitted
Fix multi-repl when only building some internal library targets
When combining together --dependency and --promised-dependency flags, we were using `Map.union` in the wrong place. If you had a dependency and promised-dependency from the same package (ie when using an internal library) then the promised dependency wouldn't be taken into account. The fix is straightforward, don't use `Map.union`. First create a list of everything and then create a map using `fromListWith`. Fixes #10775
1 parent 53dd1e5 commit c2cdfc0

File tree

9 files changed

+75
-2
lines changed

9 files changed

+75
-2
lines changed

Cabal/src/Distribution/Backpack/Configure.hs

+4-2
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ configureComponentLocalBuildInfos
101101
let conf_pkg_map =
102102
Map.fromListWith
103103
Map.union
104+
$
105+
-- Normal dependencies
104106
[ ( pc_pkgname pkg
105107
, Map.singleton
106108
(pc_compname pkg)
@@ -113,8 +115,8 @@ configureComponentLocalBuildInfos
113115
)
114116
| pkg <- prePkgDeps
115117
]
116-
`Map.union` Map.fromListWith
117-
Map.union
118+
++
119+
-- Promised dependencies
118120
[ (pkg, Map.singleton (ann_cname aid) aid)
119121
| ConfiguredPromisedComponent pkg aid <- promisedPkgDeps
120122
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# cabal v2-repl
2+
Configuration is affected by the following files:
3+
- cabal.project
4+
Resolving dependencies...
5+
Build profile: -w ghc-<GHCVER> -O1
6+
In order, the following will be built:
7+
- foo-0.1.0.0 (interactive) (lib:x) (first run)
8+
- foo-0.1.0.0 (lib:y) (first run)
9+
- foo-0.1.0.0 (interactive) (lib:z) (first run)
10+
Configuring library 'x' for foo-0.1.0.0...
11+
Preprocessing library 'x' for foo-0.1.0.0...
12+
Configuring library 'y' for foo-0.1.0.0...
13+
Preprocessing library 'y' for foo-0.1.0.0...
14+
Building library 'y' for foo-0.1.0.0...
15+
Configuring library 'z' for foo-0.1.0.0...
16+
Preprocessing library 'z' for foo-0.1.0.0...
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages: .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
import Test.Cabal.Prelude
3+
4+
main = do
5+
cabalTest $ do
6+
skipUnlessGhcVersion ">= 9.4"
7+
void $ cabalWithStdin "v2-repl" ["--enable-multi-repl","x", "z"] ""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module X where
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module Y where
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module Z where
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
cabal-version: 3.14
2+
3+
name: foo
4+
version: 0.1.0.0
5+
build-type: Simple
6+
7+
library x
8+
exposed-modules:
9+
X
10+
hs-source-dirs:
11+
components/x
12+
build-depends:
13+
base
14+
15+
library y
16+
exposed-modules:
17+
Y
18+
hs-source-dirs:
19+
components/y
20+
build-depends:
21+
base
22+
-- uncommenting this causes 'make show' to pass
23+
-- , foo:x
24+
25+
library z
26+
exposed-modules:
27+
Z
28+
hs-source-dirs:
29+
components/z
30+
build-depends:
31+
base
32+
, foo:x
33+
, foo:y

changelog.d/pr-10841.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
synopsis: Fix `cabal repl --enable-multi-repl` when only specifying some targets from a package.
3+
packages: [Cabal]
4+
prs: 10841
5+
issues: [10775]
6+
---
7+
8+
Fix a bug `cabal repl --enable-multi-repl` where the repl would fail to start if you
9+
only specified some targets to be loaded.
10+
11+
In particular, if you are using internal libraries you may be affected by this bug.

0 commit comments

Comments
 (0)