Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 922202 - sys-libs/libcxx, sys-libs/libcxxabi: Cannot build shared library with clang++ -stdlib=libc++ -static-libstdc++ (build them as PIC?)
Summary: sys-libs/libcxx, sys-libs/libcxxabi: Cannot build shared library with clang++...
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: LLVM support project
URL:
Whiteboard:
Keywords:
: 918946 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-01-16 08:55 UTC by fallunar
Modified: 2024-01-26 19:44 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
source code (t1.cpp,103 bytes, text/x-c++src)
2024-01-16 08:55 UTC, fallunar
Details

Note You need to log in before you can comment on or make changes to this bug.
Description fallunar 2024-01-16 08:55:37 UTC
Created attachment 882395 [details]
source code

clang++-17 -o t1.so -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. ***