Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Libs are compiled without -fPIC flag #47

Open
windoze opened this issue Jul 3, 2018 · 1 comment
Open

Libs are compiled without -fPIC flag #47

windoze opened this issue Jul 3, 2018 · 1 comment

Comments

@windoze
Copy link

windoze commented Jul 3, 2018

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

#include <stdio.h>
void f() { printf("hello\n"); }
$ /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
@ger-oss
Copy link

ger-oss commented Jul 23, 2018

I had the same issue. I found a solution here: http://www.openwall.com/lists/musl/2017/12/21/1

I simply added this line in my config.mak:
GCC_CONFIG += --enable-default-pie

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants