sdardis created this revision. sdardis added a reviewer: EricWF. Herald added subscribers: christof, mgorny.
When libcxx is built in tree for a host which requires libatomic, LLVM's configuration steps will determine it is required and add it to CMAKE_REQUIRED_LIBRARIES. When libcxx is later configured, it tests if it has C++ atomics without libatomic. The test erroneously passes as libatomic is already part of the set of required libraries. In turn, a number of the atomic tests will fail as they require libatomic but the test suite is configured not to use libatomic. Address this by always dropping libatomic from the set of required libraries before determining if LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB is true, then restoring the set of required libraries. Repository: rCXX libc++ https://reviews.llvm.org/D43509 Files: cmake/Modules/CheckLibcxxAtomic.cmake Index: cmake/Modules/CheckLibcxxAtomic.cmake =================================================================== --- cmake/Modules/CheckLibcxxAtomic.cmake +++ cmake/Modules/CheckLibcxxAtomic.cmake @@ -31,7 +31,14 @@ set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) endfunction(check_cxx_atomics) +# Perform the check for 64bit atomics without libatomic. It may have been added +# to the required libraries earlier in the configuration, which would cause +# this check to incorrectly pass. +set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) +list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "atomic") check_cxx_atomics(LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB) +set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES}) + check_library_exists(atomic __atomic_fetch_add_8 "" LIBCXX_HAS_ATOMIC_LIB) # If not, check if the library exists, and atomics work with it. if(NOT LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB)
Index: cmake/Modules/CheckLibcxxAtomic.cmake =================================================================== --- cmake/Modules/CheckLibcxxAtomic.cmake +++ cmake/Modules/CheckLibcxxAtomic.cmake @@ -31,7 +31,14 @@ set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) endfunction(check_cxx_atomics) +# Perform the check for 64bit atomics without libatomic. It may have been added +# to the required libraries earlier in the configuration, which would cause +# this check to incorrectly pass. +set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) +list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "atomic") check_cxx_atomics(LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB) +set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES}) + check_library_exists(atomic __atomic_fetch_add_8 "" LIBCXX_HAS_ATOMIC_LIB) # If not, check if the library exists, and atomics work with it. if(NOT LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB)
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits