-
Notifications
You must be signed in to change notification settings - Fork 12.2k
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
libcxx: set LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS for system-libcxxabi on APPLE #77218
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write If you have received no comments on your PR for a week, you can request a review If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-libcxx Author: None (a-n-n-a-l-e-e) Changeswhen building with using the extra link flags that get added are: if (LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS)
target_link_libraries(cxx_shared PRIVATE
"-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/libc++unexp.exp"
"-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/libc++abi.exp"
"-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/notweak.exp"
"-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/weak.exp")
target_link_libraries(cxx_shared PRIVATE $<TARGET_NAME_IF_EXISTS:cxxabi-reexports>)
endif() and Full diff: https://github.com/llvm/llvm-project/pull/77218.diff 1 Files Affected:
diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt
index 329964a001363b..cdf0be87250df5 100644
--- a/libcxx/src/CMakeLists.txt
+++ b/libcxx/src/CMakeLists.txt
@@ -229,7 +229,7 @@ if (LIBCXX_ENABLE_SHARED)
# Maybe re-export symbols from libc++abi
# In particular, we don't re-export the symbols if libc++abi is merged statically
# into libc++ because in that case there's no dylib to re-export from.
- if (APPLE AND LIBCXX_CXX_ABI STREQUAL "libcxxabi"
+ if (APPLE AND LIBCXX_CXX_ABI MATCHES "libcxxabi$"
AND NOT DEFINED LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS
AND NOT LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
set(LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS ON)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this makes sense, good catch.
build failure seems unrelated as target was: Ubuntu clang version 18.0.0 (++20231120042147+3494c555c93c-1~exp1~20231120042257.1318)
Target: x86_64-pc-linux-gnu and not apple. |
Yeah, I am merging this since all the Apple testing passed. Thanks! |
This change applies the upstream PR llvm/llvm-project#77218 so the same link flags on darwin are used as when LIBCXX_CXX_ABI=libcxxabi. Specifically, this adds "-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/notweak.exp" which prevents libcxx from segfaulting on darwin
This change applies the upstream PR llvm/llvm-project#77218 so the same link flags on darwin are used as when LIBCXX_CXX_ABI=libcxxabi. Specifically, this adds "-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/notweak.exp" which prevents libcxx from segfaulting on darwin (cherry picked from commit 7b62547)
…stem-libcxxabi (llvm#77218) When using LIBCXX_CXX_ABI=system-libcxxabi on Apple platforms, we would not re-export the libc++abi symbols unlike when LIBCXX_CXX_ABI=libcxxabi. This was caused by overly strict string matching in CMake. NixOS/nixpkgs#269548
when building with using
system-libcxxabi
with an out of tree libcxxabi still need to link with the flags whenLIBCXX_CXX_ABI
is set tolibcxxabi
otherwiselibcxx
will segfault on older versions of macos, eg: big sur, when multiple libc++ libraries are linked, or one linked and other dlopened.the extra link flags that get added are:
and
"-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/notweak.exp"
is the one that prevents segfaults, as symbols will not be resolved from the wrong library.NixOS/nixpkgs#269548