Skip to content

Commit e238448

Browse files
committed
cabal-install: dynExe+profExe requires prof+dyn
This commit updates the logic in cabal-install's 'elaborateInstallPlan' function to ensure that we don't try to build a profiled dynamic executable if the compiler doesn't support the profiling dynamic way. This brings the logic in cabal-install in sync with the Cabal 'configureProfiling' function, which sets 'withDynExe' to false if the user wants a profiled executable but prof+dyn is not supported by the compiler.
1 parent 01217ac commit e238448

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

Cabal/src/Distribution/Simple/Compiler.hs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -509,11 +509,13 @@ profilingVanillaSupported comp = waySupported "p" comp
509509

510510
-- | Is the compiler distributed with profiling dynamic libraries
511511
profilingDynamicSupported :: Compiler -> Maybe Bool
512-
profilingDynamicSupported comp =
513-
-- Certainly not before this version, as it was not implemented yet.
514-
if compilerVersion comp <= mkVersion [9, 11, 0]
515-
then Just False
516-
else waySupported "p_dyn" comp
512+
profilingDynamicSupported comp
513+
| GHC <- compilerFlavor comp
514+
, -- Certainly not before 9.11, as prof+dyn was not implemented yet.
515+
compilerVersion comp <= mkVersion [9, 11, 0] =
516+
Just False
517+
| otherwise =
518+
waySupported "p_dyn" comp
517519

518520
-- | Either profiling dynamic is definitely supported or we don't know (so assume
519521
-- it is)

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2279,10 +2279,15 @@ elaborateInstallPlan
22792279
{ withVanillaLib = perPkgOptionFlag pkgid True packageConfigVanillaLib -- TODO: [required feature]: also needs to be handled recursively
22802280
, withSharedLib = canBuildSharedLibs && pkgid `Set.member` pkgsUseSharedLibrary
22812281
, withStaticLib = perPkgOptionFlag pkgid False packageConfigStaticLib
2282-
, withDynExe = perPkgOptionFlag pkgid False packageConfigDynExe
2283-
, withFullyStaticExe = perPkgOptionFlag pkgid False packageConfigFullyStaticExe
2282+
, withDynExe =
2283+
perPkgOptionFlag pkgid False packageConfigDynExe
2284+
&& (okProfDyn || not profExe)
2285+
, -- We can't produce a dynamic executable if the user
2286+
-- wants to enable executable profiling but the
2287+
-- compiler doesn't support prof+dyn.
2288+
withFullyStaticExe = perPkgOptionFlag pkgid False packageConfigFullyStaticExe
22842289
, withGHCiLib = perPkgOptionFlag pkgid False packageConfigGHCiLib -- TODO: [required feature] needs to default to enabled on windows still
2285-
, withProfExe = perPkgOptionFlag pkgid False packageConfigProf
2290+
, withProfExe = profExe
22862291
, withProfLib = canBuildProfilingLibs && pkgid `Set.member` pkgsUseProfilingLibrary
22872292
, withProfLibShared = canBuildProfilingSharedLibs && pkgid `Set.member` pkgsUseProfilingLibraryShared
22882293
, exeCoverage = perPkgOptionFlag pkgid False packageConfigCoverage
@@ -2297,6 +2302,8 @@ elaborateInstallPlan
22972302
, withProfLibDetail = elabProfExeDetail
22982303
, withProfExeDetail = elabProfLibDetail
22992304
}
2305+
okProfDyn = profilingDynamicSupportedOrUnknown compiler
2306+
profExe = perPkgOptionFlag pkgid False packageConfigProf
23002307

23012308
( elabProfExeDetail
23022309
, elabProfLibDetail

0 commit comments

Comments
 (0)