Skip to content

Commit 5d8fe98

Browse files
committed
Fix predicate which determines whether to build a shared library
Consider the which determines whether we should build shared libraries. pkgsUseSharedLibrary :: Set PackageId pkgsUseSharedLibrary = packagesWithLibDepsDownwardClosedProperty needsSharedLib where needsSharedLib pkg = fromMaybe compilerShouldUseSharedLibByDefault (liftM2 (||) pkgSharedLib pkgDynExe) where pkgid = packageId pkg pkgSharedLib = perPkgOptionMaybe pkgid packageConfigSharedLib pkgDynExe = perPkgOptionMaybe pkgid packageConfigDynExe In English the intended logic is: If we have enabled shared libraries or dynamic executables then we need to build a shared libary. but, a common mistake: (liftM2 (||) pkgSharedLib pkgDynExe) instead says, if we explicitly request shared libraries and also explicitly configure whether we want dynamic executables then build a shared library. It should instead use the monoid instance: getMax <$> ((Max <$> pkgSharedLib) <> (Max <$> pkgDynExe)) which captures the original logic. This failure is currently manifested in the way that if you write --disable-shared then --enable-shared is still passed to ./Setup. If you pass both --disable-shared and --disable-executable-dynamic then you don't build a shared object. Fixes #10050
1 parent a6b99b8 commit 5d8fe98

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ import Distribution.Solver.Types.ProjectConfigPath
219219
import System.FilePath
220220
import Text.PrettyPrint (colon, comma, fsep, hang, punctuate, quotes, text, vcat, ($$))
221221
import qualified Text.PrettyPrint as Disp
222+
import Data.Semigroup
222223

223224
-- | Check that an 'ElaboratedConfiguredPackage' actually makes
224225
-- sense under some 'ElaboratedSharedConfig'.
@@ -2365,7 +2366,7 @@ elaborateInstallPlan
23652366
needsSharedLib pkg =
23662367
fromMaybe
23672368
compilerShouldUseSharedLibByDefault
2368-
(liftM2 (||) pkgSharedLib pkgDynExe)
2369+
(getMax <$> ((Max <$> pkgSharedLib) <> (Max <$> pkgDynExe)))
23692370
where
23702371
pkgid = packageId pkg
23712372
pkgSharedLib = perPkgOptionMaybe pkgid packageConfigSharedLib

0 commit comments

Comments
 (0)