Skip to content

Commit

Permalink
Make debug-info >= 1 imply library/executable-stripping: False
Browse files Browse the repository at this point in the history
Fixes haskell#2702

If you enable `debug-info` then you also have to stop the libraries and
executables being stripped as otherwise the debug symbols are removed.
  • Loading branch information
mpickering authored and 23Skidoo committed Aug 9, 2019
1 parent 7ecb9ec commit b408d16
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Cabal/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
add default implementation in terms of `coerce` / `unsafeCoerce`.
* Implement support for response file arguments to defaultMain* and cabal-install.
* Uniformly provide 'Semigroup' instances for `base < 4.9` via `semigroups` package
* Setting `debug-info` now implies `library-stripping: False` and
`executable-stripping: False) ([#2702](https://github.com/haskell/cabal/issues/2702))

----

Expand Down
25 changes: 23 additions & 2 deletions Cabal/Distribution/Simple/Configure.hs
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,27 @@ configure (pkg_descr0, pbi) cfg = do

setCoverageLBI <- configureCoverage verbosity cfg comp



-- Turn off library and executable stripping when `debug-info` is set
-- to anything other than zero.
let
strip_libexe s f =
let defaultStrip = fromFlagOrDefault True (f cfg)
in case fromFlag (configDebugInfo cfg) of
NoDebugInfo -> return defaultStrip
_ -> case f cfg of
Flag True -> do
warn verbosity $ "Setting debug-info implies "
++ s ++ "-stripping: False"
return False

_ -> return False

strip_lib <- strip_libexe "library" configStripLibs
strip_exe <- strip_libexe "executable" configStripExes


let reloc = fromFlagOrDefault False $ configRelocatable cfg

let buildComponentsMap =
Expand Down Expand Up @@ -747,8 +768,8 @@ configure (pkg_descr0, pbi) cfg = do
configGHCiLib cfg,
splitSections = split_sections,
splitObjs = split_objs,
stripExes = fromFlag $ configStripExes cfg,
stripLibs = fromFlag $ configStripLibs cfg,
stripExes = strip_exe,
stripLibs = strip_lib,
exeCoverage = False,
libCoverage = False,
withPackageDB = packageDbs,
Expand Down
4 changes: 2 additions & 2 deletions Cabal/Distribution/Simple/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ defaultConfigFlags progDb = emptyConfigFlags {
#endif
configSplitSections = Flag False,
configSplitObjs = Flag False, -- takes longer, so turn off by default
configStripExes = Flag True,
configStripLibs = Flag True,
configStripExes = NoFlag,
configStripLibs = NoFlag,
configTests = Flag False,
configBenchmarks = Flag False,
configCoverage = Flag False,
Expand Down
6 changes: 5 additions & 1 deletion Cabal/doc/nix-local-build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,8 @@ Object code options
Not all Haskell implementations generate native binaries. For such
implementations this option has no effect.

(TODO: Check what happens if you combine this with ``debug-info``.)
If ``debug-info`` is set explicitly then ``executable-stripping`` is set
to ``False`` as otherwise all the debug symbols will be stripped.

The command line variant of this flag is
``--enable-executable-stripping`` and
Expand All @@ -1440,6 +1441,9 @@ Object code options
binary, saving space on the file system. See also
``executable-stripping``.

If ``debug-info`` is set explicitly then ``library-stripping`` is set
to ``False`` as otherwise all the debug symbols will be stripped.

The command line variant of this flag is
``--enable-library-stripping`` and ``--disable-library-stripping``.

Expand Down

0 comments on commit b408d16

Please sign in to comment.