[PATCH] D60750: [libc++][CMake] Clean up logic for choosing which unwinder lib to link with tests
Tom Stellard via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 15 21:15:31 PDT 2019
tstellar created this revision.
tstellar added reviewers: mstorsjo, ldionne, phosek.
Herald added subscribers: libcxx-commits, dexonsmith, christof, mgorny.
Herald added a reviewer: EricWF.
Herald added a project: libc++.
The main functional change in this patch is that when
LIBCXXABI_USE_LLVM_UNWINDER and LIBCXX_ENABLE_ABI_LINKER_SCRIPT are both
enabled, -lgcc_s and -lgcc will no longer be added to the linker flags
for the test suite.
In this case, linking against libgcc is unnecessary, because the linker
script adds -lunwind.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D60750
Files:
libcxx/test/CMakeLists.txt
libcxx/test/lit.site.cfg.in
libcxx/utils/libcxx/test/target_info.py
Index: libcxx/utils/libcxx/test/target_info.py
===================================================================
--- libcxx/utils/libcxx/test/target_info.py
+++ libcxx/utils/libcxx/test/target_info.py
@@ -233,19 +233,25 @@
enable_threads = ('libcpp-has-no-threads' not in
self.full_config.config.available_features)
llvm_unwinder = self.full_config.get_lit_bool('llvm_unwinder', False)
+ libcxx_is_linker_script = self.full_config.get_lit_bool('libcxx_is_linker_script', False)
shared_libcxx = self.full_config.get_lit_bool('enable_shared', True)
flags += ['-lm']
- if not llvm_unwinder:
- flags += ['-lgcc_s', '-lgcc']
if enable_threads:
flags += ['-lpthread']
if not shared_libcxx:
flags += ['-lrt']
flags += ['-lc']
- if llvm_unwinder:
+ if llvm_unwinder and not libcxx_is_linker_script:
+ # FIXME: Why does llvm unwinder need -ldl?
flags += ['-lunwind', '-ldl']
- else:
- flags += ['-lgcc_s']
+ elif not llvm_unwinder:
+ # If we aren't using llvm unwinder, then fallback to using libgcc's
+ # unwind implementation.
+ # FIXME: Why is -lgcc needed for the unwinder?
+ flags += ['-lgcc_s', '-lgcc']
+ # If we are using a linker script and llvm_unwinder is eanbled, then we
+ # don't need to explicitly link against -lunwind, since the linker
+ # script will take care of that for us.
builtins_lib = self.full_config.get_lit_conf('builtins_library')
if builtins_lib:
flags += [builtins_lib]
Index: libcxx/test/lit.site.cfg.in
===================================================================
--- libcxx/test/lit.site.cfg.in
+++ libcxx/test/lit.site.cfg.in
@@ -27,6 +27,7 @@
config.executor = "@LIBCXX_EXECUTOR@"
config.llvm_unwinder = @LIBCXXABI_USE_LLVM_UNWINDER@
+config.libcxx_is_linker_script = @LIBCXX_ENABLE_ABI_LINKER_SCRIPT@
config.builtins_library = "@LIBCXX_BUILTINS_LIBRARY@"
config.has_libatomic = @LIBCXX_HAS_ATOMIC_LIB@
config.use_libatomic = @LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB@
Index: libcxx/test/CMakeLists.txt
===================================================================
--- libcxx/test/CMakeLists.txt
+++ libcxx/test/CMakeLists.txt
@@ -20,12 +20,6 @@
set(LIBCXX_CXX_ABI_LIBNAME "none")
endif()
-# The tests shouldn't link to libunwind if we have a linker script which
-# already does so.
-if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
- set(LIBCXXABI_USE_LLVM_UNWINDER OFF)
-endif()
-
pythonize_bool(LIBCXX_ENABLE_EXCEPTIONS)
pythonize_bool(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
pythonize_bool(LIBCXX_ENABLE_RTTI)
@@ -35,6 +29,7 @@
pythonize_bool(LIBCXX_GENERATE_COVERAGE)
pythonize_bool(LIBCXXABI_ENABLE_SHARED)
pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
+pythonize_bool(LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
pythonize_bool(LIBCXX_USE_COMPILER_RT)
pythonize_bool(LIBCXX_HAS_ATOMIC_LIB)
pythonize_bool(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60750.195294.patch
Type: text/x-patch
Size: 3140 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190416/990e54a1/attachment.bin>
More information about the llvm-commits
mailing list