From 412eb96b1ca384f4bebe996dba341decbc42362c Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Tue, 6 Jan 2026 14:00:09 +0000 Subject: [PATCH] libstdc++: Override detection of flockfile support in newlib [PR123406] MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit As explained in the PR, flockfile and funlockfile are always declared by newlib and there's no easy way to detect whether they're actually defined. Ensure that ac_stdio_locking=no gets set for non-cygwin newlib targets. libstdc++-v3/ChangeLog: PR libstdc++/123406 * acinclude.m4 (GLIBCXX_CHECK_STDIO_LOCKING): Override detection of flockfile for non-cygwin newlib targets. * configure: Regenerate. Reviewed-by: Tomasz Kamiński --- libstdc++-v3/acinclude.m4 | 9 ++++++++- libstdc++-v3/configure | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index 103515c000f..e6723edf880 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -5822,13 +5822,20 @@ AC_LANG_SAVE AC_MSG_CHECKING([whether flockfile and putc_unlocked are defined in ]) AC_TRY_COMPILE([ #include + #if __has_include() + # ifdef __CYGWIN__ + // Cygwin has working flockfile + # else + # error No usable flockfile on most newlib targets + # endif + #endif ],[ FILE* f = ::fopen("", ""); ::flockfile(f); ::putc_unlocked(' ', f); ::funlockfile(f); ::fclose(f); - ], [ac_stdio_locking=yes], [ac_stdio_locking=no]) + ],[ac_stdio_locking=yes],[ac_stdio_locking=no]) AC_MSG_RESULT($ac_stdio_locking) if test "$ac_stdio_locking" = yes; then diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index 0469cbe0f59..3d825a69fa2 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -55051,6 +55051,13 @@ $as_echo_n "checking whether flockfile and putc_unlocked are defined in + #if __has_include() + # ifdef __CYGWIN__ + // Cygwin has working flockfile + # else + # error No usable flockfile on most newlib targets + # endif + #endif int main () -- 2.47.3