renamed GMP symbols in GHC

Simon Marlow marlowsd at gmail.com
Thu Jan 5 15:37:17 CET 2012


On 04/01/2012 21:00, Joachim Breitner wrote:
> Hi,
>
> 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.
>>
>> So, I propose to revert to renaming the symbols in the source code
>> which could probably be done automatically using a lot of CPP
>> #defines, starting from some sort of source code tar ball of gmp. This
>> would also allow to always use the latest gmp sources without too much
>> hassle.
>
> Just to more random ideas that can probably easily dismissed by more
> knowledgeable people:
>
> Would linking gmp statically help? E.g. is there a way to link libgmp
> into the RTS that the symbols are not visible to the linker any more?

Linking a static copy of GMP into the integer-gmp package is an 
interesting idea that I hadn't considered before.  It ought to be 
possible, but I haven't played around with it.  You would probably have 
to resolve all the symbols between the integer-gmp code and GMP itself 
when building the library, and don't expose any GMP symbols in the 
resulting .a file.  That might mean making a big .o file containing GMP 
and the integer-gmp code that refers to it.

I expect there would be problems with shared libraries though.  You 
can't link the static GMP into the shared integer-gmp, because the 
static GMP isn't built with -fPIC.

> And would dlopen make a difference? RTLD_LOCAL sounds interesting...

Maybe, I haven't looked into that.

Cheers,
	Simon


>
> Greetings,
> Joachim
>
>
>
>
>
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users




More information about the Glasgow-haskell-users mailing list