diff --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt --- a/libcxx/test/CMakeLists.txt +++ b/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) diff --git a/libcxx/test/lit.site.cfg.in b/libcxx/test/lit.site.cfg.in --- a/libcxx/test/lit.site.cfg.in +++ b/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@ diff --git a/libcxx/utils/libcxx/test/target_info.py b/libcxx/utils/libcxx/test/target_info.py --- a/libcxx/utils/libcxx/test/target_info.py +++ b/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]