diff options
Diffstat (limited to 'gcc/ada/gnatlink.adb')
-rw-r--r-- | gcc/ada/gnatlink.adb | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/gcc/ada/gnatlink.adb b/gcc/ada/gnatlink.adb index 855d6d38a5b..45104a2ac4d 100644 --- a/gcc/ada/gnatlink.adb +++ b/gcc/ada/gnatlink.adb @@ -1882,6 +1882,7 @@ begin Clean_Link_Option_Set : declare J : Natural; Shared_Libgcc_Seen : Boolean := False; + Static_Libgcc_Seen : Boolean := False; begin J := Linker_Options.First; @@ -1903,7 +1904,7 @@ begin 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 @@ -1917,6 +1918,20 @@ begin 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. @@ -1948,14 +1963,27 @@ begin -- 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; |