Index: test/CMakeLists.txt =================================================================== --- test/CMakeLists.txt +++ test/CMakeLists.txt @@ -14,6 +14,7 @@ pythonize_bool(LIBCXX_ENABLE_SHARED) pythonize_bool(LIBCXX_BUILD_32_BITS) pythonize_bool(LIBCXX_GENERATE_COVERAGE) +pythonize_bool(LIBCXXABI_ENABLE_SHARED) pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER) # The tests shouldn't link to any ABI library when it has been linked into @@ -22,6 +23,13 @@ set(LIBCXX_CXX_ABI_LIBNAME "none") endif() +# By default, for non-standalone builds, libcxx and libcxxabi share a library +# directory. +if (NOT LIBCXX_CXX_ABI_LIBRARY_PATH) + set(LIBCXX_CXX_ABI_LIBRARY_PATH "${LIBCXX_LIBRARY_DIR}" CACHE PATH + "The path to libc++abi library.") +endif() + set(LIBCXX_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING "TargetInfo to use when setting up test environment.") set(LIBCXX_EXECUTOR "None" CACHE STRING Index: test/libcxx/test/config.py =================================================================== --- test/libcxx/test/config.py +++ test/libcxx/test/config.py @@ -460,7 +460,16 @@ if libcxx_library: self.cxx.link_flags += [libcxx_library] else: - self.cxx.link_flags += ['-lc++'] + libcxx_shared = self.get_lit_bool('enable_shared') + if libcxx_shared: + self.cxx.link_flags += ['-lc++'] + else: + cxx_library_root = self.get_lit_conf('cxx_library_root') + if cxx_library_root: + abs_path = cxx_library_root + "/libc++.a" + self.cxx.link_flags += [abs_path] + else: + self.cxx.link_flags += ['-lc++'] def configure_link_flags_abi_library(self): cxx_abi = self.get_lit_conf('cxx_abi', 'libcxxabi') @@ -470,7 +479,16 @@ self.cxx.link_flags += ['-lsupc++'] elif cxx_abi == 'libcxxabi': if self.target_info.allow_cxxabi_link(): - self.cxx.link_flags += ['-lc++abi'] + libcxxabi_shared = self.get_lit_bool('libcxxabi_shared') + if libcxxabi_shared: + self.cxx.link_flags += ['-lc++abi'] + else: + cxxabi_library_root = self.get_lit_conf('abi_library_path') + if cxxabi_library_root: + abs_path = cxxabi_library_root + "/libc++abi.a" + self.cxx.link_flags += [abs_path] + else: + self.cxx.link_flags += ['-lc++abi'] elif cxx_abi == 'libcxxrt': self.cxx.link_flags += ['-lcxxrt'] elif cxx_abi == 'none': Index: test/libcxx/test/target_info.py =================================================================== --- test/libcxx/test/target_info.py +++ test/libcxx/test/target_info.py @@ -104,6 +104,14 @@ env['DYLD_LIBRARY_PATH'] = ':'.join(library_paths) def allow_cxxabi_link(self): + # libc++ *should* export all of the symbols found in libc++abi on OS X. + # For this reason LibcxxConfiguration will not link libc++abi in OS X. + # However __cxa_throw_bad_new_array_length doesn't get exported into + # libc++ yet so we still need to explicitly link libc++abi when testing + # libc++abi + # See PR22654. + if(self.full_config.get_lit_conf('name', '') == 'libc++abi'): + return True # Don't link libc++abi explicitly on OS X because the symbols # should be available in libc++ directly. return False @@ -162,11 +170,14 @@ 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) + shared_libcxx = self.full_config.get_lit_bool('enable_shared', False) 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: flags += ['-lunwind', '-ldl'] Index: test/lit.site.cfg.in =================================================================== --- test/lit.site.cfg.in +++ test/lit.site.cfg.in @@ -20,6 +20,7 @@ config.target_info = "@LIBCXX_TARGET_INFO@" config.executor = "@LIBCXX_EXECUTOR@" config.llvm_unwinder = "@LIBCXXABI_USE_LLVM_UNWINDER@" +config.libcxxabi_shared = "@LIBCXXABI_ENABLE_SHARED@" # Let the main config do the real work. lit_config.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg")