You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After compilation I found generated libs were not compiled with -fPIC flag and I don't know where to add it.
The problem is, without the flag, it's not possible to build SOs using any function from any lib, which is necessary for many project, i.e. LLVM. Even the toolchain itself doesn't use or generate any SO, but still we need it to support the usage.
A small test:
$ /opt/cross/bin/x86_64-linux-musl-gcc -shared a.c -o liba.so
/opt/cross/bin/../lib/gcc/x86_64-linux-musl/6.4.0/../../../../x86_64-linux-musl/bin/ld: /tmp/ccCNRLay.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/opt/cross/bin/../lib/gcc/x86_64-linux-musl/6.4.0/../../../../x86_64-linux-musl/bin/ld: /opt/cross/bin/../lib/gcc/x86_64-linux-musl/6.4.0/../../../../x86_64-linux-musl/lib/libc.a(__stdout_write.o): relocation R_X86_64_32S against symbol `__stdio_write' can not be used when making a shared object; recompile with -fPIC
/opt/cross/bin/../lib/gcc/x86_64-linux-musl/6.4.0/../../../../x86_64-linux-musl/bin/ld: /opt/cross/bin/../lib/gcc/x86_64-linux-musl/6.4.0/../../../../x86_64-linux-musl/lib/libc.a(ofl.o): relocation R_X86_64_32 against `.bss.ofl_lock' can not be used when making a shared object; recompile with -fPIC
/opt/cross/bin/../lib/gcc/x86_64-linux-musl/6.4.0/../../../../x86_64-linux-musl/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
The text was updated successfully, but these errors were encountered:
After compilation I found generated libs were not compiled with
-fPIC
flag and I don't know where to add it.The problem is, without the flag, it's not possible to build SOs using any function from any lib, which is necessary for many project, i.e. LLVM. Even the toolchain itself doesn't use or generate any SO, but still we need it to support the usage.
A small test:
a.c
The text was updated successfully, but these errors were encountered: