Skip to content

Commit 73e09ec

Browse files
authored
Merge pull request #3953 from 23Skidoo/backport-3873
Backport #3873 to the 1.24 branch
2 parents bc8e704 + f539007 commit 73e09ec

File tree

4 files changed

+39
-16
lines changed

4 files changed

+39
-16
lines changed

Cabal/Distribution/Simple/Configure.hs

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ module Distribution.Simple.Configure (configure,
4242
getPackageDBContents,
4343
configCompiler, configCompilerAux,
4444
configCompilerEx, configCompilerAuxEx,
45+
computeEffectiveProfiling,
4546
ccLdOptionsBuildInfo,
4647
checkForeignDeps,
4748
interpretPackageDbFlags,
@@ -310,6 +311,29 @@ findDistPrefOrDefault :: Setup.Flag FilePath -- ^ override \"dist\" prefix
310311
-> IO FilePath
311312
findDistPrefOrDefault = findDistPref defaultDistPref
312313

314+
-- | Compute the effective value of the profiling flags
315+
-- @--enable-library-profiling@ and @--enable-executable-profiling@
316+
-- from the specified 'ConfigFlags'. This may be useful for
317+
-- external Cabal tools which need to interact with Setup in
318+
-- a backwards-compatible way: the most predictable mechanism
319+
-- for enabling profiling across many legacy versions is to
320+
-- NOT use @--enable-profiling@ and use those two flags instead.
321+
--
322+
-- Note that @--enable-executable-profiling@ also affects profiling
323+
-- of benchmarks and (non-detailed) test suites.
324+
computeEffectiveProfiling :: ConfigFlags -> (Bool {- lib -}, Bool {- exe -})
325+
computeEffectiveProfiling cfg =
326+
-- The --profiling flag sets the default for both libs and exes,
327+
-- but can be overidden by --library-profiling, or the old deprecated
328+
-- --executable-profiling flag.
329+
--
330+
-- The --profiling-detail and --library-profiling-detail flags behave
331+
-- similarly
332+
let profEnabledBoth = fromFlagOrDefault False (configProf cfg)
333+
profEnabledLib = fromFlagOrDefault profEnabledBoth (configProfLib cfg)
334+
profEnabledExe = fromFlagOrDefault profEnabledBoth (configProfExe cfg)
335+
in (profEnabledLib, profEnabledExe)
336+
313337
-- |Perform the \"@.\/setup configure@\" action.
314338
-- Returns the @.setup-config@ file.
315339
configure :: (GenericPackageDescription, HookedBuildInfo)
@@ -578,16 +602,8 @@ configure (pkg_descr0', pbi) cfg = do
578602
++ "is not being built. Linking will fail if any executables "
579603
++ "depend on the library."
580604

581-
-- The --profiling flag sets the default for both libs and exes,
582-
-- but can be overidden by --library-profiling, or the old deprecated
583-
-- --executable-profiling flag.
584-
let profEnabledLibOnly = configProfLib cfg
585-
profEnabledBoth = fromFlagOrDefault False (configProf cfg)
586-
profEnabledLib = fromFlagOrDefault profEnabledBoth profEnabledLibOnly
587-
profEnabledExe = fromFlagOrDefault profEnabledBoth (configProfExe cfg)
605+
let (profEnabledLib, profEnabledExe) = computeEffectiveProfiling cfg
588606

589-
-- The --profiling-detail and --library-profiling-detail flags behave
590-
-- similarly
591607
profDetailLibOnly <- checkProfDetail (configProfLibDetail cfg)
592608
profDetailBoth <- liftM (fromFlagOrDefault ProfDetailDefault)
593609
(checkProfDetail (configProfDetail cfg))

cabal-install/Distribution/Client/Setup.hs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ import Distribution.Simple.Program
7373
( defaultProgramConfiguration )
7474
import Distribution.Simple.Command hiding (boolOpt, boolOpt')
7575
import qualified Distribution.Simple.Command as Command
76+
import Distribution.Simple.Configure ( computeEffectiveProfiling )
7677
import qualified Distribution.Simple.Setup as Cabal
7778
import Distribution.Simple.Setup
7879
( ConfigFlags(..), BuildFlags(..), ReplFlags
@@ -363,6 +364,7 @@ filterConfigureFlags flags cabalLibVersion
363364
| cabalLibVersion < Version [1,23,0] [] = flags_1_22_0
364365
| otherwise = flags_latest
365366
where
367+
(profEnabledLib, profEnabledExe) = computeEffectiveProfiling flags
366368
flags_latest = flags {
367369
-- Cabal >= 1.19.1 uses '--dependency' and does not need '--constraint'.
368370
configConstraints = [],
@@ -372,21 +374,24 @@ filterConfigureFlags flags cabalLibVersion
372374
}
373375

374376
-- Cabal < 1.23 doesn't know about '--profiling-detail'.
377+
-- Cabal < 1.23 has a hacked up version of 'enable-profiling'
378+
-- which we shouldn't use.
375379
flags_1_22_0 = flags_latest { configProfDetail = NoFlag
376380
, configProfLibDetail = NoFlag
377-
, configIPID = NoFlag }
381+
, configIPID = NoFlag
382+
, configProf = NoFlag
383+
, configProfExe = Flag profEnabledExe
384+
, configProfLib = Flag profEnabledLib
385+
}
378386

379387
-- Cabal < 1.22 doesn't know about '--disable-debug-info'.
380388
flags_1_21_0 = flags_1_22_0 { configDebugInfo = NoFlag }
381389

382390
-- Cabal < 1.21.1 doesn't know about 'disable-relocatable'
383391
-- Cabal < 1.21.1 doesn't know about 'enable-profiling'
392+
-- (but we already dealt with it in flags_1_22_0)
384393
flags_1_20_0 =
385394
flags_1_21_0 { configRelocatable = NoFlag
386-
, configProf = NoFlag
387-
, configProfExe = configProf flags
388-
, configProfLib =
389-
mappend (configProf flags) (configProfLib flags)
390395
, configCoverage = NoFlag
391396
, configLibCoverage = configCoverage flags
392397
}

cabal-install/cabal-install.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Name: cabal-install
2-
Version: 1.24.0.0
2+
Version: 1.24.0.1
33
Synopsis: The command-line interface for Cabal and Hackage.
44
Description:
55
The \'cabal\' command-line program simplifies the process of managing

cabal-install/changelog

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
-*-change-log-*-
2-
1.24.0.1 Ryan Thomas <[email protected]> June 2016
2+
1.24.0.1 Ryan Thomas <[email protected]> October 2016
3+
* Fixed issue with passing '--enable-profiling' when invoking
4+
Setup scripts built with older versions of Cabal (#3873).
35
* Fixed various behaviour differences between network transports
46
(#3429).
57
* Updated to depend on the latest hackage-security that fixes

0 commit comments

Comments
 (0)