From ab1bfc33c87726dc1fd85c351191380c6c463143 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Thu, 18 Aug 2022 00:31:05 +0300 Subject: Link with rt library to get clock_gettime where necessary Issue #450 (bdwgc). This patch adds the logic to CMake and configure scripts to pass -lrt option during linking to avoid unresolved clock_gettime on some hosts. * CMakeLists.txt [!NEED_LIB_RT] (HAVE_CLOCK_GETTIME_DIRECTLY): Set variable by check_function_exists(clock_gettime). * CMakeLists.txt [!NEED_LIB_RT && !HAVE_CLOCK_GETTIME_DIRECTLY] (NEED_LIB_RT): Set to ON. * CMakeLists.txt (LIBRT): Refine comment. * CMakeLists.txt (gc): Specify target_link_libraries regardless of enable_threads. * Makefile.am (libgc_la_LIBADD): Update comment. * configure.ac (need_lib_rt): Define variable (and set to false). * configure.ac [$THREADS==pthreads && ($host==*-*-hpux11* || $host==*-*-netbsd* || $host== *-*-solaris* || $host==*-*-osf*)] (THREADDLLIBS): Do not add "-lrt" directly. * configure.ac [$THREADS==pthreads && ($host==*-*-hpux11* || $host==*-*-netbsd* || $host== *-*-solaris* || $host==*-*-osf*)] (need_lib_rt): Set to true. * configure.ac [!need_lib_rt && !AC_LINK_IFELSE(clock_gettime) && AC_CHECK_LIB(rt,clock_gettime)] (need_lib_rt): Set to true. * configure.ac [need_lib_rt] (THREADDLLIBS): Append "-lrt". --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile.am') diff --git a/Makefile.am b/Makefile.am index 919710f0..c73126c0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -115,7 +115,7 @@ endif endif # Include THREADDLLIBS here to ensure that the correct versions of -# linuxthread semaphore functions get linked: +# linuxthread semaphore (and clock_gettime) functions get linked: libgc_la_LIBADD = @addobjs@ $(THREADDLLIBS) $(UNWINDLIBS) $(ATOMIC_OPS_LIBS) libgc_la_DEPENDENCIES = @addobjs@ libgc_la_LDFLAGS = $(extra_ldflags_libgc) -version-info $(LIBGC_VER_INFO) \ -- cgit v1.2.1