Well, the detection code is too simple:Il 09/12/2013 13:47, Don Slutz ha scritto:On 12/05/13 22:20, Don Slutz wrote:On 12/05/13 16:24, Richard Henderson wrote:On 12/06/2013 04:18 AM, Paolo Bonzini wrote:$ gcc -shared -o f.so f.c -fPIE -fPIC /usr/bin/ld: /tmp/ccQc9els.o: relocation R_X86_64_PC32 against `f' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Bad value collect2: ld returned 1 exit status The bug is simply that "-fPIE -fPIC" counts as -fPIE rather than -fPIC: $ gcc -S -o - f.c -fPIE |grep call call f # PC32 relocation $ gcc -S -o - f.c -fPIC |grep call call f@PLT # PLT32 relocationThe easy workaround is to drop -fPIE when we're adding -fPIC. r~[snip] Attached is a much better version. It drops -fPIE and adds -fPIC for libtool.It's not much better, because using position-independent code for shared libraries is really platform-dependent knowledge of the kind that libtool is supposed to hide. For example, on Mac OS X everything is position-independent by default. And on some platforms you have -fpic instead of -fPIC. So I prefer the patch you had that disabled libtool if the platform is buggy. Paolo
dcs-xen-52:~/tmp/libtool>uname -aCentOS 5.10:
Linux dcs-xen-52 3.8.11-100.fc17.x86_64 #1 SMP Wed May 1 19:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
dcs-xen-52:~/tmp/libtool>gcc -shared -fPIE -DPIE f.c -fPIC -DPIC -o f.so
/usr/bin/ld: /tmp/ccl4By1r.o: relocation R_X86_64_PC32 against symbol `f' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
dcs-xen-52:~/tmp/libtool>libtool --mode=compile gcc -g -c -fPIE -DPIE f.c
libtool: compile: gcc -g -c -DPIE f.c -fPIC -DPIC -o .libs/f.o
libtool: compile: gcc -g -c -DPIE f.c -fPIE -o f.o >/dev/null 2>&1
dcs-xen-52:~/tmp/libtool>libtool --mode=link gcc -g -o libf.la f.lo -rpath /usr/local/lib
libtool: link: gcc -shared -fPIC -DPIC .libs/f.o -Wl,-soname -Wl,libf.so.0 -o .libs/libf.so.0.0.0
libtool: link: (cd ".libs" && rm -f "libf.so.0" && ln -s "libf.so.0.0.0" "libf.so.0")
libtool: link: (cd ".libs" && rm -f "libf.so" && ln -s "libf.so.0.0.0" "libf.so")
libtool: link: ar cru .libs/libf.a f.o
libtool: link: ranlib .libs/libf.a
libtool: link: ( cd ".libs" && rm -f "libf.la" && ln -s "../libf.la" "libf.la" )
dcs-xen-53:~/tmp/libtool>uname -aI have attached a patch that uses libtool to determine if gcc & libtool is broken.
Linux dcs-xen-53 2.6.18-371.el5xen #1 SMP Tue Oct 1 09:15:30 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux
dcs-xen-53:~/tmp/libtool>gcc -shared -fPIE -DPIE f.c -fPIC -DPIC -o f.so
/usr/bin/ld: /tmp/ccAy1vZK.o: relocation R_X86_64_PC32 against `f' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
dcs-xen-53:~/tmp/libtool>libtool --mode=compile gcc -g -c -fPIE -DPIE f.c
mkdir .libs
gcc -g -c -fPIE -DPIE f.c -fPIC -DPIC -o .libs/f.o
gcc -g -c -fPIE -DPIE f.c -o f.o >/dev/null 2>&1
dcs-xen-53:~/tmp/libtool>libtool --mode=link gcc -g -o libf.la f.lo -rpath /usr/local/lib
gcc -shared .libs/f.o -Wl,-soname -Wl,libf.so.0 -o .libs/libf.so.0.0.0
/usr/bin/ld: .libs/f.o: relocation R_X86_64_PC32 against `f' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status