https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93325

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
In general we can't use link tests in configure, for reasons related to
cross-compilers that I don't understand. But I think link tests should always
work for linux* targets, and to be extra cautious we can skip doing it for
freestanding builds:

--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -1422,21 +1422,15 @@ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [
         ac_has_nanosleep=yes
         ;;
       gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
-        AC_MSG_CHECKING([for at least GNU libc 2.17])
-        AC_TRY_COMPILE(
-          [#include <features.h>],
-          [
-          #if ! __GLIBC_PREREQ(2, 17)
-          #error
-          #endif
-          ],
-          [glibcxx_glibc217=yes], [glibcxx_glibc217=no])
-        AC_MSG_RESULT($glibcxx_glibc217)
-
-        if test x"$glibcxx_glibc217" = x"yes"; then
-          ac_has_clock_monotonic=yes
-          ac_has_clock_realtime=yes
-        fi
+       # Don't use link test for freestanding library, in case gcc_no_link=yes
+       if test x"$is_hosted" = xyes; then
+         # Versions of glibc before 2.17 needed -lrt for clock_gettime.
+         AC_SEARCH_LIBS(clock_gettime, [rt])
+         if test x"$ac_cv_search_clock_gettime" = x"none required"; then
+           ac_has_clock_monotonic=yes
+           ac_has_clock_realtime=yes
+         fi
+       fi
         ac_has_nanosleep=yes
         ac_has_sched_yield=yes
         ;;

For a freestanding build this means we could still end up setting
ac_has_clock_monotonic_syscall=yes and defining
_GLIBCXX_USE_CLOCK_GETTIME_SYSCALL=1 but we won't try to build
src/c++11/chrono.cc for freestanding, so it's harmless.

Reply via email to