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

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
4 -- -- 4 -- --
5 -- G N A T L I N K -- 5 -- G N A T L I N K --
6 -- -- 6 -- --
7 -- B o d y -- 7 -- B o d y --
8 -- -- 8 -- --
9 -- Copyright (C) 1996-2018, Free Software Foundation, Inc. -- 9 -- Copyright (C) 1996-2019, Free Software Foundation, Inc. --
10 -- -- 10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under -- 11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- -- 12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- -- 13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- 14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
457 when 'R' => 457 when 'R' =>
458 Opt.Run_Path_Option := False; 458 Opt.Run_Path_Option := False;
459 459
460 when 'v' => 460 when 'v' =>
461 461
462 -- Support "double" verbose mode. Second -v 462 -- Support "double" verbose mode. Second -v
463 -- gets sent to the linker and binder phases. 463 -- gets sent to the linker and binder phases.
464 464
465 if Verbose_Mode then 465 if Verbose_Mode then
466 Very_Verbose_Mode := True; 466 Very_Verbose_Mode := True;
467 467
1882 -- modify the length of the table. 1882 -- modify the length of the table.
1883 1883
1884 Clean_Link_Option_Set : declare 1884 Clean_Link_Option_Set : declare
1885 J : Natural; 1885 J : Natural;
1886 Shared_Libgcc_Seen : Boolean := False; 1886 Shared_Libgcc_Seen : Boolean := False;
1887 Static_Libgcc_Seen : Boolean := False;
1887 1888
1888 begin 1889 begin
1889 J := Linker_Options.First; 1890 J := Linker_Options.First;
1890 while J <= Linker_Options.Last loop 1891 while J <= Linker_Options.Last loop
1891 if Linker_Options.Table (J).all = "-Xlinker" 1892 if Linker_Options.Table (J).all = "-Xlinker"
1903 else 1904 else
1904 Stack_Op := True; 1905 Stack_Op := True;
1905 end if; 1906 end if;
1906 end if; 1907 end if;
1907 1908
1908 -- Remove duplicate -shared-libgcc switch 1909 -- Remove duplicate -shared-libgcc switches
1909 1910
1910 if Linker_Options.Table (J).all = Shared_Libgcc_String then 1911 if Linker_Options.Table (J).all = Shared_Libgcc_String then
1911 if Shared_Libgcc_Seen then 1912 if Shared_Libgcc_Seen then
1912 Linker_Options.Table (J .. Linker_Options.Last - 1) := 1913 Linker_Options.Table (J .. Linker_Options.Last - 1) :=
1913 Linker_Options.Table (J + 1 .. Linker_Options.Last); 1914 Linker_Options.Table (J + 1 .. Linker_Options.Last);
1914 Linker_Options.Decrement_Last; 1915 Linker_Options.Decrement_Last;
1915 Num_Args := Num_Args - 1; 1916 Num_Args := Num_Args - 1;
1916 1917
1917 else 1918 else
1918 Shared_Libgcc_Seen := True; 1919 Shared_Libgcc_Seen := True;
1920 end if;
1921 end if;
1922
1923 -- Remove duplicate -static-libgcc switches
1924
1925 if Linker_Options.Table (J).all = Static_Libgcc_String then
1926 if Static_Libgcc_Seen then
1927 Linker_Options.Table (J .. Linker_Options.Last - 1) :=
1928 Linker_Options.Table (J + 1 .. Linker_Options.Last);
1929 Linker_Options.Decrement_Last;
1930 Num_Args := Num_Args - 1;
1931
1932 else
1933 Static_Libgcc_Seen := True;
1919 end if; 1934 end if;
1920 end if; 1935 end if;
1921 1936
1922 -- Here we just check for a canonical form that matches the 1937 -- Here we just check for a canonical form that matches the
1923 -- pragma Linker_Options set in the NT runtime. 1938 -- pragma Linker_Options set in the NT runtime.
1948 1963
1949 -- For systems where the default is to link statically with 1964 -- For systems where the default is to link statically with
1950 -- libgcc, if gcc is not called with -shared-libgcc, call it 1965 -- libgcc, if gcc is not called with -shared-libgcc, call it
1951 -- with -static-libgcc, as there are some platforms where one 1966 -- with -static-libgcc, as there are some platforms where one
1952 -- of these two switches is compulsory to link. 1967 -- of these two switches is compulsory to link.
1968 -- Don't push extra switches if we already saw one.
1953 1969
1954 if Shared_Libgcc_Default = 'T' 1970 if Shared_Libgcc_Default = 'T'
1971 and then not Shared_Libgcc_Seen
1972 and then not Static_Libgcc_Seen
1973 then
1974 Linker_Options.Increment_Last;
1975 Linker_Options.Table (Linker_Options.Last) := Static_Libgcc;
1976 Num_Args := Num_Args + 1;
1977 end if;
1978
1979 -- Likewise, the reverse.
1980
1981 if Shared_Libgcc_Default = 'H'
1982 and then not Static_Libgcc_Seen
1955 and then not Shared_Libgcc_Seen 1983 and then not Shared_Libgcc_Seen
1956 then 1984 then
1957 Linker_Options.Increment_Last; 1985 Linker_Options.Increment_Last;
1958 Linker_Options.Table (Linker_Options.Last) := Static_Libgcc; 1986 Linker_Options.Table (Linker_Options.Last) := Shared_Libgcc;
1959 Num_Args := Num_Args + 1; 1987 Num_Args := Num_Args + 1;
1960 end if; 1988 end if;
1961 end if; 1989 end if;
1962 end Clean_Link_Option_Set; 1990 end Clean_Link_Option_Set;
1963 1991
2038 end if; 2066 end if;
2039 end Call_Linker; 2067 end Call_Linker;
2040 end Link_Step; 2068 end Link_Step;
2041 2069
2042 -- Only keep the binder output file and it's associated object 2070 -- Only keep the binder output file and it's associated object
2043 -- file if compiling with the -g option. These files are only 2071 -- file if compiling with the -g option. These files are only
2044 -- useful if debugging. 2072 -- useful if debugging.
2045 2073
2046 if not Debug_Flag_Present then 2074 if not Debug_Flag_Present then
2047 Delete (Binder_Ali_File.all & ASCII.NUL); 2075 Delete (Binder_Ali_File.all & ASCII.NUL);
2048 Delete (Binder_Spec_Src_File.all & ASCII.NUL); 2076 Delete (Binder_Spec_Src_File.all & ASCII.NUL);