Skip to content

Commit 6a938d6

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 6a938d6

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
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: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2280,9 +2280,13 @@ elaborateInstallPlan
22802280
, withSharedLib = canBuildSharedLibs && pkgid `Set.member` pkgsUseSharedLibrary
22812281
, withStaticLib = perPkgOptionFlag pkgid False packageConfigStaticLib
22822282
, withDynExe = perPkgOptionFlag pkgid False packageConfigDynExe
2283+
&& (okProfDyn || not profExe)
2284+
-- We can't produce a dynamic executable if the user
2285+
-- wants to enable executable profiling but the
2286+
-- compiler doesn't support prof+dyn.
22832287
, withFullyStaticExe = perPkgOptionFlag pkgid False packageConfigFullyStaticExe
22842288
, withGHCiLib = perPkgOptionFlag pkgid False packageConfigGHCiLib -- TODO: [required feature] needs to default to enabled on windows still
2285-
, withProfExe = perPkgOptionFlag pkgid False packageConfigProf
2289+
, withProfExe = profExe
22862290
, withProfLib = canBuildProfilingLibs && pkgid `Set.member` pkgsUseProfilingLibrary
22872291
, withProfLibShared = canBuildProfilingSharedLibs && pkgid `Set.member` pkgsUseProfilingLibraryShared
22882292
, exeCoverage = perPkgOptionFlag pkgid False packageConfigCoverage
@@ -2297,6 +2301,8 @@ elaborateInstallPlan
22972301
, withProfLibDetail = elabProfExeDetail
22982302
, withProfExeDetail = elabProfLibDetail
22992303
}
2304+
okProfDyn = profilingDynamicSupportedOrUnknown compiler
2305+
profExe = perPkgOptionFlag pkgid False packageConfigProf
23002306

23012307
( elabProfExeDetail
23022308
, elabProfLibDetail

0 commit comments

Comments
 (0)