Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 922202

Summary: sys-libs/libcxx, sys-libs/libcxxabi: Cannot build shared library with clang++ -stdlib=libc++ -static-libstdc++ (build them as PIC?)
Product: Gentoo Linux Reporter: fallunar
Component: Current packagesAssignee: LLVM support project <llvm>
Status: CONFIRMED ---    
Severity: normal CC: sam, toralf
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Package list:
Runtime testing required: ---
Attachments: source code

Description fallunar 2024-01-16 08:55:37 UTC
Created attachment 882395 [details]
source code

clang++-17 -o -shared -stdlib=libc++ -static-libstdc++ t1.cpp
fails with

/usr/bin/x86_64-pc-linux-gnu-ld.bfd: /usr/lib/gcc/x86_64-pc-linux-gnu/11/../../../../lib64/libc++abi.a(stdlib_typeinfo.cpp.o): warning: relocation against `_ZTVSt8bad_cast' in read-only section `.text._ZNSt8bad_castC2Ev'
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: /usr/lib/gcc/x86_64-pc-linux-gnu/11/../../../../lib64/libc++abi.a(private_typeinfo.cpp.o): relocation R_X86_64_PC32 against symbol `_ZTIN10__cxxabiv116__shim_type_infoE' can not be used when making a shared object; recompile with -fPIC
/usr/bin/x86_64-pc-linux-gnu-ld.bfd: final link failed: bad value
clang++-17: error: linker command failed with exit code 1 (use -v to see invocation)

Apparently, static libcxx and libcxxabi are built without -fPIC. Omitting either -stdlib=libc++ or -static-libstdc++ makes the problem go away, but I need both.
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-01-26 19:42:39 UTC
*** Bug 918946 has been marked as a duplicate of this bug. ***