Skip to content

Commit

Permalink
Fix use of deprecated cabal flag (fixes #2350)
Browse files Browse the repository at this point in the history
From cabal 1.21.1 onwards, the flag --enable-profiling is preferred over
--enable-executable-profiling. Cabal emits a warning when using the
latter flag which also happens to be visible to the user, possibly
causing confusion as to whether the warning is due to stack or because
of misconfiguration.

You can reproduce this bug by running stack build --profile or an
equivalent command.

This commit fixes this by using --enable-profiling for cabal 1.21.1
or later.

This fixes #2350.
  • Loading branch information
hesiod committed Jul 15, 2016
1 parent 17cbd64 commit 9a19fc6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Stack/Types/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ isStackOpt t = any (`T.isPrefixOf` t)
, "--enable-benchmarks"
, "--enable-library-profiling"
, "--enable-executable-profiling"
, "--enable-profiling"
, "--exact-configuration"
] || elem t
[ "--user"
Expand Down Expand Up @@ -617,7 +618,9 @@ configureOptsNoDir :: EnvConfig
configureOptsNoDir econfig bco deps isLocal package = concat
[ depOptions
, ["--enable-library-profiling" | boptsLibProfile bopts || boptsExeProfile bopts]
, ["--enable-executable-profiling" | boptsExeProfile bopts && isLocal]
-- Cabal < 1.21.1 does not support --enable-profiling, use --enable-executable-profiling instead
, let profFlag = "--enable-" <> (if newerProfFlagCabal then "" else "executable-") <> "profiling"
in [ profFlag | boptsExeProfile bopts && isLocal]
, ["--enable-split-objs" | boptsSplitObjs bopts]
, map (\(name,enabled) ->
"-f" <>
Expand All @@ -644,7 +647,9 @@ configureOptsNoDir econfig bco deps isLocal package = concat
-- earlier. Cabal also might do less work then.
useExactConf = configAllowNewer config

newerCabal = envConfigCabalVersion econfig >= $(mkVersion "1.22")
cabalVersion = envConfigCabalVersion econfig
newerCabal = cabalVersion >= $(mkVersion "1.22")
newerProfFlagCabal = cabalVersion >= $(mkVersion "1.21.1")

-- Unioning atop defaults is needed so that all flags are specified
-- with --exact-configuration.
Expand Down

0 comments on commit 9a19fc6

Please sign in to comment.