From 96351680833e99f0b7161a93ade0a23d7e7e8ba5 Mon Sep 17 00:00:00 2001 From: Kai Luo Date: Mon, 18 Oct 2021 09:17:04 +0000 Subject: [PATCH] [AIX][cmake] Set atomics related macros when build with xlclang Set `HAVE_CXX_ATOMICS_WITHOUT_LIB` or `HAVE_LIBATOMIC` when build LLVM with xlclang. With these macros set, libraries like libLLVMSupport are able to know whether it's necessary to add `-latomic` to dependent system libs. If `HAVE_LIBATOMIC` is set, `llvm-config --system-libs` appends `-latomic` to its output. Reviewed By: jsji Differential Revision: https://reviews.llvm.org/D111782 --- llvm/cmake/modules/CheckAtomic.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/cmake/modules/CheckAtomic.cmake b/llvm/cmake/modules/CheckAtomic.cmake index 04eed1448482..3c5ba72993a3 100644 --- a/llvm/cmake/modules/CheckAtomic.cmake +++ b/llvm/cmake/modules/CheckAtomic.cmake @@ -43,7 +43,7 @@ endfunction(check_working_cxx_atomics64) # Check for (non-64-bit) atomic operations. if(MSVC) set(HAVE_CXX_ATOMICS_WITHOUT_LIB True) -elseif(LLVM_COMPILER_IS_GCC_COMPATIBLE) +elseif(LLVM_COMPILER_IS_GCC_COMPATIBLE OR CMAKE_CXX_COMPILER_ID MATCHES "XL") # 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. @@ -64,7 +64,7 @@ endif() # Check for 64 bit atomic operations. if(MSVC) set(HAVE_CXX_ATOMICS64_WITHOUT_LIB True) -elseif(LLVM_COMPILER_IS_GCC_COMPATIBLE) +elseif(LLVM_COMPILER_IS_GCC_COMPATIBLE OR CMAKE_CXX_COMPILER_ID MATCHES "XL") # First check if atomics work without the library. check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITHOUT_LIB) # If not, check if the library exists, and atomics work with it.