Ok, it seems I isolated the problem.
The linking error shows up only on FreeBSD with gcc toolchain installed, because it does not support pie. With clang everything is fine.
There is an issue with detection mechanism. Currently, it is done in configure script with:
gcc -std=gnu99 -o conftest -g -O2 -x c -fPIE -DPIE -D_THREAD_SAFE conftest.c -lintl
It succeeds, so the scripts enables PIE. However, all further binaries are built with additional "-pie" flag.
/bin/sh ../libtool --tag=CC --mode=link gcc -std=gnu99 <some_stuff...> -fPIE -DPIE -g <other_stuff...> -pie -o libvirt_iohelper util/libvirt_iohelper-iohelper.o
libvirt_util.la ../gnulib/lib/
libgnu.la -lintl
This one fails with
/usr/local/bin/ld: /usr/lib/crt1.o: relocation R_X86_64_32 against `_DYNAMIC' can not be used when making a shared object; recompile with -fPIC
/usr/lib/crt1.o: error adding symbols: Bad value
collect2: ld returned 1 exit status
If I modify configuration line to
gcc -std=gnu99 -o conftest -g -O2 -x c -fPIE -DPIE -pie -D_THREAD_SAFE conftest.c -lintl
then it correctly detects lack of pie and build succeeds.
configure:61033: checking whether C compiler handles -fPIE -DPIE
configure:61052: gcc -std=gnu99 -o conftest -g -O2 -pie -fPIE -DPIE -D_THREAD_SAFE conftest.c -lintl >&5
/usr/local/bin/ld: /usr/lib/crt1.o: relocation R_X86_64_32 against `_DYNAMIC' can not be used when making a shared object; recompile with -fPIC
/usr/lib/crt1.o: error adding symbols: Bad value
collect2: ld returned 1 exit status
configure:61052: $? = 1
Do you think it would be reasonable to add "-pie" to configure script?
Regards,
Wojtek