When pthread is used by default, _REENTRANT should be defined in all
cases except -no-pthread. When pthread is not used by default,
_REENTRANT should only be defined with -pthread.

The current spec for mingw-w64 for default pthread is

    %{!no-pthread:-D_REENTRANT} %{pthread:-U_REENTRANT}

and for non-default pthread is

    %{pthread:-D_REENTRANT} %{!no-pthread:-U_REENTRANT}

This means that when pthread is used by default, specifying -pthread
undefines _REENTRANT! Applying the mingw32 specs instead produces the
desired result,

    %{!no-pthread:-D_REENTRANT} %{pthread: }

for default pthread, and

    %{pthread:-D_REENTRANT} %{!no-pthread: }

for non-default pthread.

gcc/ChangeLog:

        * config/i386/mingw-w64.h (CPP_SPEC): Never undefine
          _REENTRANT, only define it when appropriate.

Signed-off-by: Stephen Kitt <st...@sk2.org>
---
 gcc/config/i386/mingw-w64.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/i386/mingw-w64.h b/gcc/config/i386/mingw-w64.h
index 0146ed4f793..39e7ec2ea1e 100644
--- a/gcc/config/i386/mingw-w64.h
+++ b/gcc/config/i386/mingw-w64.h
@@ -25,7 +25,7 @@ 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} " \
+                "%{" SPEC_PTHREAD2 ": } " \
                 "%{mcrtdll=crtdll*:-U__MSVCRT__ -D__CRTDLL__} " \
                 "%{mcrtdll=msvcrt10*:-D__MSVCRT_VERSION__=0x100} " \
                 "%{mcrtdll=msvcrt20*:-D__MSVCRT_VERSION__=0x200} " \

base-commit: 1e6815071fd137424f79ca79a6ba66b776a98778
-- 
2.30.2

Reply via email to