From 01bfb2e5d803b9ce03cb13ec98937fa4c3c352c4 Mon Sep 17 00:00:00 2001 From: Ivan Prisyazhnyy Date: Wed, 31 Jul 2024 11:53:33 +0200 Subject: [PATCH] build(macos/other): librt is not needed for glibc >= 2.17 Since glibc >=2.17 (2012-12-25), librt is a stub-only library. (https://abi-laboratory.pro/?view=changelog&l=glibc&v=2.17) * The `clock_*' suite of functions (declared in ) is now available directly in the main C library. Previously it was necessary to link with -lrt to use these functions. This change has the effect that a single-threaded program that uses a function such as `clock_gettime' (and is not linked with -lrt) will no longer implicitly load the pthreads library at runtime and so will not suffer the overheads associated with multi-thread support in other code such as the C++ runtime library. Current version on Arch Linux is 2.40. It is however is required for Debian 10, 11 and Ubuntu 20.04. Signed-off-by: Ivan Prisyazhnyy --- cmake/check.cmake | 6 ++++++ cmake/os.cmake | 4 ++-- galerautils/tests/CMakeLists.txt | 2 +- gcache/src/CMakeLists.txt | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cmake/check.cmake b/cmake/check.cmake index e1ea471e8..83f3f5643 100644 --- a/cmake/check.cmake +++ b/cmake/check.cmake @@ -24,6 +24,12 @@ if (GALERA_HAVE_SUBUNIT_LIB) list(APPEND GALERA_UNIT_TEST_LIBS "${GALERA_HAVE_SUBUNIT_LIB}") endif() +# needed on old systems with glibc < 2.17 for timer_create() in libcheck. +find_library(RT_LIB rt) +if (RT_LIB) + list(APPEND GALERA_UNIT_TEST_LIBS "${RT_LIB}") +endif() + list(APPEND GALERA_UNIT_TEST_LIBS m) list(APPEND GALERA_UNIT_TEST_LIBS ${GALERA_SYSTEM_LIBS}) diff --git a/cmake/os.cmake b/cmake/os.cmake index 75d3a44d1..6d039a2c6 100644 --- a/cmake/os.cmake +++ b/cmake/os.cmake @@ -5,8 +5,8 @@ # find_library(PTHREAD_LIB pthread) -find_library(RT_LIB rt) -set(GALERA_SYSTEM_LIBS ${PTHREAD_LIB} ${RT_LIB}) + +set(GALERA_SYSTEM_LIBS ${PTHREAD_LIB}) if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") # Check if linkage with atomic library is needed for 8 byte atomics diff --git a/galerautils/tests/CMakeLists.txt b/galerautils/tests/CMakeLists.txt index a44b2d6b3..36522a7d3 100644 --- a/galerautils/tests/CMakeLists.txt +++ b/galerautils/tests/CMakeLists.txt @@ -102,7 +102,7 @@ target_compile_options(deqmap_bench PRIVATE -Wno-conversion) -target_link_libraries(deqmap_bench galerautilsxx rt) +target_link_libraries(deqmap_bench galerautilsxx) # # CRC32C micro benchmark. diff --git a/gcache/src/CMakeLists.txt b/gcache/src/CMakeLists.txt index e518c89d1..f174f6b4d 100644 --- a/gcache/src/CMakeLists.txt +++ b/gcache/src/CMakeLists.txt @@ -33,7 +33,7 @@ target_link_libraries(gcache galerautilsxx) add_executable(gcache_test test.cpp) -target_link_libraries(gcache_test gcache pthread rt) +target_link_libraries(gcache_test gcache pthread) target_compile_options(gcache_test PRIVATE