Index: cmake/config-ix.cmake =================================================================== --- cmake/config-ix.cmake +++ cmake/config-ix.cmake @@ -1,5 +1,6 @@ include(CheckLibraryExists) include(CheckCXXCompilerFlag) +include(CheckAtomic) # Check compiler flags @@ -17,3 +18,7 @@ check_library_exists(m ccos "" LIBCXX_HAS_M_LIB) check_library_exists(rt clock_gettime "" LIBCXX_HAS_RT_LIB) check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXX_HAS_GCC_S_LIB) + +if (NOT HAVE_CXX_ATOMICS_WITHOUT_LIB) + set(LIBCXX_HAS_ATOMIC_LIB True) +endif() Index: lib/CMakeLists.txt =================================================================== --- lib/CMakeLists.txt +++ lib/CMakeLists.txt @@ -79,6 +79,7 @@ add_library_flags_if(LIBCXX_HAS_M_LIB m) add_library_flags_if(LIBCXX_HAS_RT_LIB rt) add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s) +add_library_flags_if(LIBCXX_HAS_ATOMIC_LIB atomic) # Setup flags. add_flags_if_supported(-fPIC) Index: test/CMakeLists.txt =================================================================== --- test/CMakeLists.txt +++ test/CMakeLists.txt @@ -15,6 +15,7 @@ pythonize_bool(LIBCXX_BUILD_32_BITS) pythonize_bool(LIBCXX_GENERATE_COVERAGE) pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER) +pythonize_bool(LIBCXX_HAS_ATOMIC_LIB) # The tests shouldn't link to any ABI library when it has been linked into # libc++ statically or via a linker script. Index: test/libcxx/test/target_info.py =================================================================== --- test/libcxx/test/target_info.py +++ test/libcxx/test/target_info.py @@ -172,6 +172,9 @@ flags += ['-lunwind', '-ldl'] else: flags += ['-lgcc_s', '-lgcc'] + use_libatomic = self.full_config.get_lit_bool('use_libatomic', False) + if use_libatomic: + flags += ['-latomic'] san = self.full_config.get_lit_conf('use_sanitizer', '').strip() if san: # The libraries and their order are taken from the 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.use_libatomic = "@LIBCXX_HAS_ATOMIC_LIB@" # Let the main config do the real work. lit_config.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg")