From 19254c4dd4e47c94364ebf78b12bcf69fdf28f16 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Wed, 4 Sep 2024 17:42:34 -0700 Subject: [PATCH] Fix C++ Atomic support check (#2126) Summary: Some platforms need libatomic linked for sub-word operations while others need it for super-word operations. Let's make sure we test for all. Relates to https://github.com/facebook/folly/pull/1907 Pull Request resolved: https://github.com/facebook/folly/pull/2126 Reviewed By: Gownta Differential Revision: D52975209 Pulled By: yfeldblum fbshipit-source-id: 2c8781f817d6cc59fb8c74c1d13812e584187b47 --- CMake/folly-deps.cmake | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/CMake/folly-deps.cmake b/CMake/folly-deps.cmake index d060982a920..6ce4c679a42 100644 --- a/CMake/folly-deps.cmake +++ b/CMake/folly-deps.cmake @@ -187,9 +187,13 @@ message(STATUS "Setting FOLLY_HAVE_DWARF: ${FOLLY_HAVE_DWARF}") check_cxx_source_compiles(" #include int main(int argc, char** argv) { + std::atomic a1; + std::atomic a2; + std::atomic a4; + std::atomic a8; struct Test { bool val; }; std::atomic s; - return static_cast(s.is_lock_free()); + return a1++ + a2++ + a4++ + a8++ + unsigned(s.is_lock_free()); }" FOLLY_CPP_ATOMIC_BUILTIN ) @@ -200,9 +204,13 @@ if(NOT FOLLY_CPP_ATOMIC_BUILTIN) check_cxx_source_compiles(" #include int main(int argc, char** argv) { + std::atomic a1; + std::atomic a2; + std::atomic a4; + std::atomic a8; struct Test { bool val; }; - std::atomic s2; - return static_cast(s2.is_lock_free()); + std::atomic s; + return a1++ + a2++ + a4++ + a8++ + unsigned(s.is_lock_free()); }" FOLLY_CPP_ATOMIC_WITH_LIBATOMIC )