Skip to content

Commit

Permalink
build(macos/other): librt is not needed for glibc >= 2.17
Browse files Browse the repository at this point in the history
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 <time.h>) 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 <john.koepi@gmail.com>
  • Loading branch information
sitano committed Aug 27, 2024
1 parent 5db72da commit 01bfb2e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions cmake/check.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down
4 changes: 2 additions & 2 deletions cmake/os.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion galerautils/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion gcache/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 01bfb2e

Please sign in to comment.