Skip to content

Commit

Permalink
PS-9379 Fix problem with "-latomic" on some platorms in uuid_vx compo…
Browse files Browse the repository at this point in the history
…nent (#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.
  • Loading branch information
lukin-oleksiy authored Sep 10, 2024
1 parent c51d625 commit 6bba53b
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions components/uuid_vx_udf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,26 @@ MYSQL_ADD_COMPONENT(uuid_vx_udf

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

if(NOT APPLE)
target_link_libraries(component_uuid_vx_udf PRIVATE atomic)
# Check if -latomic is required or not
if (NOT MSVC)
include(CheckCXXSourceCompiles)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
# Adding "-w" compiler option to suppres all possible warnings
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -std=c++17 -w)
check_cxx_source_compiles("
#include <atomic>
std::atomic<uint64_t> x(0);
int main() {
uint64_t i = x.load(std::memory_order_relaxed);
bool b = x.is_lock_free();
return 0;
}
" uuid_vx_HAVE_BUILTIN_ATOMICS)
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
if (uuid_vx_HAVE_BUILTIN_ATOMICS)
message(STATUS "Building UUID_VX UDF component without libatomic")
else()
message(STATUS "Building UUID_VX UDF component with libatomic")
target_link_libraries(component_uuid_vx_udf PRIVATE atomic)
endif()
endif()

0 comments on commit 6bba53b

Please sign in to comment.