Skip to content

Commit

Permalink
Rewrite logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mpickering committed May 22, 2024
1 parent 01a1939 commit c1f27fe
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions Cabal/src/Distribution/Simple/Configure.hs
Original file line number Diff line number Diff line change
Expand Up @@ -754,11 +754,6 @@ computeLocalBuildConfig cfg comp programDb = do

withFullyStaticExe_ = fromFlag $ configFullyStaticExe cfg

when (withDynExe_ && not withSharedLib_) $
warn verbosity $
"Executables will use dynamic linking, but a shared library "
++ "is not being built. Linking will fail if any executables "
++ "depend on the library."

setProfiling <- configureProfiling verbosity cfg comp

Expand Down Expand Up @@ -808,6 +803,20 @@ computeLocalBuildConfig cfg comp programDb = do
, relocatable = fromFlagOrDefault False $ configRelocatable cfg
}

-- Dynamic executable, but no shared vanilla libararies
when (LBC.withDynExe buildOptions && not (LBC.withProfExe buildOptions) && not (LBC.withSharedLib buildOptions)) $
warn verbosity $
"Executables will use dynamic linking, but a shared library "
++ "is not being built. Linking will fail if any executables "
++ "depend on the library."

-- Profiled dynamic executable, but no shared vanilla libararies
when (LBC.withDynExe buildOptions && LBC.withProfExe buildOptions && not (LBC.withProfLibShared buildOptions)) $
warn verbosity $
"Executables will use profiled dynamic linking, but a profiled shared library "
++ "is not being built. Linking will fail if any executables "
++ "depend on the library."

return $
LBC.LocalBuildConfig
{ extraConfigArgs = [] -- Currently configure does not
Expand Down Expand Up @@ -1805,12 +1814,15 @@ configureProfiling verbosity cfg comp = do
}
let compilerSupportsProfilingDynamic = profilingDynamicSupported comp
apply2 <-
if tryLibProfilingShared && compilerSupportsProfilingDynamic
then return $ \buildOptions -> apply buildOptions { LBC.withProfLibShared = True }
if compilerSupportsProfilingDynamic
-- Case 1: We support profiled shared libraries so turn on shared profiling
-- libraries if the user asked for it.
then return $ \buildOptions -> apply buildOptions { LBC.withProfLibShared = tryLibProfilingShared }
-- Case 2: Compiler doesn't support profiling shared so turn them off
else do
if (tryLibProfilingShared && not compilerSupportsProfilingDynamic)
then do
warn verbosity ( "The compiler "
-- If we wanted to enable profilng shared libraries.. tell the
-- user we couldn't.
when tryLibProfilingShared $ warn verbosity ( "The compiler "
++ showCompilerId comp
++ " does not support "
++ "profiling shared objects. Static profiled objects "
Expand All @@ -1819,10 +1831,8 @@ configureProfiling verbosity cfg comp = do
return $ \buildOptions ->
let original_options = apply buildOptions
in original_options { LBC.withProfLibShared = False
, LBC.withProfLib = True
, LBC.withProfLib = tryLibProfilingShared || LBC.withProfLib original_options
, LBC.withDynExe = if LBC.withProfExe original_options then False else LBC.withDynExe original_options }
else
return apply
return (tryExeProfiling && not (tryLibProfiling || tryLibProfilingShared) , apply2)
else do
let apply buildOptions =
Expand Down

0 comments on commit c1f27fe

Please sign in to comment.