https://gcc.gnu.org/g:8d4c05982c4de7bd839f5009a05d9e26b60897da

commit r17-6539-g8d4c05982c4de7bd839f5009a05d9e26b60897da
Author: Zhongteng Gui <[email protected]>
Date:   Fri Nov 20 18:32:55 2026 +0800

    mingw-w64: Never undef _REENTRANT
    
    From 56444d25caa60c8e11f6b2de8da7ad544bd76112 Mon Sep 17 00:00:00 2001
    From: Zhongteng Gui <[email protected]>
    Date: Fri, 20 Nov 2026 18:19:37 +0800
    Subject: [PATCH] mingw-w64: Never undef _REENTRANT
    
    SPEC_PTHREAD1 and SPEC_PTHREAD2 both indicate that the user wants to use
    pthreads, either by default (!no-pthread) or by explicitly (-pthread).
    In either case, we should not undef _REENTRANT.
    
    Currently, if pthreads is enabled by default, the spec expands to
    
            %{!no-pthread:-D_REENTRANT} %{pthread:-U_REENTRANT}
    
    Which means -pthread will undef _REENTRANT!  This can also be verifed
    with gcc -dM.
    
    An empty spec is useless, so remove SPEC_PTHREAD2 here instead of
    expanding it to empty.
    
    See also:
    https://gcc.gnu.org/pipermail/gcc-patches/2023-September/631732.html
    
    gcc/ChangeLog:
    
            * config/i386/mingw-w64.h (CPP_SPEC): Never undef _REENTRANT.
    
    Signed-off-by: Zhongteng Gui <[email protected]>
    Signed-off-by: Jonathan Yong <[email protected]>

Diff:
---
 gcc/config/i386/mingw-w64.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/gcc/config/i386/mingw-w64.h b/gcc/config/i386/mingw-w64.h
index 7cd5e31b1029..09b79f9265e4 100644
--- a/gcc/config/i386/mingw-w64.h
+++ b/gcc/config/i386/mingw-w64.h
@@ -25,7 +25,6 @@ along with GCC; see the file COPYING3.  If not see
 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT} " \
                 "%{municode:-DUNICODE} " \
                 "%{" SPEC_PTHREAD1 ":-D_REENTRANT} " \
-                "%{" SPEC_PTHREAD2 ":-U_REENTRANT} " \
                 "%{mcrtdll=crtdll*:-U__MSVCRT__ -D__CRTDLL__} " \
                 "%{mcrtdll=msvcrt10*:-D__MSVCRT_VERSION__=0x100} " \
                 "%{mcrtdll=msvcrt20*:-D__MSVCRT_VERSION__=0x200} " \

Reply via email to