~fgaz/cabal

ffd45c505803742cff5bf22b8dbfadf874be1cd9 — Matthew Pickering 1 year, 1 month ago c241917
Make `debug-info` >= 1 imply library/executable-stripping: False

Fixes #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.
M Cabal/ChangeLog.md => Cabal/ChangeLog.md +2 -0
@@ 26,6 26,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))

----


M Cabal/Distribution/Simple/Configure.hs => Cabal/Distribution/Simple/Configure.hs +23 -2
@@ 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 =


@@ 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,

M Cabal/Distribution/Simple/Setup.hs => Cabal/Distribution/Simple/Setup.hs +2 -2
@@ 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,

M Cabal/doc/nix-local-build.rst => Cabal/doc/nix-local-build.rst +5 -1
@@ 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


@@ 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``.