https://gcc.gnu.org/g:499dfc880d45fe0a04ef1f7986871f661ef131b2

commit r17-6540-g499dfc880d45fe0a04ef1f7986871f661ef131b2
Author: Zhongteng Gui <[email protected]>
Date:   Fri Nov 20 19:59:15 2026 +0800

    mingw/cygwin: Simplify SHARED_LIBGCC_SPEC
    
    In gcc/gcc.cc, under "The Specs Language", it says:
    
     %{S:X;   if S was given to GCC, substitutes X;
       T:Y;   else if T was given to GCC, substitutes Y;
        :D}   else substitutes D.  There can be as many clauses as you need.
    
    So we can use this to simplify SHARED_LIBGCC_SPEC.  There should be no
    functional change.
    
    Note that for mingw targets, SHARED_LIBGCC_SPEC defaults to use static
    libgcc, which IMHO is not aligned with the name, and also not aligned
    with cygwin targets.
    
    gcc/ChangeLog:
    
            * config/i386/cygwin.h (SHARED_LIBGCC_SPEC): Simplify using
            %{S:X;T:Y;:D} syntax.
            * config/mingw/mingw32.h (SHARED_LIBGCC_SPEC): Likewise.
    
    Signed-off-by: Zhongteng Gui <[email protected]>
    Signed-off-by: Jonathan Yong <[email protected]>

Diff:
---
 gcc/config/i386/cygwin.h   |  8 ++------
 gcc/config/mingw/mingw32.h | 13 +++----------
 2 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/gcc/config/i386/cygwin.h b/gcc/config/i386/cygwin.h
index 0e915706f22b..7877a8f589f9 100644
--- a/gcc/config/i386/cygwin.h
+++ b/gcc/config/i386/cygwin.h
@@ -62,12 +62,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #ifdef ENABLE_SHARED_LIBGCC
 #define SHARED_LIBGCC_SPEC " \
- %{static|static-libgcc:-lgcc -lgcc_eh} \
- %{!static: \
-   %{!static-libgcc: \
-     -lgcc_s -lgcc \
-    } \
-  } "
+ %{static|static-libgcc:-lgcc -lgcc_eh; \
+   :-lgcc_s -lgcc } "
 #else
 #define SHARED_LIBGCC_SPEC " -lgcc "
 #endif
diff --git a/gcc/config/mingw/mingw32.h b/gcc/config/mingw/mingw32.h
index 4b2a6753defb..106d569705b5 100644
--- a/gcc/config/mingw/mingw32.h
+++ b/gcc/config/mingw/mingw32.h
@@ -182,16 +182,9 @@ along with GCC; see the file COPYING3.  If not see
 /* Include in the mingw32 libraries with libgcc */
 #ifdef ENABLE_SHARED_LIBGCC
 #define SHARED_LIBGCC_SPEC " \
- %{static|static-libgcc:-lgcc -lgcc_eh} \
- %{!static: \
-   %{!static-libgcc: \
-     %{!shared: \
-       %{!shared-libgcc:-lgcc -lgcc_eh} \
-       %{shared-libgcc:-lgcc_s -lgcc} \
-      } \
-     %{shared:-lgcc_s -lgcc} \
-    } \
-  } "
+  %{static|static-libgcc:-lgcc -lgcc_eh; \
+    shared|shared-libgcc:-lgcc_s -lgcc; \
+    :-lgcc -lgcc_eh} "
 #else
 #define SHARED_LIBGCC_SPEC " -lgcc "
 #endif

Reply via email to