Now that it's clear that glibc bug <https://sourceware.org/bugzilla/show_bug.cgi?id=13701> will never be fixed, it's time to update the corresponding cross-compilation guess in gnulib.
2019-08-29 Bruno Haible <br...@clisp.org> lock: Fix cross-compilation guesses. * m4/pthread_rwlock_rdlock.m4 (gl_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER): Require AC_CANONICAL_HOST. When cross-compiling, guess no on most platforms. diff --git a/m4/pthread_rwlock_rdlock.m4 b/m4/pthread_rwlock_rdlock.m4 index 3c1d645..85e8dba 100644 --- a/m4/pthread_rwlock_rdlock.m4 +++ b/m4/pthread_rwlock_rdlock.m4 @@ -1,4 +1,4 @@ -# pthread_rwlock_rdlock.m4 serial 2 +# pthread_rwlock_rdlock.m4 serial 3 dnl Copyright (C) 2017-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -29,11 +29,13 @@ dnl and SCHED_RR, see dnl http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_rwlock_rdlock.html dnl but this test verifies the guarantee regardless of TPS and regardless of dnl scheduling policy. -dnl Glibc currently does not provide this guarantee, see +dnl Glibc does not provide this guarantee (and never will on Linux), see dnl https://sourceware.org/bugzilla/show_bug.cgi?id=13701 +dnl https://bugzilla.redhat.com/show_bug.cgi?id=1410052 AC_DEFUN([gl_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER], [ AC_REQUIRE([gl_THREADLIB_EARLY]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles AC_CACHE_CHECK([whether pthread_rwlock_rdlock prefers a writer to a reader], [gl_cv_pthread_rwlock_rdlock_prefer_writer], [save_LIBS="$LIBS" @@ -153,7 +155,25 @@ main () ]])], [gl_cv_pthread_rwlock_rdlock_prefer_writer=yes], [gl_cv_pthread_rwlock_rdlock_prefer_writer=no], - [gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing yes"]) + [case "$host_os" in + # Guess no on glibc systems. + *-gnu* | gnu*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;; + # Guess no on musl systems. + *-musl*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;; + # Guess no on bionic systems. + *-android*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;; + # Guess yes on native Windows with the mingw-w64 winpthreads library. + # Guess no on native Windows with the gnulib windows-rwlock module. + mingw*) if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then + gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing yes" + else + gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" + fi + ;; + # If we don't know, assume the worst. + *) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;; + esac + ]) LIBS="$save_LIBS" ]) case "$gl_cv_pthread_rwlock_rdlock_prefer_writer" in