From 6e00db58fbeaa09e58c20a606e00b83743e81c7f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 3 Apr 2025 10:12:53 +0200 Subject: [PATCH] configure: fix --disable-rt This option now better only prevents the actual -lrt to be used, and thus has no effect if the system does not need -lt for the monotonic clock etc. Fixes #16932 Closes #16934 --- acinclude.m4 | 105 ++++++++++++++++++++++++++------------------------- configure.ac | 5 --- 2 files changed, 54 insertions(+), 56 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index abf19c2cd4..53c302cc03 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -807,29 +807,29 @@ AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [ AC_CHECK_HEADERS(sys/types.h sys/time.h) AC_MSG_CHECKING([for monotonic clock_gettime]) # - if test "x$dontwant_rt" = "xno" ; then - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[ - #ifdef HAVE_SYS_TYPES_H - #include - #endif - #ifdef HAVE_SYS_TIME_H - #include - #endif - #include - ]],[[ - struct timespec ts; - (void)clock_gettime(CLOCK_MONOTONIC, &ts); - (void)ts; - ]]) - ],[ - AC_MSG_RESULT([yes]) - curl_func_clock_gettime="yes" - ],[ - AC_MSG_RESULT([no]) - curl_func_clock_gettime="no" - ]) - fi + + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + #ifdef HAVE_SYS_TYPES_H + #include + #endif + #ifdef HAVE_SYS_TIME_H + #include + #endif + #include + ]],[[ + struct timespec ts; + (void)clock_gettime(CLOCK_MONOTONIC, &ts); + (void)ts; + ]]) + ],[ + AC_MSG_RESULT([yes]) + curl_func_clock_gettime="yes" + ],[ + AC_MSG_RESULT([no]) + curl_func_clock_gettime="no" + ]) + dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed dnl until library linking and run-time checks for clock_gettime succeed. ]) @@ -842,29 +842,27 @@ AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC_RAW], [ AC_CHECK_HEADERS(sys/types.h sys/time.h) AC_MSG_CHECKING([for raw monotonic clock_gettime]) # - if test "x$dontwant_rt" = "xno" ; then - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[ - #ifdef HAVE_SYS_TYPES_H - #include - #endif - #ifdef HAVE_SYS_TIME_H - #include - #endif - #include - ]],[[ - struct timespec ts; - (void)clock_gettime(CLOCK_MONOTONIC_RAW, &ts); - (void)ts; - ]]) - ],[ - AC_MSG_RESULT([yes]) - AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC_RAW, 1, - [Define to 1 if you have the clock_gettime function and raw monotonic timer.]) - ],[ - AC_MSG_RESULT([no]) - ]) - fi + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + #ifdef HAVE_SYS_TYPES_H + #include + #endif + #ifdef HAVE_SYS_TIME_H + #include + #endif + #include + ]],[[ + struct timespec ts; + (void)clock_gettime(CLOCK_MONOTONIC_RAW, &ts); + (void)ts; + ]]) + ],[ + AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC_RAW, 1, + [Define to 1 if you have the clock_gettime function and raw monotonic timer.]) + ],[ + AC_MSG_RESULT([no]) + ]) ]) @@ -923,13 +921,18 @@ AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [ curl_func_clock_gettime="yes" ;; *) - if test -z "$curl_cv_save_LIBS"; then - LIBS="$curl_cv_gclk_LIBS" + if test "x$dontwant_rt" = "xyes" ; then + AC_MSG_WARN([needs -lrt but asked not to use it, HAVE_CLOCK_GETTIME_MONOTONIC will not be defined]) + curl_func_clock_gettime="no" else - LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS" + if test -z "$curl_cv_save_LIBS"; then + LIBS="$curl_cv_gclk_LIBS" + else + LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS" + fi + AC_MSG_RESULT([$curl_cv_gclk_LIBS]) + curl_func_clock_gettime="yes" fi - AC_MSG_RESULT([$curl_cv_gclk_LIBS]) - curl_func_clock_gettime="yes" ;; esac # diff --git a/configure.ac b/configure.ac index 7f5a2bff59..311d2853e6 100644 --- a/configure.ac +++ b/configure.ac @@ -4203,11 +4203,6 @@ if test "$ipv6" = yes -a "$curl_cv_apple" = 'yes'; then CURL_DARWIN_SYSTEMCONFIGURATION fi -dnl turn off pthreads if rt is disabled -if test "$want_threaded_resolver" = "yes" && test "$dontwant_rt" = "yes"; then - AC_MSG_ERROR([options --enable-pthreads and --disable-rt are mutually exclusive]) -fi - dnl Windows threaded resolver check if test "$want_threaded_resolver" = "yes" && test "$curl_cv_native_windows" = "yes"; then USE_THREADS_WIN32=1 -- 2.47.2