https://gcc.gnu.org/g:2fb8a47c8d94b257575fb6294b218be8dc81a8a3

commit r17-6541-g2fb8a47c8d94b257575fb6294b218be8dc81a8a3
Author: Zhongteng Gui <[email protected]>
Date:   Fri Nov 20 20:53:20 2026 +0800

    mingw: Note for empty spec, and remove it from other
    
    From 0b9cbad895486d1ae0cc12d0692fb41b40e75f15 Mon Sep 17 00:00:00 2001
    From: Zhongteng Gui <[email protected]>
    Date: Fri, 20 Nov 2026 19:13:37 +0800
    Subject: [PATCH v2] mingw: Note for empty spec, and remove it from other
     places.
    
    A spec expands to nothing is generally useless, however we have to
    reference both pthread and no-pthread at least once in the specs file,
    otherwise the driver will reject it.
    
    Add a note about why keeping SPEC_PTHREAD2 referenced in LIB_SPEC, and
    remove it from CPP_SPEC.
    
    gcc/ChangeLog:
    
            * config/i386/mingw-w64.h (LIB_SPEC): Note empty spec for
            SPEC_PTHREAD2.  Fix indentation.
            * config/mingw/mingw32.h (LIB_SPEC): Likewise.
            (CPP_SPEC): Remove empty spec for SPEC_PTHREAD2.
    
    Signed-off-by: Zhongteng Gui <[email protected]>
    Signed-off-by: Jonathan Yong <[email protected]>

Diff:
---
 gcc/config/i386/mingw-w64.h | 5 +++--
 gcc/config/mingw/mingw32.h  | 8 ++++----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/gcc/config/i386/mingw-w64.h b/gcc/config/i386/mingw-w64.h
index 09b79f9265e4..993793aa8b72 100644
--- a/gcc/config/i386/mingw-w64.h
+++ b/gcc/config/i386/mingw-w64.h
@@ -70,12 +70,13 @@ along with GCC; see the file COPYING3.  If not see
 #undef ASM_SPEC
 #define ASM_SPEC "%{m32:--32} %{m64:--64}"
 
+/* Note: Keep SPEC_PTHREAD2 referenced, otherwise it will be rejected by 
driver */
 #undef LIB_SPEC
 #define LIB_SPEC "%{pg:-lgmon} %{" SPEC_PTHREAD1 ":-lpthread} " \
                 "%{" SPEC_PTHREAD2 ": } " \
                 "%{mwindows:-lgdi32 -lcomdlg32} " \
-     "%{fvtable-verify=preinit:-lvtv -lpsapi; \
-        fvtable-verify=std:-lvtv -lpsapi} " \
+                "%{fvtable-verify=preinit:-lvtv -lpsapi; " \
+                "  fvtable-verify=std:-lvtv -lpsapi} " \
                 "-ladvapi32 -lshell32 -luser32 -lkernel32"
 
 #undef SPEC_32
diff --git a/gcc/config/mingw/mingw32.h b/gcc/config/mingw/mingw32.h
index 106d569705b5..544e2526e90b 100644
--- a/gcc/config/mingw/mingw32.h
+++ b/gcc/config/mingw/mingw32.h
@@ -94,7 +94,6 @@ along with GCC; see the file COPYING3.  If not see
 #undef CPP_SPEC
 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT} " \
                 "%{" SPEC_PTHREAD1 ":-D_REENTRANT} " \
-                "%{" SPEC_PTHREAD2 ": } " \
                 "%{mcrtdll=crtdll*:-U__MSVCRT__ -D__CRTDLL__} " \
                 "%{mcrtdll=msvcrt10*:-D__MSVCRT_VERSION__=0x100} " \
                 "%{mcrtdll=msvcrt20*:-D__MSVCRT_VERSION__=0x200} " \
@@ -113,13 +112,14 @@ along with GCC; see the file COPYING3.  If not see
 
 /* For Windows applications, include more libraries, but always include
    kernel32.  */
+/* Note: Keep SPEC_PTHREAD2 referenced, otherwise it will be rejected by 
driver */
 #undef LIB_SPEC
 #define LIB_SPEC "%{pg:-lgmon} %{" SPEC_PTHREAD1 ":-lpthread} " \
                 "%{" SPEC_PTHREAD2 ": } " \
                 "%{mwindows:-lgdi32 -lcomdlg32} " \
-     "%{fvtable-verify=preinit:-lvtv -lpsapi; \
-        fvtable-verify=std:-lvtv -lpsapi} " \
-                 "-ladvapi32 -lshell32 -luser32 -lkernel32"
+                "%{fvtable-verify=preinit:-lvtv -lpsapi; " \
+                "  fvtable-verify=std:-lvtv -lpsapi} " \
+                "-ladvapi32 -lshell32 -luser32 -lkernel32"
 
 /* Weak symbols do not get resolved if using a Windows dll import lib.
    Make the unwind registration references strong undefs.  */

Reply via email to