Skip to content

Commit 041d8cc

Browse files
committed
refactor: remove wayWarnings and other checks
1. We want to let the user take control and we have no issue with GHC failing later on. 2. These checks depend on the compiler which now can change within the build graph. If they have to exist they will exist in a different way.
1 parent 85b8c8c commit 041d8cc

File tree

1 file changed

+37
-97
lines changed

1 file changed

+37
-97
lines changed

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

Lines changed: 37 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ import Distribution.Simple.LocalBuildInfo
179179
, pkgComponents
180180
)
181181

182-
import Distribution.Simple.BuildWay
183182
import Distribution.Simple.PackageIndex (InstalledPackageIndex)
184183
import Distribution.Simple.Program
185184
import Distribution.Simple.Program.Db
@@ -215,8 +214,6 @@ import qualified Distribution.InstalledPackageInfo as IPI
215214
import qualified Distribution.PackageDescription as PD
216215
import qualified Distribution.PackageDescription.Configuration as PD
217216
import qualified Distribution.Simple.Configure as Cabal
218-
import qualified Distribution.Simple.GHC as GHC
219-
import qualified Distribution.Simple.GHCJS as GHCJS
220217
import qualified Distribution.Simple.InstallDirs as InstallDirs
221218
import qualified Distribution.Simple.LocalBuildInfo as Cabal
222219
import qualified Distribution.Simple.Setup as Cabal
@@ -1677,8 +1674,7 @@ elaborateInstallPlan
16771674
(map fst src_comps)
16781675
let whyNotPerComp = why_not_per_component src_comps
16791676
case NE.nonEmpty whyNotPerComp of
1680-
Nothing -> do
1681-
elaborationWarnings
1677+
Nothing ->
16821678
return comps
16831679
Just notPerCompReasons -> do
16841680
checkPerPackageOk comps notPerCompReasons
@@ -1751,7 +1747,7 @@ elaborateInstallPlan
17511747
<+> fsep (punctuate comma $ map (text . whyNotPerComponent) $ toList reasons)
17521748
-- TODO: Maybe exclude Backpack too
17531749

1754-
(elab0, elaborationWarnings) = elaborateSolverToCommon spkg
1750+
elab0 = elaborateSolverToCommon spkg
17551751
pkgid = elabPkgSourceId elab0
17561752
pd = elabPkgDescription elab0
17571753

@@ -2062,10 +2058,9 @@ elaborateInstallPlan
20622058
-- Knot tying: the final elab includes the
20632059
-- pkgInstalledId, which is calculated by hashing many
20642060
-- of the other fields of the elaboratedPackage.
2065-
elaborationWarnings
20662061
return elab
20672062
where
2068-
(elab0@ElaboratedConfiguredPackage{..}, elaborationWarnings) =
2063+
elab0@ElaboratedConfiguredPackage{..} =
20692064
elaborateSolverToCommon pkg
20702065

20712066
elab1 =
@@ -2151,7 +2146,7 @@ elaborateInstallPlan
21512146

21522147
elaborateSolverToCommon
21532148
:: SolverPackage UnresolvedPkgLoc
2154-
-> (ElaboratedConfiguredPackage, LogProgress ())
2149+
-> ElaboratedConfiguredPackage
21552150
elaborateSolverToCommon
21562151
pkg@( SolverPackage
21572152
(SourcePackage pkgid gdesc srcloc descOverride)
@@ -2160,7 +2155,7 @@ elaborateInstallPlan
21602155
deps0
21612156
_exe_deps0
21622157
) =
2163-
(elaboratedPackage, wayWarnings pkgid)
2158+
elaboratedPackage
21642159
where
21652160
elaboratedPackage = ElaboratedConfiguredPackage{..}
21662161

