renamed GMP symbols in GHC

Joachim Breitner nomeata at
Thu Jan 5 19:53:42 CET 2012


Am Mittwoch, den 04.01.2012, 20:50 +0100 schrieb Axel Simon:
> On 04.01.2012, at 17:50, Joachim Breitner wrote:
> > BTW, Is there a way to get the linker to create two independent copies
> > of a library in one program space? Maybe if it is compiled as PIC
> > (random name dropping here)? That would seem to be an elegant solution,
> > as it makes the distro packers happy and you would not have to maintain
> > a code copy.
> In the past, I've linked a C++ library that used gmpxx against a
> Haskell program by renaming all symbols starting with gmp to mygmp
> using objcopy. Unfortunately, this is not portable and completely
> broke down on Mac OS when Apple moved to fat binaries (Intel and
> PowerPC) since their objcopy version was crippled (there doesn't even
> seem to be an objcopy anymore on later OS X versions). Thus, renaming
> symbols after compilation is non-portable and sometimes not possible
> without writing your own tool.

let me pick up this idea again. It was pointed out that it is mostly
Linux and BSD based distributions that dislike code copies. For these,
the objcopy-way might work. It does not work on MacOS, but that target
does not have the code copy requirements.. So would it be possible to
      * use objcopy at GHC build-time to take the system libgmp shared
        library, rename the symbols, and install the modified library
        with ghc on architectures that support it,
      * have a code copy for those who don’t?

For the distros this has the nice effect that if there is a bugfix in
libgmp, they just have to rebuild ghc without any changes to the sources
to benefit from it.

(But I am really wondering why the linker cannot do something that has
the same effect as objcopy --prefix-symbols, but on the fly.)


Joachim "nomeata" Breitner
Debian Developer
  nomeata at | ICQ# 74513189 | GPG-Keyid: 4743206C
  JID: nomeata at |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <>

More information about the Glasgow-haskell-users mailing list