Description of problem: Attempts of linking a shared library with libc++ fails with lots of errors like this: ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol '__cxa_unexpected_handler'; recompile with -fPIC >>> defined in /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../lib64/libc++.a(cxa_default_handlers.cpp.o) >>> referenced by cxa_default_handlers.cpp.o:(std::set_unexpected(void (*)())) in archive /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../lib64/libc++.a Version-Release number of selected component (if applicable): libcxxabi-15.0.7-1.fc37.x86_64 libcxx-15.0.7-1.fc37.x86_64 libcxxabi-devel-15.0.7-1.fc37.x86_64 libcxx-devel-15.0.7-1.fc37.x86_64 libcxxabi-static-15.0.7-1.fc37.x86_64 libcxx-static-15.0.7-1.fc37.x86_64 How reproducible: Always Additional info: Earlier these library were built with -fPIC unconditionally, but now they require passing -DCMAKE_POSITION_INDEPENDENT_CODE=ON on build. See more details at https://reviews.llvm.org/rGa6e5563dfaff0cb7147058b9c49e38b611a28fb1 I managed to fix this issue by adding -DCMAKE_POSITION_INDEPENDENT_CODE=ON to libcxxabi.spec: %cmake -GNinja \ -DCMAKE_C_COMPILER=/usr/bin/clang \ -DCMAKE_CXX_COMPILER=/usr/bin/clang++ \ -DCMAKE_MODULE_PATH=%{_libdir}/cmake/llvm \ -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ -DLIBCXXABI_LIBCXX_INCLUDES=%{_includedir}/c++/v1/ \ %if 0%{?__isa_bits} == 64 -DLIBCXXABI_LIBDIR_SUFFIX:STRING=64 \ %endif -DCMAKE_BUILD_TYPE=RelWithDebInfo and to libcxx.spec: # Build the static libc++.a. # We include the libc++abi symbols. %cmake -GNinja \ $common_cmake_flags \ -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ -DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=OFF \ -DLIBCXX_ENABLE_STATIC=ON \ -DLIBCXX_ENABLE_SHARED=OFF \ -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON \ -DLIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY=ON \ -DLIBCXX_CXX_ABI_LIBRARY_PATH=%{_libdir} and rebuilding libcxxabi and libcxx. Please include this fix upstream.
@osamarin68 , I tried to reproduce this issue without success. I took a look at the build logs and I confirmed that -fPIC is being used. Could you provide a reproducer for this issue, please?
Running this script ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- cat >TestShared.cpp <<EOF #include <exception> extern void test_shared() { std::get_terminate(); } EOF clang++ -fPIC -o TestShared.cpp.o -c TestShared.cpp clang++ -fuse-ld=lld -nostdlib++ -Wl,-Bstatic -lc++ -lc++abi -Wl,-Bdynamic -stdlib=libc++ -shared -o libtest-shared.so TestShared.cpp.o ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- raises lots of linking errors.
After installing libcxxabi-static and libcxx-static built with -DCMAKE_POSITION_INDEPENDENT_CODE=ON, the shared library libtest-shared.so can be linked without errors.
Thank you, Oleg! I was able to reproduce the issue now. libcxx rebuilds some files provided by libcxxabi. Part of these files are specifically built under cxxabi_static_objects.dir. This group of files is not being built with -fPIC.
FEDORA-2023-67a2776b08 has been submitted as an update to Fedora 39. https://bodhi.fedoraproject.org/updates/FEDORA-2023-67a2776b08
FEDORA-2023-67a2776b08 has been pushed to the Fedora 39 stable repository. If problem still persists, please make note of it in this bug report.
FEDORA-2023-fac2a3fb5f has been submitted as an update to Fedora 38. https://bodhi.fedoraproject.org/updates/FEDORA-2023-fac2a3fb5f
FEDORA-2023-fac2a3fb5f has been pushed to the Fedora 38 testing repository. Soon you'll be able to install the update with the following command: `sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-fac2a3fb5f` You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-fac2a3fb5f See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.
FEDORA-2023-fac2a3fb5f has been pushed to the Fedora 38 stable repository. If problem still persists, please make note of it in this bug report.
FEDORA-2023-8640c2d9be has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2023-8640c2d9be
FEDORA-2023-8640c2d9be has been pushed to the Fedora 37 testing repository. Soon you'll be able to install the update with the following command: `sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-8640c2d9be` You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-8640c2d9be See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.
FEDORA-2023-8640c2d9be has been pushed to the Fedora 37 stable repository. If problem still persists, please make note of it in this bug report.
@tuliom I found out that the issue is still present and reproducible. This makes the libc++_shared_static.cpp test from the integration testsuite to fail. It can be reproduced by following the instuctions in comment 2. Could you please take a look into this? Thanks!
Confirmed. This is only affecting Fedora 37. Both Fedora 38 and Rawhide are working well. libc++ will require a rebuild. I'm working on it.
FEDORA-2023-e4957281af has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2023-e4957281af
FEDORA-2023-e4957281af has been pushed to the Fedora 37 testing repository. Soon you'll be able to install the update with the following command: `sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-e4957281af` You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-e4957281af See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.
FEDORA-2023-e4957281af has been pushed to the Fedora 37 stable repository. If problem still persists, please make note of it in this bug report.