From 37205ba11b0972e36eb320c1a086bf574f654feb Mon Sep 17 00:00:00 2001 From: sheaf Date: Wed, 18 Jun 2025 12:52:37 +0200 Subject: [PATCH] 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. --- Cabal/src/Distribution/Simple/Compiler.hs | 12 +++++++----- .../src/Distribution/Client/ProjectPlanning.hs | 11 +++++++++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Cabal/src/Distribution/Simple/Compiler.hs b/Cabal/src/Distribution/Simple/Compiler.hs index 346c4c82125..6c81b50f891 100644 --- a/Cabal/src/Distribution/Simple/Compiler.hs +++ b/Cabal/src/Distribution/Simple/Compiler.hs @@ -509,11 +509,13 @@ profilingVanillaSupported comp = waySupported "p" comp -- | Is the compiler distributed with profiling dynamic libraries profilingDynamicSupported :: Compiler -> Maybe Bool -profilingDynamicSupported comp = - -- Certainly not before this version, as it was not implemented yet. - if compilerVersion comp <= mkVersion [9, 11, 0] - then Just False - else waySupported "p_dyn" comp +profilingDynamicSupported comp + | GHC <- compilerFlavor comp + , -- Certainly not before 9.11, as prof+dyn was not implemented yet. + compilerVersion comp <= mkVersion [9, 11, 0] = + Just False + | otherwise = + waySupported "p_dyn" comp -- | Either profiling dynamic is definitely supported or we don't know (so assume -- it is) diff --git a/cabal-install/src/Distribution/Client/ProjectPlanning.hs b/cabal-install/src/Distribution/Client/ProjectPlanning.hs index f6b27eafca2..fbd4f758d67 100644 --- a/cabal-install/src/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/src/Distribution/Client/ProjectPlanning.hs @@ -2316,10 +2316,15 @@ elaborateInstallPlan { withVanillaLib = perPkgOptionFlag pkgid True packageConfigVanillaLib -- TODO: [required feature]: also needs to be handled recursively , withSharedLib = canBuildSharedLibs && pkgid `Set.member` pkgsUseSharedLibrary , withStaticLib = perPkgOptionFlag pkgid False packageConfigStaticLib - , withDynExe = perPkgOptionFlag pkgid False packageConfigDynExe + , withDynExe = + perPkgOptionFlag pkgid False packageConfigDynExe + -- We can't produce a dynamic executable if the user + -- wants to enable executable profiling but the + -- compiler doesn't support prof+dyn. + && (okProfDyn || not profExe) , withFullyStaticExe = perPkgOptionFlag pkgid False packageConfigFullyStaticExe , withGHCiLib = perPkgOptionFlag pkgid False packageConfigGHCiLib -- TODO: [required feature] needs to default to enabled on windows still - , withProfExe = perPkgOptionFlag pkgid False packageConfigProf + , withProfExe = profExe , withProfLib = canBuildProfilingLibs && pkgid `Set.member` pkgsUseProfilingLibrary , withProfLibShared = canBuildProfilingSharedLibs && pkgid `Set.member` pkgsUseProfilingLibraryShared , exeCoverage = perPkgOptionFlag pkgid False packageConfigCoverage @@ -2334,6 +2339,8 @@ elaborateInstallPlan , withProfLibDetail = elabProfExeDetail , withProfExeDetail = elabProfLibDetail } + okProfDyn = profilingDynamicSupportedOrUnknown compiler + profExe = perPkgOptionFlag pkgid False packageConfigProf ( elabProfExeDetail , elabProfLibDetail