how do I force PIC code in libgmp.a on MacOSX (Intel)...?

Alex Martelli aleaxit at gmail.com
Mon Apr 17 03:47:34 CEST 2006


I'm struggling to build gmpy (http://gmpy.sf.net) with GMP 4.2 on my  
new Mac-Intel (MacOSX 10.4.6, gcc 4.0.1 etc, Python 2.4.3). Ideally  
I'd like a "Universal" build (a fat binary with support for both PPC  
and intel processors), but that's a dream for the future; for now,  
I'd be reasonably glad just to get the thing working at all.  
Unfortunately, I'm most definitely NOT an expert of libtools and  
friends, so getting the configuration right is proving very hard for me.

Right now, I'm blocked at the following problem:

brain:~/alex/gmpy alex$ python setup.py build_ext -i
running build_ext
building 'gmpy' extension
gcc -bundle -undefined dynamic_lookup build/temp.darwin-8.6.1- 
i386-2.4/src/gmpy.o -lgmp -o gmpy.so
/usr/bin/ld: /usr/local/lib/libgmp.a(add_n.o) has local relocation  
entries in non-writable section (__TEXT,__text)
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1

i.e., Python's distutils are trying to link gmpy.so as a "bundle" --  
but, failing because add_n.o in libgmp.a (and no doubt other entries  
in it) are not PIC.  There are many discussions on the web about this  
error message about "local relocation entries in non-writable  
section", but apparently they all boil down to a wretched option "- 
mdynamic-no-pic" which is implied by other options (such as -fast).   
I've grepped through libtools in gmp 4.2 rather uselessly; I've hand- 
edited all makefiles to try to force -fPIC; no go.

Does anybody have suggestions on how I should go about making  
libgmp.a suitable for building a .so bundle (i.e., PIC) in this  
environment?


TIA,

Alex



More information about the gmp-bugs mailing list