From 7432c0472dabaefa73b31d6e4471181f94fcdd01 Mon Sep 17 00:00:00 2001 From: Vasileios Kalintiris Date: Tue, 9 Feb 2016 23:38:28 +0000 Subject: [PATCH] Revert "Introduce a cmake module to figure out whether we need to link with libatomic." This reverts commit r260235. It breaks LLVM's bootstrap when building with a -gcc-toolchain and the system's gcc installation does not provide the libatomic library and its headers. We should check whether LIBCXX_GCC_TOOLCHAIN is set and adjust the flags accordingly. llvm-svn: 260323 --- libcxx/cmake/Modules/CheckLibcxxAtomic.cmake | 38 -------------------- libcxx/cmake/config-ix.cmake | 5 --- libcxx/lib/CMakeLists.txt | 1 - libcxx/test/CMakeLists.txt | 1 - libcxx/test/libcxx/test/target_info.py | 3 -- libcxx/test/lit.site.cfg.in | 1 - 6 files changed, 49 deletions(-) delete mode 100644 libcxx/cmake/Modules/CheckLibcxxAtomic.cmake diff --git a/libcxx/cmake/Modules/CheckLibcxxAtomic.cmake b/libcxx/cmake/Modules/CheckLibcxxAtomic.cmake deleted file mode 100644 index ed3e6cc879e0..000000000000 --- a/libcxx/cmake/Modules/CheckLibcxxAtomic.cmake +++ /dev/null @@ -1,38 +0,0 @@ -INCLUDE(CheckCXXSourceCompiles) - -# Sometimes linking against libatomic is required for atomic ops, if -# the platform doesn't support lock-free atomics. -# -# We could modify LLVM's CheckAtomic module and have it check for 64-bit -# atomics instead. However, we would like to avoid careless uses of 64-bit -# atomics inside LLVM over time on 32-bit platforms. - -function(check_cxx_atomics varname) - set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) - set(CMAKE_REQUIRED_FLAGS "-std=c++11") - check_cxx_source_compiles(" -#include -#include -std::atomic x; -std::atomic y; -int main() { - return x + y; -} -" ${varname}) - set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) -endfunction(check_cxx_atomics) - -check_cxx_atomics(HAVE_CXX_ATOMICS_WITHOUT_LIB) -# If not, check if the library exists, and atomics work with it. -if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB) - check_library_exists(atomic __atomic_fetch_add_8 "" HAVE_LIBATOMIC) - if(HAVE_LIBATOMIC) - list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic") - check_cxx_atomics(HAVE_CXX_ATOMICS_WITH_LIB) - if (NOT HAVE_CXX_ATOMICS_WITH_LIB) - message(FATAL_ERROR "Host compiler must support std::atomic!") - endif() - else() - message(FATAL_ERROR "Host compiler appears to require libatomic, but cannot find it.") - endif() -endif() diff --git a/libcxx/cmake/config-ix.cmake b/libcxx/cmake/config-ix.cmake index 1bfa23fadd8b..c05597ea73dd 100644 --- a/libcxx/cmake/config-ix.cmake +++ b/libcxx/cmake/config-ix.cmake @@ -1,6 +1,5 @@ include(CheckLibraryExists) include(CheckCXXCompilerFlag) -include(CheckLibcxxAtomic) # Check compiler flags @@ -18,7 +17,3 @@ check_library_exists(c fopen "" LIBCXX_HAS_C_LIB) 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() diff --git a/libcxx/lib/CMakeLists.txt b/libcxx/lib/CMakeLists.txt index 3e3c47f2265d..d6a35f8eba2e 100644 --- a/libcxx/lib/CMakeLists.txt +++ b/libcxx/lib/CMakeLists.txt @@ -79,7 +79,6 @@ add_library_flags_if(LIBCXX_HAS_C_LIB c) 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) diff --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt index 88145534f7d4..b67b3b43f83e 100644 --- a/libcxx/test/CMakeLists.txt +++ b/libcxx/test/CMakeLists.txt @@ -15,7 +15,6 @@ pythonize_bool(LIBCXX_ENABLE_SHARED) 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. diff --git a/libcxx/test/libcxx/test/target_info.py b/libcxx/test/libcxx/test/target_info.py index dc37f7108d3e..7ca08bea193a 100644 --- a/libcxx/test/libcxx/test/target_info.py +++ b/libcxx/test/libcxx/test/target_info.py @@ -172,9 +172,6 @@ class LinuxLocalTI(DefaultTargetInfo): 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 diff --git a/libcxx/test/lit.site.cfg.in b/libcxx/test/lit.site.cfg.in index 9eb2b20a7dc6..fa25834d1110 100644 --- a/libcxx/test/lit.site.cfg.in +++ b/libcxx/test/lit.site.cfg.in @@ -20,7 +20,6 @@ config.generate_coverage = "@LIBCXX_GENERATE_COVERAGE@" 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")