
Here's something I just stumbled upon by accident: at least on Linux, GHC emits huge numbers of symbols into the binaries it generates. Here's Haddock, which I compiled without any funny debug options: $ du -h haddock-0.9 4.1M haddock-0.9 $ nm haddock-0.9 | wc -l 37938 $ strip haddock-0.9 $ du -h haddock-0.9 2.7M haddock-0.9 I happened upon this because I'm repackaging GHC 6.8.3 for Fedora, and rpmlint complained that haddock was not stripped. The RPM packager automatically strips binaries using "strip -g", but that wasn't stripping any of the abovementioned symbols. I don't know what the purpose of those symbols might be. Could someone fill me in, please? Can they actually be used for anything?

Bryan O'Sullivan wrote:
Here's something I just stumbled upon by accident: at least on Linux, GHC emits huge numbers of symbols into the binaries it generates. Here's Haddock, which I compiled without any funny debug options:
$ du -h haddock-0.9 4.1M haddock-0.9 $ nm haddock-0.9 | wc -l 37938 $ strip haddock-0.9 $ du -h haddock-0.9 2.7M haddock-0.9
I happened upon this because I'm repackaging GHC 6.8.3 for Fedora, and rpmlint complained that haddock was not stripped. The RPM packager automatically strips binaries using "strip -g", but that wasn't stripping any of the abovementioned symbols.
I don't know what the purpose of those symbols might be. Could someone fill me in, please? Can they actually be used for anything?
We didn't put them there on purpose, if that's what you're asking :) These are just the symbols that get left in by the linker by default. gdb and things like valgrind can use them, but they're not a lot of use in general. There tend to be a lot of local symbols left around too, which are of even less use. At one time I used to strip these out when making libraries, but it was tricky and non-portable, so I think we stopped doing it. Cheers, Simon

On Tue, 2008-06-17 at 16:16 -0700, Bryan O'Sullivan wrote:
Here's something I just stumbled upon by accident: at least on Linux, GHC emits huge numbers of symbols into the binaries it generates. Here's Haddock, which I compiled without any funny debug options:
$ du -h haddock-0.9 4.1M haddock-0.9 $ nm haddock-0.9 | wc -l 37938 $ strip haddock-0.9 $ du -h haddock-0.9 2.7M haddock-0.9
I happened upon this because I'm repackaging GHC 6.8.3 for Fedora, and rpmlint complained that haddock was not stripped. The RPM packager automatically strips binaries using "strip -g", but that wasn't stripping any of the abovementioned symbols.
According to man strip, the -g flag means only strip debugging symbols. But ghc doesn't generate any debugging symbols (and ghc does not pass -g to gcc so nor does gcc). So it seems to me that it's not surprising that you still get all the symbols. What is a surprise is that rpm only uses strip -g when rpmlint seems to expect normal strip.
I don't know what the purpose of those symbols might be. Could someone fill me in, please? Can they actually be used for anything?
I don't think they're used for anything. Cabal-1.4 now strips executables by default upon installation (distros that want to do the strip themselves can disable this). Duncan
participants (3)
-
Bryan O'Sullivan
-
Duncan Coutts
-
Simon Marlow