[libcxx-commits] [PATCH] D79904: [libcxx][libcxxabi] Link against libdl on Android
Shoaib Meenai via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed May 13 13:36:26 PDT 2020
smeenai created this revision.
smeenai added reviewers: danalbert, enh, ldionne, phosek, rprichard, srhines.
Herald added subscribers: libcxx-commits, dexonsmith, kristof.beyls, aprantl, mgorny.
Herald added projects: libc++, libc++abi.
Herald added a reviewer: libc++.
Herald added a reviewer: libc++abi.
smeenai added a comment.
This is a follow-up to D78787 <https://reviews.llvm.org/D78787>. I'd only tested that one with armv7, so I didn't notice this earlier.
(To be more precise, I'd tested the other architectures, but with an inadvertent config change which meant this issue wasn't exposed.)
libgcc's DWARF unwinder (used for all Android targets except armv7) uses
dl_iterate_phdr, so we need to link against libdl to make the link
succeed. The driver ordinarily injects libdl for you, but we prevent the
driver's default library additions so we have to add it ourselves.
Ideally the libgcc linker script in the NDK would be adjusted to add the
libdl link, but until we have an NDK with that change, work around it in
the libc++ and libc++abi build systems.
Note that LIBCXXABI_HAS_DL_LIB was defined but previously unused, so I'm
just repurposing it. libunwind already links against libdl so no changes
are needed there.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D79904
Files:
libcxx/CMakeLists.txt
libcxx/cmake/config-ix.cmake
libcxxabi/cmake/config-ix.cmake
libcxxabi/src/CMakeLists.txt
Index: libcxxabi/src/CMakeLists.txt
===================================================================
--- libcxxabi/src/CMakeLists.txt
+++ libcxxabi/src/CMakeLists.txt
@@ -105,6 +105,7 @@
if (NOT LIBCXXABI_USE_COMPILER_RT)
add_library_flags_if(LIBCXXABI_HAS_GCC_LIB gcc)
+ add_library_flags_if(LIBCXXABI_HAS_DL_LIB dl)
endif ()
# Setup flags.
Index: libcxxabi/cmake/config-ix.cmake
===================================================================
--- libcxxabi/cmake/config-ix.cmake
+++ libcxxabi/cmake/config-ix.cmake
@@ -8,6 +8,8 @@
if (NOT LIBCXXABI_USE_COMPILER_RT)
if (ANDROID)
check_library_exists(gcc __gcc_personality_v0 "" LIBCXXABI_HAS_GCC_LIB)
+ # Needed by the static libgcc unwinder
+ check_library_exists(dl dl_iterate_phdr "" LIBCXXABI_HAS_DL_LIB)
else ()
check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXXABI_HAS_GCC_S_LIB)
check_library_exists(gcc __aeabi_uldivmod "" LIBCXXABI_HAS_GCC_LIB)
@@ -76,13 +78,11 @@
# Check libraries
if(FUCHSIA)
- set(LIBCXXABI_HAS_DL_LIB NO)
set(LIBCXXABI_HAS_PTHREAD_LIB NO)
check_library_exists(c __cxa_thread_atexit_impl ""
LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL)
set(LIBCXXABI_HAS_SYSTEM_LIB NO)
else()
- check_library_exists(dl dladdr "" LIBCXXABI_HAS_DL_LIB)
check_library_exists(pthread pthread_once "" LIBCXXABI_HAS_PTHREAD_LIB)
check_library_exists(c __cxa_thread_atexit_impl ""
LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL)
Index: libcxx/cmake/config-ix.cmake
===================================================================
--- libcxx/cmake/config-ix.cmake
+++ libcxx/cmake/config-ix.cmake
@@ -18,6 +18,8 @@
else()
if(ANDROID)
check_library_exists(gcc __gcc_personality_v0 "" LIBCXX_HAS_GCC_LIB)
+ # Needed by the static libgcc unwinder
+ check_library_exists(dl dl_iterate_phdr "" LIBCXX_HAS_DL_LIB)
else()
check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXX_HAS_GCC_S_LIB)
endif()
Index: libcxx/CMakeLists.txt
===================================================================
--- libcxx/CMakeLists.txt
+++ libcxx/CMakeLists.txt
@@ -759,6 +759,9 @@
endif()
elseif (LIBCXX_HAS_GCC_LIB)
target_link_libraries(${target} PRIVATE gcc)
+ if (LIBCXX_HAS_DL_LIB)
+ target_link_libraries(${target} PRIVATE dl)
+ endif ()
elseif (LIBCXX_HAS_GCC_S_LIB)
target_link_libraries(${target} PRIVATE gcc_s)
endif()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79904.263837.patch
Type: text/x-patch
Size: 2417 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200513/ef9fc9eb/attachment-0001.bin>
More information about the libcxx-commits
mailing list