Skip to content

Commit 517b49d

Browse files
committed
Do register monolithic packages if they contain a buildable pub-lib (#5604)
As the case of `cpphs-1.20.8` has shown in #5379, in cases when a monolithic package gets installed due to its executable components (i.e. `exe:cpphs`) into the store we *have* to register if there's a buildable public library (i.e. `lib:cpphs`) that was built and installed into the same store folder as otherwise this will cause build failures once a target actually depends on `lib:cpphs` This ought to fix #5379 (cherry picked from commit a4578fc)
1 parent 00c12ea commit 517b49d

File tree

1 file changed

+18
-1
lines changed
  • cabal-install/Distribution/Client/ProjectPlanning

1 file changed

+18
-1
lines changed

cabal-install/Distribution/Client/ProjectPlanning/Types.hs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,24 @@ elabRequiresRegistration elab =
355355
-- register in all cases, but some Custom Setups will fall
356356
-- over if you try to do that, ESPECIALLY if there actually is
357357
-- a library but they hadn't built it.
358-
build_target || any (depends_on_lib pkg) (elabBuildTargets elab)
358+
--
359+
-- However, as the case of `cpphs-1.20.8` has shown in
360+
-- #5379, in cases when a monolithic package gets
361+
-- installed due to its executable components
362+
-- (i.e. exe:cpphs) into the store we *have* to register
363+
-- if there's a buildable public library (i.e. lib:cpphs)
364+
-- that was built and installed into the same store folder
365+
-- as otherwise this will cause build failures once a
366+
-- target actually depends on lib:cpphs.
367+
build_target || (elabBuildStyle elab == BuildAndInstall &&
368+
Cabal.hasPublicLib (elabPkgDescription elab))
369+
-- the next sub-condition below is currently redundant
370+
-- (see discussion in #5604 for more details), but it's
371+
-- being kept intentionally here as a safeguard because if
372+
-- internal libraries ever start working with
373+
-- non-per-component builds this condition won't be
374+
-- redundant anymore.
375+
|| any (depends_on_lib pkg) (elabBuildTargets elab)
359376
where
360377
depends_on_lib pkg (ComponentTarget cn _) =
361378
not (null (CD.select (== CD.componentNameToComponent cn)

0 commit comments

Comments
 (0)