Skip to content

Commit f47840d

Browse files
committed
refactor(cabal-install): simplify the logic behind pkgsUseSharedLibrary, pkgsUseProfilingLibrary, pkgsUseProfilingLibraryShared
We do not want to check the compiler.
1 parent e2b7b85 commit f47840d

File tree

1 file changed

+17
-59
lines changed

1 file changed

+17
-59
lines changed

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

Lines changed: 17 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ import Distribution.Simple.LocalBuildInfo
176176
, pkgComponents
177177
)
178178

179-
import Distribution.Simple.BuildWay
180179
import Distribution.Simple.PackageIndex (InstalledPackageIndex)
181180
import Distribution.Simple.Program
182181
import Distribution.Simple.Program.Db
@@ -212,8 +211,6 @@ import qualified Distribution.InstalledPackageInfo as IPI
212211
import qualified Distribution.PackageDescription as PD
213212
import qualified Distribution.PackageDescription.Configuration as PD
214213
import qualified Distribution.Simple.Configure as Cabal
215-
import qualified Distribution.Simple.GHC as GHC
216-
import qualified Distribution.Simple.GHCJS as GHCJS
217214
import qualified Distribution.Simple.InstallDirs as InstallDirs
218215
import qualified Distribution.Simple.LocalBuildInfo as Cabal
219216
import qualified Distribution.Simple.Setup as Cabal
@@ -1715,8 +1712,7 @@ elaborateInstallPlan
17151712
(map fst src_comps)
17161713
let whyNotPerComp = why_not_per_component src_comps
17171714
case NE.nonEmpty whyNotPerComp of
1718-
Nothing -> do
1719-
elaborationWarnings
1715+
Nothing ->
17201716
return comps
17211717
Just notPerCompReasons -> do
17221718
checkPerPackageOk comps notPerCompReasons
@@ -1787,7 +1783,7 @@ elaborateInstallPlan
17871783
<+> fsep (punctuate comma $ map (text . whyNotPerComponent) $ toList reasons)
17881784
-- TODO: Maybe exclude Backpack too
17891785

1790-
(elab0, elaborationWarnings) = elaborateSolverToCommon spkg
1786+
elab0 = elaborateSolverToCommon spkg
17911787
pkgid = elabPkgSourceId elab0
17921788
pd = elabPkgDescription elab0
17931789

@@ -2098,10 +2094,9 @@ elaborateInstallPlan
20982094
-- Knot tying: the final elab includes the
20992095
-- pkgInstalledId, which is calculated by hashing many
21002096
-- of the other fields of the elaboratedPackage.
2101-
elaborationWarnings
21022097
return elab
21032098
where
2104-
(elab0@ElaboratedConfiguredPackage{..}, elaborationWarnings) =
2099+
elab0@ElaboratedConfiguredPackage{..} =
21052100
elaborateSolverToCommon pkg
21062101

21072102
elab1 =
@@ -2187,7 +2182,7 @@ elaborateInstallPlan
21872182

21882183
elaborateSolverToCommon
21892184
:: SolverPackage UnresolvedPkgLoc
2190-
-> (ElaboratedConfiguredPackage, LogProgress ())
2185+
-> ElaboratedConfiguredPackage
21912186
elaborateSolverToCommon
21922187
pkg@( SolverPackage
21932188
(SourcePackage pkgid gdesc srcloc descOverride)
@@ -2196,7 +2191,7 @@ elaborateInstallPlan
21962191
deps0
21972192
_exe_deps0
21982193
) =
2199-
(elaboratedPackage, wayWarnings pkgid)
2194+
elaboratedPackage
22002195
where
22012196
elaboratedPackage = ElaboratedConfiguredPackage{..}
22022197

@@ -2304,7 +2299,7 @@ elaborateInstallPlan
23042299
elabBuildOptions =
23052300
LBC.BuildOptions
23062301
{ withVanillaLib = perPkgOptionFlag pkgid True packageConfigVanillaLib -- TODO: [required feature]: also needs to be handled recursively
2307-
, withSharedLib = canBuildSharedLibs && pkgid `Set.member` pkgsUseSharedLibrary
2302+
, withSharedLib = pkgid `Set.member` pkgsUseSharedLibrary
23082303
, withStaticLib = perPkgOptionFlag pkgid False packageConfigStaticLib
23092304
, withDynExe =
23102305
perPkgOptionFlag pkgid False packageConfigDynExe
@@ -2315,8 +2310,8 @@ elaborateInstallPlan
23152310
, withFullyStaticExe = perPkgOptionFlag pkgid False packageConfigFullyStaticExe
23162311
, withGHCiLib = perPkgOptionFlag pkgid False packageConfigGHCiLib -- TODO: [required feature] needs to default to enabled on windows still
23172312
, withProfExe = profExe
2318-
, withProfLib = canBuildProfilingLibs && pkgid `Set.member` pkgsUseProfilingLibrary
2319-
, withProfLibShared = canBuildProfilingSharedLibs && pkgid `Set.member` pkgsUseProfilingLibraryShared
2313+
, withProfLib = pkgid `Set.member` pkgsUseProfilingLibrary
2314+
, withProfLibShared = pkgid `Set.member` pkgsUseProfilingLibraryShared
23202315
, exeCoverage = perPkgOptionFlag pkgid False packageConfigCoverage
23212316
, libCoverage = perPkgOptionFlag pkgid False packageConfigCoverage
23222317
, withOptimization = perPkgOptionFlag pkgid NormalOptimisation packageConfigOptimization
@@ -2485,7 +2480,9 @@ elaborateInstallPlan
24852480

24862481
needsSharedLib pkgid =
24872482
fromMaybe
2488-
compilerShouldUseSharedLibByDefault
2483+
-- FIXME
2484+
-- compilerShouldUseSharedLibByDefault
2485+
False
24892486
-- Case 1: --enable-shared or --disable-shared is passed explicitly, honour that.
24902487
( case pkgSharedLib of
24912488
Just v -> Just v
@@ -2496,7 +2493,7 @@ elaborateInstallPlan
24962493
-- Case 3: If --enable-profiling is passed, then we are going to
24972494
-- build profiled dynamic, so no need for shared libraries.
24982495
case pkgProf of
2499-
Just True -> if canBuildProfilingSharedLibs then Nothing else Just True
2496+
Just True -> Nothing
25002497
_ -> Just True
25012498
-- But don't necessarily turn off shared library generation if
25022499
-- --disable-executable-dynamic is passed. The shared objects might
@@ -2508,53 +2505,12 @@ elaborateInstallPlan
25082505
pkgDynExe = perPkgOptionMaybe pkgid packageConfigDynExe
25092506
pkgProf = perPkgOptionMaybe pkgid packageConfigProf
25102507

2511-
-- TODO: [code cleanup] move this into the Cabal lib. It's currently open
2512-
-- coded in Distribution.Simple.Configure, but should be made a proper
2513-
-- function of the Compiler or CompilerInfo.
2514-
compilerShouldUseSharedLibByDefault =
2515-
case compilerFlavor compiler of
2516-
GHC -> GHC.compilerBuildWay compiler == DynWay && canBuildSharedLibs
2517-
GHCJS -> GHCJS.isDynamic compiler
2518-
_ -> False
2519-
2520-
compilerShouldUseProfilingLibByDefault =
2521-
case compilerFlavor compiler of
2522-
GHC -> GHC.compilerBuildWay compiler == ProfWay && canBuildProfilingLibs
2523-
_ -> False
2524-
2525-
compilerShouldUseProfilingSharedLibByDefault =
2526-
case compilerFlavor compiler of
2527-
GHC -> GHC.compilerBuildWay compiler == ProfDynWay && canBuildProfilingSharedLibs
2528-
_ -> False
2529-
2530-
-- Returns False if we definitely can't build shared libs
2531-
canBuildWayLibs predicate = case predicate compiler of
2532-
Just can_build -> can_build
2533-
-- If we don't know for certain, just assume we can
2534-
-- which matches behaviour in previous cabal releases
2535-
Nothing -> True
2536-
2537-
canBuildSharedLibs = canBuildWayLibs dynamicSupported
2538-
canBuildProfilingLibs = canBuildWayLibs profilingVanillaSupported
2539-
canBuildProfilingSharedLibs = canBuildWayLibs profilingDynamicSupported
2540-
2541-
wayWarnings pkg = do
2542-
when
2543-
(needsProfilingLib pkg && not canBuildProfilingLibs)
2544-
(warnProgress (text "Compiler does not support building p libraries, profiling is disabled"))
2545-
when
2546-
(needsSharedLib pkg && not canBuildSharedLibs)
2547-
(warnProgress (text "Compiler does not support building dyn libraries, dynamic libraries are disabled"))
2548-
when
2549-
(needsProfilingLibShared pkg && not canBuildProfilingSharedLibs)
2550-
(warnProgress (text "Compiler does not support building p_dyn libraries, profiling dynamic libraries are disabled."))
2551-
25522508
pkgsUseProfilingLibrary :: Set PackageId
25532509
pkgsUseProfilingLibrary =
25542510
packagesWithLibDepsDownwardClosedProperty needsProfilingLib
25552511

25562512
needsProfilingLib pkg =
2557-
fromFlagOrDefault compilerShouldUseProfilingLibByDefault (profBothFlag <> profLibFlag)
2513+
fromFlagOrDefault False (profBothFlag <> profLibFlag)
25582514
where
25592515
pkgid = packageId pkg
25602516
profBothFlag = lookupPerPkgOption pkgid packageConfigProf
@@ -2566,7 +2522,9 @@ elaborateInstallPlan
25662522

25672523
needsProfilingLibShared pkg =
25682524
fromMaybe
2569-
compilerShouldUseProfilingSharedLibByDefault
2525+
-- FIXME
2526+
-- compilerShouldUseProfilingSharedLibByDefault
2527+
False
25702528
-- case 1: If --enable-profiling-shared is passed explicitly, honour that
25712529
( case profLibSharedFlag of
25722530
Just v -> Just v
@@ -2575,7 +2533,7 @@ elaborateInstallPlan
25752533
case pkgProf of
25762534
-- case 2: --enable-executable-dynamic + --enable-profiling
25772535
-- turn on shared profiling libraries
2578-
Just True -> if canBuildProfilingSharedLibs then Just True else Nothing
2536+
Just True -> Just True
25792537
_ -> Nothing
25802538
-- But don't necessarily turn off shared library generation is
25812539
-- --disable-executable-dynamic is passed. The shared objects might

0 commit comments

Comments
 (0)