From 2a11e3635619015987aa464ccf6ca47c16650b87 Mon Sep 17 00:00:00 2001 From: Mikhail Glushenkov <mikhail.glushenkov@gmail.com> Date: Thu, 27 Jun 2019 19:32:30 +0100 Subject: [PATCH] Merge pull request #6111 from mpickering/debug-info Make `debug-info` >= 1 imply library/executable-stripping: False (cherry picked from commit ed3ae1332ca7ef4d1d09b6da6494a44f3e40f5a8) --- Cabal/ChangeLog.md | 2 ++ Cabal/Distribution/Simple/Configure.hs | 25 +++++++++++++++++++++++-- Cabal/Distribution/Simple/Setup.hs | 4 ++-- Cabal/doc/nix-local-build.rst | 6 +++++- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/Cabal/ChangeLog.md b/Cabal/ChangeLog.md index 54678e6761..5c8287f72c 100644 --- a/Cabal/ChangeLog.md +++ b/Cabal/ChangeLog.md @@ -34,6 +34,8 @@ * Uniformly provide 'Semigroup' instances for `base < 4.9` via `semigroups` package * Implement `{cmm,asm}-{sources,options} buildinfo fields for separate compilation of C-- and ASM source files (#6033). + * Setting `debug-info` now implies `library-stripping: False` and + `executable-stripping: False) ([#2702](https://github.com/haskell/cabal/issues/2702)) ---- diff --git a/Cabal/Distribution/Simple/Configure.hs b/Cabal/Distribution/Simple/Configure.hs index e0fee661d2..4039a078ff 100644 --- a/Cabal/Distribution/Simple/Configure.hs +++ b/Cabal/Distribution/Simple/Configure.hs @@ -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, diff --git a/Cabal/Distribution/Simple/Setup.hs b/Cabal/Distribution/Simple/Setup.hs index 1dc0e10af2..3d1096b155 100644 --- a/Cabal/Distribution/Simple/Setup.hs +++ b/Cabal/Distribution/Simple/Setup.hs @@ -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, diff --git a/Cabal/doc/nix-local-build.rst b/Cabal/doc/nix-local-build.rst index bf8f9db589..a4733b2883 100644 --- a/Cabal/doc/nix-local-build.rst +++ b/Cabal/doc/nix-local-build.rst @@ -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``. -- GitLab