Can't link libbz2 static library into a shared library
An issue was observed linking libbz2_static.a into a shared library.
[ 82%] Linking C shared library libclamav.so
/usr/bin/ld: /home/micah/.mussels/install/host-static/lib/libbz2_static.a(bzlib.c.o): relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' 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
make[2]: *** [libclamav/CMakeFiles/clamav.dir/build.make:2146: libclamav/libclamav.so.12.0.1] Error 1
make[1]: *** [CMakeFiles/Makefile2:1602: libclamav/CMakeFiles/clamav.dir/all] Error 2
make: *** [Makefile:163: all] Error 2
This is because libbz2_static.a is no longer being compiled with -fPIC
.
The issue was introduced with this commit bf5f505d from !43 (merged)
I believe the correct thing to do is to revert this change and then make a new option to disable POSITION_INDEPENDENT_CODE
like maybe "DISABLE_PIC" and make it default-off. This way there will still be an option for @fjtrujy's use-case where it's not possible to generate position-independent code for ‘-mabi=eabi’.
The reason why I believe PIC should be enabled by default is to make sure that libbz2.a provided by distributions in the future can still be linked into shared libraries.
Edited by Micah