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

need to build static libs with -fPIC for making a shared object #11

Open
HinTak opened this issue Apr 17, 2020 · 6 comments
Open

need to build static libs with -fPIC for making a shared object #11

HinTak opened this issue Apr 17, 2020 · 6 comments

Comments

@HinTak
Copy link

HinTak commented Apr 17, 2020

This happens during osxcross build, but I assume it should be filed here:

[100%] Linking CXX shared library ../../../../lib/libtapi.so
/usr/bin/ld: ../../../../lib/libLLVMSupport.a(regcomp.c.o): relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: ../../../../lib/libLLVMSupport.a(regerror.c.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile
 with -fPIC
/usr/bin/ld: ../../../../lib/libLLVMSupport.a(regexec.c.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -
fPIC
/usr/bin/ld: final link failed: nonrepresentable section on output
clang-9: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [projects/libtapi/tools/libtapi/CMakeFiles/libtapi.dir/build.make:157: lib/libtapi.so.6.0.1] Error 1

I suppose there are two answers to this - add -fPIC to the building of libLLVMSupport.a (this I did), or disable the building of shared libtapi.so and make sure the rest works with a static libtapi.a

@tpoechtrager
Copy link
Owner

What OS are you on and what compiler do you use?

@HinTak
Copy link
Author

HinTak commented Apr 17, 2020

That would be clang-9 on x86_64 linux . I have seen the "relocation R_X86_64_32S ... when making a shared object, recompile using -fPIC" in the past. PIC (position-independent code) for everything (including bits from a consistuting static object archive) that goes into a shared library seems quite reasonable?

@tpoechtrager
Copy link
Owner

Arch Linux I suppose? File a pull request please.

@HinTak
Copy link
Author

HinTak commented Apr 17, 2020

Fedora, actually. That Arch Linux patch is interesting - I came across those // ... lines while looking for something else (or maybe this), but never looked any further as they look like c++ comments. I guess llvm/clang must be abusing the c++ comment system and put "functional" comments there.

Anyway, I'll have a better look at that change, and if it is adaptable to fedora in a simple way, I'll make a pull.

@kiufta
Copy link

kiufta commented Sep 6, 2022

Have you found a solution?

[100%] Linking CXX shared library ../../../../lib/libtapi.so
/usr/bin/ld: ../../../../lib/libLLVMSupport.a(PrettyStackTrace.cpp.o): relocation R_X86_64_TPOFF32 against `_ZL20PrettyStackTraceHead' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: failed to set dynamic section sizes: bad value

@HinTak
Copy link
Author

HinTak commented Sep 6, 2022

Sorry haven't revisited this, but apparently I "...add -fPIC to the building of libLLVMSupport.a (this I did).."

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

3 participants