Skip to content

Commit 6bba53b

Browse files
PS-9379 Fix problem with "-latomic" on some platorms in uuid_vx component (#5407)
https://perconadev.atlassian.net/browse/PS-9379 Fix of problem with -latomic in uuid_vx component of some platofrms. CMakeLists.txtx for the component now check code sample compilation and adds "-latomic" if required. Note! On RHEL platforms the package "gcc-toolset-12-libatomic-devel" must be installed as compile dependency.
1 parent c51d625 commit 6bba53b

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

components/uuid_vx_udf/CMakeLists.txt

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,26 @@ MYSQL_ADD_COMPONENT(uuid_vx_udf
3333

3434
target_include_directories(component_uuid_vx_udf SYSTEM PRIVATE ${BOOST_PATCHES_DIR} ${BOOST_INCLUDE_DIR})
3535

36-
if(NOT APPLE)
37-
target_link_libraries(component_uuid_vx_udf PRIVATE atomic)
36+
# Check if -latomic is required or not
37+
if (NOT MSVC)
38+
include(CheckCXXSourceCompiles)
39+
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
40+
# Adding "-w" compiler option to suppres all possible warnings
41+
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -std=c++17 -w)
42+
check_cxx_source_compiles("
43+
#include <atomic>
44+
std::atomic<uint64_t> x(0);
45+
int main() {
46+
uint64_t i = x.load(std::memory_order_relaxed);
47+
bool b = x.is_lock_free();
48+
return 0;
49+
}
50+
" uuid_vx_HAVE_BUILTIN_ATOMICS)
51+
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
52+
if (uuid_vx_HAVE_BUILTIN_ATOMICS)
53+
message(STATUS "Building UUID_VX UDF component without libatomic")
54+
else()
55+
message(STATUS "Building UUID_VX UDF component with libatomic")
56+
target_link_libraries(component_uuid_vx_udf PRIVATE atomic)
57+
endif()
3858
endif()

0 commit comments

Comments
 (0)