[PATCH] D74767: [CMake][NFC] Clean up CheckAtomic.cmake
Luís Marques via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 18 06:52:34 PST 2020
luismarques created this revision.
luismarques added reviewers: jyknight, slthakur, lenary.
Herald added subscribers: llvm-commits, jfb, mgorny.
Herald added a project: LLVM.
`CheckAtomic.cmake` was skipping the test of whether atomics work in MSVC without an atomics library (they do), but not setting the value of `HAVE_CXX_ATOMICS_WITHOUT_LIB`. That caused build issues when trying to land D69869 <https://reviews.llvm.org/D69869>. I fixed that issue in f128f442a3d <https://reviews.llvm.org/rGf128f442a3d23674bee19ae18e29f92c9dfe40cd>, by adding an `elseif(MSVC)`, as was being done below in the 64-bit atomics check. That minimal fix did work, but it kept various inconsistencies between the original atomics check and the 64-bit one. This patch now makes the checks follow the same structure, cleaning them up.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D74767
Files:
llvm/cmake/modules/CheckAtomic.cmake
Index: llvm/cmake/modules/CheckAtomic.cmake
===================================================================
--- llvm/cmake/modules/CheckAtomic.cmake
+++ llvm/cmake/modules/CheckAtomic.cmake
@@ -39,46 +39,45 @@
endfunction(check_working_cxx_atomics64)
-# This isn't necessary on MSVC, so avoid command-line switch annoyance
-# by only running on GCC-like hosts.
-if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
+# Check for (non-64-bit) atomic operations.
+if(MSVC)
+ set(HAVE_CXX_ATOMICS_WITHOUT_LIB True)
+elseif(LLVM_COMPILER_IS_GCC_COMPATIBLE )
# First check if atomics work without the library.
check_working_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_4 "" HAVE_LIBATOMIC)
- if( HAVE_LIBATOMIC )
+ if(HAVE_LIBATOMIC)
list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITH_LIB)
if (NOT HAVE_CXX_ATOMICS_WITH_LIB)
- message(FATAL_ERROR "Host compiler must support std::atomic!")
+ 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()
-elseif(MSVC)
- set(HAVE_CXX_ATOMICS_WITHOUT_LIB True)
endif()
# Check for 64 bit atomic operations.
if(MSVC)
set(HAVE_CXX_ATOMICS64_WITHOUT_LIB True)
-else()
+elseif(LLVM_COMPILER_IS_GCC_COMPATIBLE )
+ # First check if atomics work without the library.
check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITHOUT_LIB)
-endif()
-
-# If not, check if the library exists, and atomics work with it.
-if(NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
- check_library_exists(atomic __atomic_load_8 "" HAVE_CXX_LIBATOMICS64)
- if(HAVE_CXX_LIBATOMICS64)
- list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
- check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITH_LIB)
- if (NOT HAVE_CXX_ATOMICS64_WITH_LIB)
- message(FATAL_ERROR "Host compiler must support 64-bit std::atomic!")
+ # If not, check if the library exists, and atomics work with it.
+ if(NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
+ check_library_exists(atomic __atomic_load_8 "" HAVE_CXX_LIBATOMICS64)
+ if(HAVE_CXX_LIBATOMICS64)
+ list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
+ check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITH_LIB)
+ if (NOT HAVE_CXX_ATOMICS64_WITH_LIB)
+ message(FATAL_ERROR "Host compiler must support 64-bit std::atomic!")
+ endif()
+ else()
+ message(FATAL_ERROR "Host compiler appears to require libatomic for 64-bit operations, but cannot find it.")
endif()
- else()
- message(FATAL_ERROR "Host compiler appears to require libatomic for 64-bit operations, but cannot find it.")
endif()
endif()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74767.245150.patch
Type: text/x-patch
Size: 2867 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200218/4bd1f5ad/attachment.bin>
More information about the llvm-commits
mailing list