@@ -2268,14 +2263,14 @@ elaborateInstallPlan
22682263
elabBuildOptions =
22692264
LBC.BuildOptions
22702265
{ withVanillaLib = perPkgOptionFlag pkgid True packageConfigVanillaLib -- TODO: [required feature]: also needs to be handled recursively
2271-
, withSharedLib = canBuildSharedLibs && pkgid `Set.member` pkgsUseSharedLibrary
2266+
, withSharedLib = pkgid `Set.member` pkgsUseSharedLibrary
22722267
, withStaticLib = perPkgOptionFlag pkgid False packageConfigStaticLib
22732268
, withDynExe = perPkgOptionFlag pkgid False packageConfigDynExe
22742269
, withFullyStaticExe = perPkgOptionFlag pkgid False packageConfigFullyStaticExe
22752270
, withGHCiLib = perPkgOptionFlag pkgid False packageConfigGHCiLib -- TODO: [required feature] needs to default to enabled on windows still
22762271
, withProfExe = perPkgOptionFlag pkgid False packageConfigProf
2277-
, withProfLib = canBuildProfilingLibs && pkgid `Set.member` pkgsUseProfilingLibrary
2278-
, withProfLibShared = canBuildProfilingSharedLibs && pkgid `Set.member` pkgsUseProfilingLibraryShared
2272+
, withProfLib = pkgid `Set.member` pkgsUseProfilingLibrary
2273+
, withProfLibShared = pkgid `Set.member` pkgsUseProfilingLibraryShared
22792274
, exeCoverage = perPkgOptionFlag pkgid False packageConfigCoverage
22802275
, libCoverage = perPkgOptionFlag pkgid False packageConfigCoverage
22812276
, withOptimization = perPkgOptionFlag pkgid NormalOptimisation packageConfigOptimization
@@ -2437,77 +2432,29 @@ elaborateInstallPlan
24372432
packagesWithLibDepsDownwardClosedProperty needsSharedLib
24382433

24392434
needsSharedLib pkgid =
2440-
fromMaybe
2441-
compilerShouldUseSharedLibByDefault
2442-
-- Case 1: --enable-shared or --disable-shared is passed explicitly, honour that.
2443-
( case pkgSharedLib of
2444-
Just v -> Just v
2445-
Nothing -> case pkgDynExe of
2446-
-- case 2: If --enable-executable-dynamic is passed then turn on
2447-
-- shared library generation.
2448-
Just True ->
2449-
-- Case 3: If --enable-profiling is passed, then we are going to
2450-
-- build profiled dynamic, so no need for shared libraries.
2451-
case pkgProf of
2452-
Just True -> if canBuildProfilingSharedLibs then Nothing else Just True
2453-
_ -> Just True
2454-
-- But don't necessarily turn off shared library generation if
2455-
-- --disable-executable-dynamic is passed. The shared objects might
2456-
-- be needed for something different.
2457-
_ -> Nothing
2458-
)
2459-
where
2460-
pkgSharedLib = perPkgOptionMaybe pkgid packageConfigSharedLib
2461-
pkgDynExe = perPkgOptionMaybe pkgid packageConfigDynExe
2462-
pkgProf = perPkgOptionMaybe pkgid packageConfigProf
2463-
2464-
-- TODO: [code cleanup] move this into the Cabal lib. It's currently open
2465-
-- coded in Distribution.Simple.Configure, but should be made a proper
2466-
-- function of the Compiler or CompilerInfo.
2467-
compilerShouldUseSharedLibByDefault =
2468-
case compilerFlavor compiler of
2469-
GHC -> GHC.compilerBuildWay compiler == DynWay && canBuildSharedLibs
2470-
GHCJS -> GHCJS.isDynamic compiler
2471-
_ -> False
2472-
2473-
compilerShouldUseProfilingLibByDefault =
2474-
case compilerFlavor compiler of
2475-
GHC -> GHC.compilerBuildWay compiler == ProfWay && canBuildProfilingLibs
2476-
_ -> False
2477-
2478-
compilerShouldUseProfilingSharedLibByDefault =
2479-
case compilerFlavor compiler of
2480-
GHC -> GHC.compilerBuildWay compiler == ProfDynWay && canBuildProfilingSharedLibs
2481-
_ -> False
2482-
2483-
-- Returns False if we definitely can't build shared libs
2484-
canBuildWayLibs predicate = case predicate compiler of
2485-
Just can_build -> can_build
2486-
-- If we don't know for certain, just assume we can
2487-
-- which matches behaviour in previous cabal releases
2488-
Nothing -> True
2489-
2490-
canBuildSharedLibs = canBuildWayLibs dynamicSupported
2491-
canBuildProfilingLibs = canBuildWayLibs profilingVanillaSupported
2492-
canBuildProfilingSharedLibs = canBuildWayLibs profilingDynamicSupported
2493-
2494-
wayWarnings pkg = do
2495-
when
2496-
(needsProfilingLib pkg && not canBuildProfilingLibs)
2497-
(warnProgress (text "Compiler does not support building p libraries, profiling is disabled"))
2498-
when
2499-
(needsSharedLib pkg && not canBuildSharedLibs)
2500-
(warnProgress (text "Compiler does not support building dyn libraries, dynamic libraries are disabled"))
2501-
when
2502-
(needsProfilingLibShared pkg && not canBuildProfilingSharedLibs)
2503-
(warnProgress (text "Compiler does not support building p_dyn libraries, profiling dynamic libraries are disabled."))
2435+
fromFlagOrDefault False (case1 <> case2)
2436+
where
2437+
-- Case 1: --enable-shared or --disable-shared is passed explicitly, honour that.
2438+
case1 = pkgSharedLib
2439+
-- Case 2: --enable-executable-dynamic + --enable-profiling
2440+
-- turn on shared profiling libraries
2441+
case2 = case (pkgDynExe, pkgProf) of
2442+
(Flag True, Flag True) -> Flag True
2443+
_ -> NoFlag
2444+
-- FIXME
2445+
-- Case 3: If --enable-profiling is passed, then we are going to
2446+
-- build profiled dynamic, so no need for shared libraries.
2447+
2448+
pkgSharedLib = lookupPerPkgOption pkgid packageConfigSharedLib
2449+
pkgDynExe = lookupPerPkgOption pkgid packageConfigDynExe
2450+
pkgProf = lookupPerPkgOption pkgid packageConfigProf
25042451

25052452
pkgsUseProfilingLibrary :: Set PackageId
25062453
pkgsUseProfilingLibrary =
25072454
packagesWithLibDepsDownwardClosedProperty needsProfilingLib
25082455

25092456
needsProfilingLib pkg =
2510-
fromFlagOrDefault compilerShouldUseProfilingLibByDefault (profBothFlag <> profLibFlag)
2457+
fromFlagOrDefault False (profBothFlag <> profLibFlag)
25112458
where
25122459
pkgid = packageId pkg
25132460
profBothFlag = lookupPerPkgOption pkgid packageConfigProf
@@ -2518,28 +2465,21 @@ elaborateInstallPlan
25182465
packagesWithLibDepsDownwardClosedProperty needsProfilingLibShared
25192466

25202467
needsProfilingLibShared pkg =
2521-
fromMaybe
2522-
compilerShouldUseProfilingSharedLibByDefault
2468+
fromFlagOrDefault False $
25232469
-- case 1: If --enable-profiling-shared is passed explicitly, honour that
2524-
( case profLibSharedFlag of
2525-
Just v -> Just v
2526-
Nothing -> case pkgDynExe of
2527-
Just True ->
2528-
case pkgProf of
2529-
-- case 2: --enable-executable-dynamic + --enable-profiling
2530-
-- turn on shared profiling libraries
2531-
Just True -> if canBuildProfilingSharedLibs then Just True else Nothing
2532-
_ -> Nothing
2533-
-- But don't necessarily turn off shared library generation is
2534-
-- --disable-executable-dynamic is passed. The shared objects might
2535-
-- be needed for something different.
2536-
_ -> Nothing
2537-
)
2470+
case profLibSharedFlag of
2471+
Flag True -> Flag True
2472+
_ ->
2473+
-- case 2: --enable-executable-dynamic + --enable-profiling
2474+
-- turn on shared profiling libraries
2475+
case pkgDynExe <> pkgProf of
2476+
Flag True -> Flag True
2477+
_ -> NoFlag
25382478
where
25392479
pkgid = packageId pkg
2540-
profLibSharedFlag = perPkgOptionMaybe pkgid packageConfigProfShared
2541-
pkgDynExe = perPkgOptionMaybe pkgid packageConfigDynExe
2542-
pkgProf = perPkgOptionMaybe pkgid packageConfigProf
2480+
profLibSharedFlag = lookupPerPkgOption pkgid packageConfigProfShared
2481+
pkgDynExe = lookupPerPkgOption pkgid packageConfigDynExe
2482+
pkgProf = lookupPerPkgOption pkgid packageConfigProf
25432483

25442484
-- TODO: [code cleanup] unused: the old deprecated packageConfigProfExe
25452485

0 commit comments

Comments
 (0)