[llvm] [CMake] Use shm_open, not clock_gettime, to detect librt (PR #120727)

Raphael Kubo da Costa via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 20 04:46:33 PST 2024


https://github.com/rakuco created https://github.com/llvm/llvm-project/pull/120727

On systems with glibc, clock_gettime() was moved from librt to libc in version 2.17, in which case the current librt detection attempt would always fail.

Look for shm_open instead, like other parts of the tree also do when looking for librt.

>From 199a2f20a1ff5930b1b71103c2cec236101e5c9a Mon Sep 17 00:00:00 2001
From: Raphael Kubo da Costa <kubo at igalia.com>
Date: Fri, 20 Dec 2024 13:44:12 +0100
Subject: [PATCH] [CMake] Use shm_open, not clock_gettime, to detect librt

On systems with glibc, clock_gettime() was moved from librt to libc in
version 2.17, in which case the current librt detection attempt would always
fail.

Look for shm_open instead, like other parts of the tree also do when looking
for librt.
---
 llvm/cmake/config-ix.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 64878d28d9e1e5..53cde952416c62 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -124,7 +124,7 @@ if( NOT PURE_WINDOWS )
     endif()
   endif()
   check_library_exists(dl dlopen "" HAVE_LIBDL)
-  check_library_exists(rt clock_gettime "" HAVE_LIBRT)
+  check_library_exists(rt shm_open "" HAVE_LIBRT)
 endif()
 
 # Check for libpfm.



More information about the llvm-commits mailing list