diff gcc/ada/gnatlink.adb @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
line wrap: on
line diff
--- a/gcc/ada/gnatlink.adb	Thu Oct 25 07:37:49 2018 +0900
+++ b/gcc/ada/gnatlink.adb	Thu Feb 13 11:34:05 2020 +0900
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1996-2018, Free Software Foundation, Inc.         --
+--          Copyright (C) 1996-2019, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -459,7 +459,7 @@
 
                      when 'v' =>
 
-                        --  Support "double" verbose mode.  Second -v
+                        --  Support "double" verbose mode. Second -v
                         --  gets sent to the linker and binder phases.
 
                         if Verbose_Mode then
@@ -1884,6 +1884,7 @@
       Clean_Link_Option_Set : declare
          J                  : Natural;
          Shared_Libgcc_Seen : Boolean := False;
+         Static_Libgcc_Seen : Boolean := False;
 
       begin
          J := Linker_Options.First;
@@ -1905,7 +1906,7 @@
                end if;
             end if;
 
-            --  Remove duplicate -shared-libgcc switch
+            --  Remove duplicate -shared-libgcc switches
 
             if Linker_Options.Table (J).all = Shared_Libgcc_String then
                if Shared_Libgcc_Seen then
@@ -1919,6 +1920,20 @@
                end if;
             end if;
 
+            --  Remove duplicate -static-libgcc switches
+
+            if Linker_Options.Table (J).all = Static_Libgcc_String then
+               if Static_Libgcc_Seen then
+                  Linker_Options.Table (J .. Linker_Options.Last - 1) :=
+                    Linker_Options.Table (J + 1 .. Linker_Options.Last);
+                  Linker_Options.Decrement_Last;
+                  Num_Args := Num_Args - 1;
+
+               else
+                  Static_Libgcc_Seen := True;
+               end if;
+            end if;
+
             --  Here we just check for a canonical form that matches the
             --  pragma Linker_Options set in the NT runtime.
 
@@ -1950,14 +1965,27 @@
             --  libgcc, if gcc is not called with -shared-libgcc, call it
             --  with -static-libgcc, as there are some platforms where one
             --  of these two switches is compulsory to link.
+            --  Don't push extra switches if we already saw one.
 
             if Shared_Libgcc_Default = 'T'
               and then not Shared_Libgcc_Seen
+              and then not Static_Libgcc_Seen
             then
                Linker_Options.Increment_Last;
                Linker_Options.Table (Linker_Options.Last) := Static_Libgcc;
                Num_Args := Num_Args + 1;
             end if;
+
+            --  Likewise, the reverse.
+
+            if Shared_Libgcc_Default = 'H'
+              and then not Static_Libgcc_Seen
+              and then not Shared_Libgcc_Seen
+            then
+               Linker_Options.Increment_Last;
+               Linker_Options.Table (Linker_Options.Last) := Shared_Libgcc;
+               Num_Args := Num_Args + 1;
+            end if;
          end if;
       end Clean_Link_Option_Set;
 
@@ -2040,7 +2068,7 @@
    end Link_Step;
 
    --  Only keep the binder output file and it's associated object
-   --  file if compiling with the -g option.  These files are only
+   --  file if compiling with the -g option. These files are only
    --  useful if debugging.
 
    if not Debug_Flag_Present then