annotate gcc/ada/gnatbind.adb @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- G N A T B I N D --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- B o d y --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
kono
parents:
diff changeset
17 -- for more details. You should have received a copy of the GNU General --
kono
parents:
diff changeset
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
kono
parents:
diff changeset
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
kono
parents:
diff changeset
20 -- --
kono
parents:
diff changeset
21 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
23 -- --
kono
parents:
diff changeset
24 ------------------------------------------------------------------------------
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 with ALI; use ALI;
kono
parents:
diff changeset
27 with ALI.Util; use ALI.Util;
kono
parents:
diff changeset
28 with Bcheck; use Bcheck;
kono
parents:
diff changeset
29 with Binde; use Binde;
kono
parents:
diff changeset
30 with Binderr; use Binderr;
kono
parents:
diff changeset
31 with Bindgen; use Bindgen;
kono
parents:
diff changeset
32 with Bindusg;
kono
parents:
diff changeset
33 with Casing; use Casing;
kono
parents:
diff changeset
34 with Csets;
kono
parents:
diff changeset
35 with Debug; use Debug;
kono
parents:
diff changeset
36 with Fmap;
kono
parents:
diff changeset
37 with Namet; use Namet;
kono
parents:
diff changeset
38 with Opt; use Opt;
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 with Osint; use Osint;
kono
parents:
diff changeset
41 -- Note that we use low-level routines in Osint to read command-line
kono
parents:
diff changeset
42 -- arguments. We cannot depend on Ada.Command_Line, because it contains modern
kono
parents:
diff changeset
43 -- Ada features that would break bootstrapping with old base compilers.
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 with Osint.B; use Osint.B;
kono
parents:
diff changeset
46 with Output; use Output;
kono
parents:
diff changeset
47 with Rident; use Rident;
kono
parents:
diff changeset
48 with Snames;
kono
parents:
diff changeset
49 with Switch; use Switch;
kono
parents:
diff changeset
50 with Switch.B; use Switch.B;
kono
parents:
diff changeset
51 with Targparm; use Targparm;
kono
parents:
diff changeset
52 with Types; use Types;
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 with System.Case_Util; use System.Case_Util;
kono
parents:
diff changeset
55 with System.Response_File;
kono
parents:
diff changeset
56 with System.OS_Lib; use System.OS_Lib;
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 procedure Gnatbind is
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 Total_Errors : Nat := 0;
kono
parents:
diff changeset
61 -- Counts total errors in all files
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 Total_Warnings : Nat := 0;
kono
parents:
diff changeset
64 -- Total warnings in all files
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 Main_Lib_File : File_Name_Type;
kono
parents:
diff changeset
67 -- Current main library file
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 First_Main_Lib_File : File_Name_Type := No_File;
kono
parents:
diff changeset
70 -- The first library file, that should be a main subprogram if neither -n
kono
parents:
diff changeset
71 -- nor -z are used.
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 Text : Text_Buffer_Ptr;
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 Output_File_Name_Seen : Boolean := False;
kono
parents:
diff changeset
76 Output_File_Name : String_Ptr := new String'("");
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 Mapping_File : String_Ptr := null;
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 procedure Add_Artificial_ALI_File (Name : String);
kono
parents:
diff changeset
81 -- Artificially add ALI file Name in the closure
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 function Gnatbind_Supports_Auto_Init return Boolean;
kono
parents:
diff changeset
84 -- Indicates if automatic initialization of elaboration procedure through
kono
parents:
diff changeset
85 -- the constructor mechanism is possible on the platform.
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 function Is_Cross_Compiler return Boolean;
kono
parents:
diff changeset
88 -- Returns True iff this is a cross-compiler
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 procedure List_Applicable_Restrictions;
kono
parents:
diff changeset
91 -- List restrictions that apply to this partition if option taken
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 procedure Scan_Bind_Arg (Argv : String);
kono
parents:
diff changeset
94 -- Scan and process binder specific arguments. Argv is a single argument.
kono
parents:
diff changeset
95 -- All the one character arguments are still handled by Switch. This
kono
parents:
diff changeset
96 -- routine handles -aO -aI and -I-. The lower bound of Argv must be 1.
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 generic
kono
parents:
diff changeset
99 with procedure Action (Argv : String);
kono
parents:
diff changeset
100 procedure Generic_Scan_Bind_Args;
kono
parents:
diff changeset
101 -- Iterate through the args calling Action on each one, taking care of
kono
parents:
diff changeset
102 -- response files.
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 procedure Write_Arg (S : String);
kono
parents:
diff changeset
105 -- Passed to Generic_Scan_Bind_Args to print args
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 -----------------------------
kono
parents:
diff changeset
108 -- Add_Artificial_ALI_File --
kono
parents:
diff changeset
109 -----------------------------
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 procedure Add_Artificial_ALI_File (Name : String) is
kono
parents:
diff changeset
112 Id : ALI_Id;
kono
parents:
diff changeset
113 pragma Warnings (Off, Id);
kono
parents:
diff changeset
114
kono
parents:
diff changeset
115 Std_Lib_File : File_Name_Type;
kono
parents:
diff changeset
116 -- Standard library
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 begin
kono
parents:
diff changeset
119 Name_Len := Name'Length;
kono
parents:
diff changeset
120 Name_Buffer (1 .. Name_Len) := Name;
kono
parents:
diff changeset
121 Std_Lib_File := Name_Find;
kono
parents:
diff changeset
122 Text := Read_Library_Info (Std_Lib_File, True);
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 Id :=
kono
parents:
diff changeset
125 Scan_ALI
kono
parents:
diff changeset
126 (F => Std_Lib_File,
kono
parents:
diff changeset
127 T => Text,
kono
parents:
diff changeset
128 Ignore_ED => False,
kono
parents:
diff changeset
129 Err => False,
kono
parents:
diff changeset
130 Ignore_Errors => Debug_Flag_I);
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 Free (Text);
kono
parents:
diff changeset
133 end Add_Artificial_ALI_File;
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 ---------------------------------
kono
parents:
diff changeset
136 -- Gnatbind_Supports_Auto_Init --
kono
parents:
diff changeset
137 ---------------------------------
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139 function Gnatbind_Supports_Auto_Init return Boolean is
kono
parents:
diff changeset
140 function gnat_binder_supports_auto_init return Integer;
kono
parents:
diff changeset
141 pragma Import (C, gnat_binder_supports_auto_init,
kono
parents:
diff changeset
142 "__gnat_binder_supports_auto_init");
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 begin
kono
parents:
diff changeset
145 return gnat_binder_supports_auto_init /= 0;
kono
parents:
diff changeset
146 end Gnatbind_Supports_Auto_Init;
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 -----------------------
kono
parents:
diff changeset
149 -- Is_Cross_Compiler --
kono
parents:
diff changeset
150 -----------------------
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 function Is_Cross_Compiler return Boolean is
kono
parents:
diff changeset
153 Cross_Compiler : Integer;
kono
parents:
diff changeset
154 pragma Import (C, Cross_Compiler, "__gnat_is_cross_compiler");
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 begin
kono
parents:
diff changeset
157 return Cross_Compiler = 1;
kono
parents:
diff changeset
158 end Is_Cross_Compiler;
kono
parents:
diff changeset
159
kono
parents:
diff changeset
160 ----------------------------------
kono
parents:
diff changeset
161 -- List_Applicable_Restrictions --
kono
parents:
diff changeset
162 ----------------------------------
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 procedure List_Applicable_Restrictions is
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 -- Define those restrictions that should be output if the gnatbind
kono
parents:
diff changeset
167 -- -r switch is used. Not all restrictions are output for the reasons
kono
parents:
diff changeset
168 -- given below in the list, and this array is used to test whether
kono
parents:
diff changeset
169 -- the corresponding pragma should be listed. True means that it
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
170 -- should be listed.
111
kono
parents:
diff changeset
171
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
172 Restrictions_To_List : constant array (All_Restrictions) of Boolean :=
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
173 (No_Standard_Allocators_After_Elaboration => False,
111
kono
parents:
diff changeset
174 -- This involves run-time conditions not checkable at compile time
kono
parents:
diff changeset
175
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
176 No_Anonymous_Allocators => False,
111
kono
parents:
diff changeset
177 -- Premature, since we have not implemented this yet
kono
parents:
diff changeset
178
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
179 No_Exception_Propagation => False,
111
kono
parents:
diff changeset
180 -- Modifies code resulting in different exception semantics
kono
parents:
diff changeset
181
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
182 No_Exceptions => False,
111
kono
parents:
diff changeset
183 -- Has unexpected Suppress (All_Checks) effect
kono
parents:
diff changeset
184
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
185 No_Implicit_Conditionals => False,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
186 -- This could modify and pessimize generated code
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
187
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
188 No_Implicit_Dynamic_Code => False,
111
kono
parents:
diff changeset
189 -- This could modify and pessimize generated code
kono
parents:
diff changeset
190
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
191 No_Implicit_Loops => False,
111
kono
parents:
diff changeset
192 -- This could modify and pessimize generated code
kono
parents:
diff changeset
193
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
194 No_Recursion => False,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
195 -- Not checkable at compile time
111
kono
parents:
diff changeset
196
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
197 No_Reentrancy => False,
111
kono
parents:
diff changeset
198 -- Not checkable at compile time
kono
parents:
diff changeset
199
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
200 Max_Entry_Queue_Length => False,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
201 -- Not checkable at compile time
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
202
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
203 Max_Storage_At_Blocking => False,
111
kono
parents:
diff changeset
204 -- Not checkable at compile time
kono
parents:
diff changeset
205
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
206 No_Implementation_Restrictions => False,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
207 -- Listing this one would cause a chicken&egg problem; the program
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
208 -- doesn't use implementation-defined restrictions, but after
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
209 -- applying the listed restrictions, it probably WILL use them,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
210 -- so No_Implementation_Restrictions will cause an error.
111
kono
parents:
diff changeset
211
kono
parents:
diff changeset
212 -- The following three should not be partition-wide, so the
kono
parents:
diff changeset
213 -- following tests are junk to be removed eventually ???
kono
parents:
diff changeset
214
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
215 No_Specification_Of_Aspect => False,
111
kono
parents:
diff changeset
216 -- Requires a parameter value, not a count
kono
parents:
diff changeset
217
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
218 No_Use_Of_Attribute => False,
111
kono
parents:
diff changeset
219 -- Requires a parameter value, not a count
kono
parents:
diff changeset
220
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
221 No_Use_Of_Pragma => False,
111
kono
parents:
diff changeset
222 -- Requires a parameter value, not a count
kono
parents:
diff changeset
223
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
224 others => True);
111
kono
parents:
diff changeset
225
kono
parents:
diff changeset
226 Additional_Restrictions_Listed : Boolean := False;
kono
parents:
diff changeset
227 -- Set True if we have listed header for restrictions
kono
parents:
diff changeset
228
kono
parents:
diff changeset
229 function Restriction_Could_Be_Set (R : Restriction_Id) return Boolean;
kono
parents:
diff changeset
230 -- Returns True if the given restriction can be listed as an additional
kono
parents:
diff changeset
231 -- restriction that could be set.
kono
parents:
diff changeset
232
kono
parents:
diff changeset
233 ------------------------------
kono
parents:
diff changeset
234 -- Restriction_Could_Be_Set --
kono
parents:
diff changeset
235 ------------------------------
kono
parents:
diff changeset
236
kono
parents:
diff changeset
237 function Restriction_Could_Be_Set (R : Restriction_Id) return Boolean is
kono
parents:
diff changeset
238 CR : Restrictions_Info renames Cumulative_Restrictions;
kono
parents:
diff changeset
239
kono
parents:
diff changeset
240 begin
kono
parents:
diff changeset
241 case R is
kono
parents:
diff changeset
242
kono
parents:
diff changeset
243 -- Boolean restriction
kono
parents:
diff changeset
244
kono
parents:
diff changeset
245 when All_Boolean_Restrictions =>
kono
parents:
diff changeset
246
kono
parents:
diff changeset
247 -- The condition for listing a boolean restriction as an
kono
parents:
diff changeset
248 -- additional restriction that could be set is that it is
kono
parents:
diff changeset
249 -- not violated by any unit, and not already set.
kono
parents:
diff changeset
250
kono
parents:
diff changeset
251 return CR.Violated (R) = False and then CR.Set (R) = False;
kono
parents:
diff changeset
252
kono
parents:
diff changeset
253 -- Parameter restriction
kono
parents:
diff changeset
254
kono
parents:
diff changeset
255 when All_Parameter_Restrictions =>
kono
parents:
diff changeset
256
kono
parents:
diff changeset
257 -- If the restriction is violated and the level of violation is
kono
parents:
diff changeset
258 -- unknown, the restriction can definitely not be listed.
kono
parents:
diff changeset
259
kono
parents:
diff changeset
260 if CR.Violated (R) and then CR.Unknown (R) then
kono
parents:
diff changeset
261 return False;
kono
parents:
diff changeset
262
kono
parents:
diff changeset
263 -- We can list the restriction if it is not set
kono
parents:
diff changeset
264
kono
parents:
diff changeset
265 elsif not CR.Set (R) then
kono
parents:
diff changeset
266 return True;
kono
parents:
diff changeset
267
kono
parents:
diff changeset
268 -- We can list the restriction if is set to a greater value
kono
parents:
diff changeset
269 -- than the maximum value known for the violation.
kono
parents:
diff changeset
270
kono
parents:
diff changeset
271 else
kono
parents:
diff changeset
272 return CR.Value (R) > CR.Count (R);
kono
parents:
diff changeset
273 end if;
kono
parents:
diff changeset
274
kono
parents:
diff changeset
275 -- No other values for R possible
kono
parents:
diff changeset
276
kono
parents:
diff changeset
277 when others =>
kono
parents:
diff changeset
278 raise Program_Error;
kono
parents:
diff changeset
279 end case;
kono
parents:
diff changeset
280 end Restriction_Could_Be_Set;
kono
parents:
diff changeset
281
kono
parents:
diff changeset
282 -- Start of processing for List_Applicable_Restrictions
kono
parents:
diff changeset
283
kono
parents:
diff changeset
284 begin
kono
parents:
diff changeset
285 -- Loop through restrictions
kono
parents:
diff changeset
286
kono
parents:
diff changeset
287 for R in All_Restrictions loop
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
288 if Restrictions_To_List (R)
111
kono
parents:
diff changeset
289 and then Restriction_Could_Be_Set (R)
kono
parents:
diff changeset
290 then
kono
parents:
diff changeset
291 if not Additional_Restrictions_Listed then
kono
parents:
diff changeset
292 Write_Eol;
kono
parents:
diff changeset
293 Write_Line
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
294 ("-- The following additional restrictions may be applied "
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
295 & "to this partition:");
111
kono
parents:
diff changeset
296 Additional_Restrictions_Listed := True;
kono
parents:
diff changeset
297 end if;
kono
parents:
diff changeset
298
kono
parents:
diff changeset
299 Write_Str ("pragma Restrictions (");
kono
parents:
diff changeset
300
kono
parents:
diff changeset
301 declare
kono
parents:
diff changeset
302 S : constant String := Restriction_Id'Image (R);
kono
parents:
diff changeset
303
kono
parents:
diff changeset
304 begin
kono
parents:
diff changeset
305 Name_Len := S'Length;
kono
parents:
diff changeset
306 Name_Buffer (1 .. Name_Len) := S;
kono
parents:
diff changeset
307 end;
kono
parents:
diff changeset
308
kono
parents:
diff changeset
309 Set_Casing (Mixed_Case);
kono
parents:
diff changeset
310 Write_Str (Name_Buffer (1 .. Name_Len));
kono
parents:
diff changeset
311
kono
parents:
diff changeset
312 if R in All_Parameter_Restrictions then
kono
parents:
diff changeset
313 Write_Str (" => ");
kono
parents:
diff changeset
314 Write_Int (Int (Cumulative_Restrictions.Count (R)));
kono
parents:
diff changeset
315 end if;
kono
parents:
diff changeset
316
kono
parents:
diff changeset
317 Write_Str (");");
kono
parents:
diff changeset
318 Write_Eol;
kono
parents:
diff changeset
319 end if;
kono
parents:
diff changeset
320 end loop;
kono
parents:
diff changeset
321 end List_Applicable_Restrictions;
kono
parents:
diff changeset
322
kono
parents:
diff changeset
323 -------------------
kono
parents:
diff changeset
324 -- Scan_Bind_Arg --
kono
parents:
diff changeset
325 -------------------
kono
parents:
diff changeset
326
kono
parents:
diff changeset
327 procedure Scan_Bind_Arg (Argv : String) is
kono
parents:
diff changeset
328 pragma Assert (Argv'First = 1);
kono
parents:
diff changeset
329
kono
parents:
diff changeset
330 begin
kono
parents:
diff changeset
331 -- Now scan arguments that are specific to the binder and are not
kono
parents:
diff changeset
332 -- handled by the common circuitry in Switch.
kono
parents:
diff changeset
333
kono
parents:
diff changeset
334 if Opt.Output_File_Name_Present
kono
parents:
diff changeset
335 and then not Output_File_Name_Seen
kono
parents:
diff changeset
336 then
kono
parents:
diff changeset
337 Output_File_Name_Seen := True;
kono
parents:
diff changeset
338
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
339 if Argv'Length = 0 or else Argv (1) = '-' then
111
kono
parents:
diff changeset
340 Fail ("output File_Name missing after -o");
kono
parents:
diff changeset
341
kono
parents:
diff changeset
342 else
kono
parents:
diff changeset
343 Output_File_Name := new String'(Argv);
kono
parents:
diff changeset
344 end if;
kono
parents:
diff changeset
345
kono
parents:
diff changeset
346 elsif Argv'Length >= 2 and then Argv (1) = '-' then
kono
parents:
diff changeset
347
kono
parents:
diff changeset
348 -- -I-
kono
parents:
diff changeset
349
kono
parents:
diff changeset
350 if Argv (2 .. Argv'Last) = "I-" then
kono
parents:
diff changeset
351 Opt.Look_In_Primary_Dir := False;
kono
parents:
diff changeset
352
kono
parents:
diff changeset
353 -- -Idir
kono
parents:
diff changeset
354
kono
parents:
diff changeset
355 elsif Argv (2) = 'I' then
kono
parents:
diff changeset
356 Add_Src_Search_Dir (Argv (3 .. Argv'Last));
kono
parents:
diff changeset
357 Add_Lib_Search_Dir (Argv (3 .. Argv'Last));
kono
parents:
diff changeset
358
kono
parents:
diff changeset
359 -- -Ldir
kono
parents:
diff changeset
360
kono
parents:
diff changeset
361 elsif Argv (2) = 'L' then
kono
parents:
diff changeset
362 if Argv'Length >= 3 then
kono
parents:
diff changeset
363
kono
parents:
diff changeset
364 Opt.Bind_For_Library := True;
kono
parents:
diff changeset
365 Opt.Ada_Init_Name :=
kono
parents:
diff changeset
366 new String'(Argv (3 .. Argv'Last) & Opt.Ada_Init_Suffix);
kono
parents:
diff changeset
367 Opt.Ada_Final_Name :=
kono
parents:
diff changeset
368 new String'(Argv (3 .. Argv'Last) & Opt.Ada_Final_Suffix);
kono
parents:
diff changeset
369 Opt.Ada_Main_Name :=
kono
parents:
diff changeset
370 new String'(Argv (3 .. Argv'Last) & Opt.Ada_Main_Name_Suffix);
kono
parents:
diff changeset
371
kono
parents:
diff changeset
372 -- This option (-Lxxx) implies -n
kono
parents:
diff changeset
373
kono
parents:
diff changeset
374 Opt.Bind_Main_Program := False;
kono
parents:
diff changeset
375
kono
parents:
diff changeset
376 else
kono
parents:
diff changeset
377 Fail
kono
parents:
diff changeset
378 ("Prefix of initialization and finalization procedure names "
kono
parents:
diff changeset
379 & "missing in -L");
kono
parents:
diff changeset
380 end if;
kono
parents:
diff changeset
381
kono
parents:
diff changeset
382 -- -Sin -Slo -Shi -Sxx -Sev
kono
parents:
diff changeset
383
kono
parents:
diff changeset
384 elsif Argv'Length = 4
kono
parents:
diff changeset
385 and then Argv (2) = 'S'
kono
parents:
diff changeset
386 then
kono
parents:
diff changeset
387 declare
kono
parents:
diff changeset
388 C1 : Character := Argv (3);
kono
parents:
diff changeset
389 C2 : Character := Argv (4);
kono
parents:
diff changeset
390
kono
parents:
diff changeset
391 begin
kono
parents:
diff changeset
392 -- Fold to upper case
kono
parents:
diff changeset
393
kono
parents:
diff changeset
394 if C1 in 'a' .. 'z' then
kono
parents:
diff changeset
395 C1 := Character'Val (Character'Pos (C1) - 32);
kono
parents:
diff changeset
396 end if;
kono
parents:
diff changeset
397
kono
parents:
diff changeset
398 if C2 in 'a' .. 'z' then
kono
parents:
diff changeset
399 C2 := Character'Val (Character'Pos (C2) - 32);
kono
parents:
diff changeset
400 end if;
kono
parents:
diff changeset
401
kono
parents:
diff changeset
402 -- Test valid option and set mode accordingly
kono
parents:
diff changeset
403
kono
parents:
diff changeset
404 if C1 = 'E' and then C2 = 'V' then
kono
parents:
diff changeset
405 null;
kono
parents:
diff changeset
406
kono
parents:
diff changeset
407 elsif C1 = 'I' and then C2 = 'N' then
kono
parents:
diff changeset
408 null;
kono
parents:
diff changeset
409
kono
parents:
diff changeset
410 elsif C1 = 'L' and then C2 = 'O' then
kono
parents:
diff changeset
411 null;
kono
parents:
diff changeset
412
kono
parents:
diff changeset
413 elsif C1 = 'H' and then C2 = 'I' then
kono
parents:
diff changeset
414 null;
kono
parents:
diff changeset
415
kono
parents:
diff changeset
416 elsif (C1 in '0' .. '9' or else C1 in 'A' .. 'F')
kono
parents:
diff changeset
417 and then
kono
parents:
diff changeset
418 (C2 in '0' .. '9' or else C2 in 'A' .. 'F')
kono
parents:
diff changeset
419 then
kono
parents:
diff changeset
420 null;
kono
parents:
diff changeset
421
kono
parents:
diff changeset
422 -- Invalid -S switch, let Switch give error, set default of IN
kono
parents:
diff changeset
423
kono
parents:
diff changeset
424 else
kono
parents:
diff changeset
425 Scan_Binder_Switches (Argv);
kono
parents:
diff changeset
426 C1 := 'I';
kono
parents:
diff changeset
427 C2 := 'N';
kono
parents:
diff changeset
428 end if;
kono
parents:
diff changeset
429
kono
parents:
diff changeset
430 Initialize_Scalars_Mode1 := C1;
kono
parents:
diff changeset
431 Initialize_Scalars_Mode2 := C2;
kono
parents:
diff changeset
432 end;
kono
parents:
diff changeset
433
kono
parents:
diff changeset
434 -- -aIdir
kono
parents:
diff changeset
435
kono
parents:
diff changeset
436 elsif Argv'Length >= 3
kono
parents:
diff changeset
437 and then Argv (2 .. 3) = "aI"
kono
parents:
diff changeset
438 then
kono
parents:
diff changeset
439 Add_Src_Search_Dir (Argv (4 .. Argv'Last));
kono
parents:
diff changeset
440
kono
parents:
diff changeset
441 -- -aOdir
kono
parents:
diff changeset
442
kono
parents:
diff changeset
443 elsif Argv'Length >= 3
kono
parents:
diff changeset
444 and then Argv (2 .. 3) = "aO"
kono
parents:
diff changeset
445 then
kono
parents:
diff changeset
446 Add_Lib_Search_Dir (Argv (4 .. Argv'Last));
kono
parents:
diff changeset
447
kono
parents:
diff changeset
448 -- -nostdlib
kono
parents:
diff changeset
449
kono
parents:
diff changeset
450 elsif Argv (2 .. Argv'Last) = "nostdlib" then
kono
parents:
diff changeset
451 Opt.No_Stdlib := True;
kono
parents:
diff changeset
452
kono
parents:
diff changeset
453 -- -nostdinc
kono
parents:
diff changeset
454
kono
parents:
diff changeset
455 elsif Argv (2 .. Argv'Last) = "nostdinc" then
kono
parents:
diff changeset
456 Opt.No_Stdinc := True;
kono
parents:
diff changeset
457
kono
parents:
diff changeset
458 -- -static
kono
parents:
diff changeset
459
kono
parents:
diff changeset
460 elsif Argv (2 .. Argv'Last) = "static" then
kono
parents:
diff changeset
461 Opt.Shared_Libgnat := False;
kono
parents:
diff changeset
462
kono
parents:
diff changeset
463 -- -shared
kono
parents:
diff changeset
464
kono
parents:
diff changeset
465 elsif Argv (2 .. Argv'Last) = "shared" then
kono
parents:
diff changeset
466 Opt.Shared_Libgnat := True;
kono
parents:
diff changeset
467
kono
parents:
diff changeset
468 -- -F=mapping_file
kono
parents:
diff changeset
469
kono
parents:
diff changeset
470 elsif Argv'Length >= 4 and then Argv (2 .. 3) = "F=" then
kono
parents:
diff changeset
471 if Mapping_File /= null then
kono
parents:
diff changeset
472 Fail ("cannot specify several mapping files");
kono
parents:
diff changeset
473 end if;
kono
parents:
diff changeset
474
kono
parents:
diff changeset
475 Mapping_File := new String'(Argv (4 .. Argv'Last));
kono
parents:
diff changeset
476
kono
parents:
diff changeset
477 -- -Mname
kono
parents:
diff changeset
478
kono
parents:
diff changeset
479 elsif Argv'Length >= 3 and then Argv (2) = 'M' then
kono
parents:
diff changeset
480 if not Is_Cross_Compiler then
kono
parents:
diff changeset
481 Write_Line
kono
parents:
diff changeset
482 ("gnatbind: -M not expected to be used on native platforms");
kono
parents:
diff changeset
483 end if;
kono
parents:
diff changeset
484
kono
parents:
diff changeset
485 Opt.Bind_Alternate_Main_Name := True;
kono
parents:
diff changeset
486 Opt.Alternate_Main_Name := new String'(Argv (3 .. Argv'Last));
kono
parents:
diff changeset
487
kono
parents:
diff changeset
488 -- All other options are single character and are handled by
kono
parents:
diff changeset
489 -- Scan_Binder_Switches.
kono
parents:
diff changeset
490
kono
parents:
diff changeset
491 else
kono
parents:
diff changeset
492 Scan_Binder_Switches (Argv);
kono
parents:
diff changeset
493 end if;
kono
parents:
diff changeset
494
kono
parents:
diff changeset
495 -- Not a switch, so must be a file name (if non-empty)
kono
parents:
diff changeset
496
kono
parents:
diff changeset
497 elsif Argv'Length /= 0 then
kono
parents:
diff changeset
498 if Argv'Length > 4
kono
parents:
diff changeset
499 and then Argv (Argv'Last - 3 .. Argv'Last) = ".ali"
kono
parents:
diff changeset
500 then
kono
parents:
diff changeset
501 Add_File (Argv);
kono
parents:
diff changeset
502 else
kono
parents:
diff changeset
503 Add_File (Argv & ".ali");
kono
parents:
diff changeset
504 end if;
kono
parents:
diff changeset
505 end if;
kono
parents:
diff changeset
506 end Scan_Bind_Arg;
kono
parents:
diff changeset
507
kono
parents:
diff changeset
508 ----------------------------
kono
parents:
diff changeset
509 -- Generic_Scan_Bind_Args --
kono
parents:
diff changeset
510 ----------------------------
kono
parents:
diff changeset
511
kono
parents:
diff changeset
512 procedure Generic_Scan_Bind_Args is
kono
parents:
diff changeset
513 Next_Arg : Positive := 1;
kono
parents:
diff changeset
514
kono
parents:
diff changeset
515 begin
kono
parents:
diff changeset
516 while Next_Arg < Arg_Count loop
kono
parents:
diff changeset
517 declare
kono
parents:
diff changeset
518 Next_Argv : String (1 .. Len_Arg (Next_Arg));
kono
parents:
diff changeset
519
kono
parents:
diff changeset
520 begin
kono
parents:
diff changeset
521 Fill_Arg (Next_Argv'Address, Next_Arg);
kono
parents:
diff changeset
522
kono
parents:
diff changeset
523 if Next_Argv'Length > 0 then
kono
parents:
diff changeset
524 if Next_Argv (1) = '@' then
kono
parents:
diff changeset
525 if Next_Argv'Length > 1 then
kono
parents:
diff changeset
526 declare
kono
parents:
diff changeset
527 Arguments : constant Argument_List :=
kono
parents:
diff changeset
528 System.Response_File.Arguments_From
kono
parents:
diff changeset
529 (Response_File_Name =>
kono
parents:
diff changeset
530 Next_Argv (2 .. Next_Argv'Last),
kono
parents:
diff changeset
531 Recursive => True,
kono
parents:
diff changeset
532 Ignore_Non_Existing_Files => True);
kono
parents:
diff changeset
533 begin
kono
parents:
diff changeset
534 for J in Arguments'Range loop
kono
parents:
diff changeset
535 Action (Arguments (J).all);
kono
parents:
diff changeset
536 end loop;
kono
parents:
diff changeset
537 end;
kono
parents:
diff changeset
538 end if;
kono
parents:
diff changeset
539
kono
parents:
diff changeset
540 else
kono
parents:
diff changeset
541 Action (Next_Argv);
kono
parents:
diff changeset
542 end if;
kono
parents:
diff changeset
543 end if;
kono
parents:
diff changeset
544 end;
kono
parents:
diff changeset
545
kono
parents:
diff changeset
546 Next_Arg := Next_Arg + 1;
kono
parents:
diff changeset
547 end loop;
kono
parents:
diff changeset
548 end Generic_Scan_Bind_Args;
kono
parents:
diff changeset
549
kono
parents:
diff changeset
550 ---------------
kono
parents:
diff changeset
551 -- Write_Arg --
kono
parents:
diff changeset
552 ---------------
kono
parents:
diff changeset
553
kono
parents:
diff changeset
554 procedure Write_Arg (S : String) is
kono
parents:
diff changeset
555 begin
kono
parents:
diff changeset
556 Write_Str (" " & S);
kono
parents:
diff changeset
557 end Write_Arg;
kono
parents:
diff changeset
558
kono
parents:
diff changeset
559 procedure Check_Version_And_Help is
kono
parents:
diff changeset
560 new Check_Version_And_Help_G (Bindusg.Display);
kono
parents:
diff changeset
561
kono
parents:
diff changeset
562 procedure Put_Bind_Args is new Generic_Scan_Bind_Args (Write_Arg);
kono
parents:
diff changeset
563 procedure Scan_Bind_Args is new Generic_Scan_Bind_Args (Scan_Bind_Arg);
kono
parents:
diff changeset
564
kono
parents:
diff changeset
565 -- Start of processing for Gnatbind
kono
parents:
diff changeset
566
kono
parents:
diff changeset
567 begin
kono
parents:
diff changeset
568 -- Set default for Shared_Libgnat option
kono
parents:
diff changeset
569
kono
parents:
diff changeset
570 declare
kono
parents:
diff changeset
571 Shared_Libgnat_Default : Character;
kono
parents:
diff changeset
572 pragma Import
kono
parents:
diff changeset
573 (C, Shared_Libgnat_Default, "__gnat_shared_libgnat_default");
kono
parents:
diff changeset
574
kono
parents:
diff changeset
575 SHARED : constant Character := 'H';
kono
parents:
diff changeset
576 STATIC : constant Character := 'T';
kono
parents:
diff changeset
577
kono
parents:
diff changeset
578 begin
kono
parents:
diff changeset
579 pragma Assert
kono
parents:
diff changeset
580 (Shared_Libgnat_Default = SHARED
kono
parents:
diff changeset
581 or else
kono
parents:
diff changeset
582 Shared_Libgnat_Default = STATIC);
kono
parents:
diff changeset
583 Shared_Libgnat := (Shared_Libgnat_Default = SHARED);
kono
parents:
diff changeset
584 end;
kono
parents:
diff changeset
585
kono
parents:
diff changeset
586 -- Carry out package initializations. These are initializations which
kono
parents:
diff changeset
587 -- might logically be performed at elaboration time, and we decide to be
kono
parents:
diff changeset
588 -- consistent. Like elaboration, the order in which these calls are made
kono
parents:
diff changeset
589 -- is in some cases important.
kono
parents:
diff changeset
590
kono
parents:
diff changeset
591 Csets.Initialize;
kono
parents:
diff changeset
592 Snames.Initialize;
kono
parents:
diff changeset
593
kono
parents:
diff changeset
594 -- Scan the switches and arguments. Note that Snames must already be
kono
parents:
diff changeset
595 -- initialized (for processing of the -V switch).
kono
parents:
diff changeset
596
kono
parents:
diff changeset
597 -- First, scan to detect --version and/or --help
kono
parents:
diff changeset
598
kono
parents:
diff changeset
599 Check_Version_And_Help ("GNATBIND", "1992");
kono
parents:
diff changeset
600
kono
parents:
diff changeset
601 -- We need to Scan_Bind_Args first, to set Verbose_Mode, so we know whether
kono
parents:
diff changeset
602 -- to Put_Bind_Args.
kono
parents:
diff changeset
603
kono
parents:
diff changeset
604 Scan_Bind_Args;
kono
parents:
diff changeset
605
kono
parents:
diff changeset
606 if Verbose_Mode then
kono
parents:
diff changeset
607 declare
kono
parents:
diff changeset
608 Command_Name : String (1 .. Len_Arg (0));
kono
parents:
diff changeset
609 begin
kono
parents:
diff changeset
610 Fill_Arg (Command_Name'Address, 0);
kono
parents:
diff changeset
611 Write_Str (Command_Name);
kono
parents:
diff changeset
612 end;
kono
parents:
diff changeset
613
kono
parents:
diff changeset
614 Put_Bind_Args;
kono
parents:
diff changeset
615 Write_Eol;
kono
parents:
diff changeset
616 end if;
kono
parents:
diff changeset
617
kono
parents:
diff changeset
618 if Use_Pragma_Linker_Constructor then
kono
parents:
diff changeset
619 if Bind_Main_Program then
kono
parents:
diff changeset
620 Fail ("switch -a must be used in conjunction with -n or -Lxxx");
kono
parents:
diff changeset
621
kono
parents:
diff changeset
622 elsif not Gnatbind_Supports_Auto_Init then
kono
parents:
diff changeset
623 Fail ("automatic initialisation of elaboration not supported on this "
kono
parents:
diff changeset
624 & "platform");
kono
parents:
diff changeset
625 end if;
kono
parents:
diff changeset
626 end if;
kono
parents:
diff changeset
627
kono
parents:
diff changeset
628 -- Test for trailing -o switch
kono
parents:
diff changeset
629
kono
parents:
diff changeset
630 if Opt.Output_File_Name_Present and then not Output_File_Name_Seen then
kono
parents:
diff changeset
631 Fail ("output file name missing after -o");
kono
parents:
diff changeset
632 end if;
kono
parents:
diff changeset
633
kono
parents:
diff changeset
634 -- Output usage if requested
kono
parents:
diff changeset
635
kono
parents:
diff changeset
636 if Usage_Requested then
kono
parents:
diff changeset
637 Bindusg.Display;
kono
parents:
diff changeset
638 end if;
kono
parents:
diff changeset
639
kono
parents:
diff changeset
640 -- Check that the binder file specified has extension .adb
kono
parents:
diff changeset
641
kono
parents:
diff changeset
642 if Opt.Output_File_Name_Present and then Output_File_Name_Seen then
kono
parents:
diff changeset
643 Check_Extensions : declare
kono
parents:
diff changeset
644 Length : constant Natural := Output_File_Name'Length;
kono
parents:
diff changeset
645 Last : constant Natural := Output_File_Name'Last;
kono
parents:
diff changeset
646
kono
parents:
diff changeset
647 begin
kono
parents:
diff changeset
648 if Length <= 4
kono
parents:
diff changeset
649 or else Output_File_Name (Last - 3 .. Last) /= ".adb"
kono
parents:
diff changeset
650 then
kono
parents:
diff changeset
651 Fail ("output file name should have .adb extension");
kono
parents:
diff changeset
652 end if;
kono
parents:
diff changeset
653 end Check_Extensions;
kono
parents:
diff changeset
654 end if;
kono
parents:
diff changeset
655
kono
parents:
diff changeset
656 Osint.Add_Default_Search_Dirs;
kono
parents:
diff changeset
657
kono
parents:
diff changeset
658 -- Acquire target parameters
kono
parents:
diff changeset
659
kono
parents:
diff changeset
660 Targparm.Get_Target_Parameters;
kono
parents:
diff changeset
661
kono
parents:
diff changeset
662 -- Initialize Cumulative_Restrictions with the restrictions on the target
kono
parents:
diff changeset
663 -- scanned from the system.ads file. Then as we read ALI files, we will
kono
parents:
diff changeset
664 -- accumulate additional restrictions specified in other files.
kono
parents:
diff changeset
665
kono
parents:
diff changeset
666 Cumulative_Restrictions := Targparm.Restrictions_On_Target;
kono
parents:
diff changeset
667
kono
parents:
diff changeset
668 -- Acquire configurable run-time mode
kono
parents:
diff changeset
669
kono
parents:
diff changeset
670 if Configurable_Run_Time_On_Target then
kono
parents:
diff changeset
671 Configurable_Run_Time_Mode := True;
kono
parents:
diff changeset
672 end if;
kono
parents:
diff changeset
673
kono
parents:
diff changeset
674 -- Output copyright notice if in verbose mode
kono
parents:
diff changeset
675
kono
parents:
diff changeset
676 if Verbose_Mode then
kono
parents:
diff changeset
677 Write_Eol;
kono
parents:
diff changeset
678 Display_Version ("GNATBIND", "1995");
kono
parents:
diff changeset
679 end if;
kono
parents:
diff changeset
680
kono
parents:
diff changeset
681 -- Output usage information if no arguments
kono
parents:
diff changeset
682
kono
parents:
diff changeset
683 if not More_Lib_Files then
kono
parents:
diff changeset
684 if Arg_Count = 0 then
kono
parents:
diff changeset
685 Bindusg.Display;
kono
parents:
diff changeset
686 else
kono
parents:
diff changeset
687 Write_Line ("try ""gnatbind --help"" for more information.");
kono
parents:
diff changeset
688 end if;
kono
parents:
diff changeset
689
kono
parents:
diff changeset
690 Exit_Program (E_Fatal);
kono
parents:
diff changeset
691 end if;
kono
parents:
diff changeset
692
kono
parents:
diff changeset
693 -- If a mapping file was specified, initialize the file mapping
kono
parents:
diff changeset
694
kono
parents:
diff changeset
695 if Mapping_File /= null then
kono
parents:
diff changeset
696 Fmap.Initialize (Mapping_File.all);
kono
parents:
diff changeset
697 end if;
kono
parents:
diff changeset
698
kono
parents:
diff changeset
699 -- The block here is to catch the Unrecoverable_Error exception in the
kono
parents:
diff changeset
700 -- case where we exceed the maximum number of permissible errors or some
kono
parents:
diff changeset
701 -- other unrecoverable error occurs.
kono
parents:
diff changeset
702
kono
parents:
diff changeset
703 begin
kono
parents:
diff changeset
704 -- Initialize binder packages
kono
parents:
diff changeset
705
kono
parents:
diff changeset
706 Initialize_Binderr;
kono
parents:
diff changeset
707 Initialize_ALI;
kono
parents:
diff changeset
708 Initialize_ALI_Source;
kono
parents:
diff changeset
709
kono
parents:
diff changeset
710 if Verbose_Mode then
kono
parents:
diff changeset
711 Write_Eol;
kono
parents:
diff changeset
712 end if;
kono
parents:
diff changeset
713
kono
parents:
diff changeset
714 -- Input ALI files
kono
parents:
diff changeset
715
kono
parents:
diff changeset
716 while More_Lib_Files loop
kono
parents:
diff changeset
717 Main_Lib_File := Next_Main_Lib_File;
kono
parents:
diff changeset
718
kono
parents:
diff changeset
719 if First_Main_Lib_File = No_File then
kono
parents:
diff changeset
720 First_Main_Lib_File := Main_Lib_File;
kono
parents:
diff changeset
721 end if;
kono
parents:
diff changeset
722
kono
parents:
diff changeset
723 if Verbose_Mode then
kono
parents:
diff changeset
724 if Check_Only then
kono
parents:
diff changeset
725 Write_Str ("Checking: ");
kono
parents:
diff changeset
726 else
kono
parents:
diff changeset
727 Write_Str ("Binding: ");
kono
parents:
diff changeset
728 end if;
kono
parents:
diff changeset
729
kono
parents:
diff changeset
730 Write_Name (Main_Lib_File);
kono
parents:
diff changeset
731 Write_Eol;
kono
parents:
diff changeset
732 end if;
kono
parents:
diff changeset
733
kono
parents:
diff changeset
734 Text := Read_Library_Info (Main_Lib_File, True);
kono
parents:
diff changeset
735
kono
parents:
diff changeset
736 declare
kono
parents:
diff changeset
737 Id : ALI_Id;
kono
parents:
diff changeset
738 pragma Warnings (Off, Id);
kono
parents:
diff changeset
739
kono
parents:
diff changeset
740 begin
kono
parents:
diff changeset
741 Id := Scan_ALI
kono
parents:
diff changeset
742 (F => Main_Lib_File,
kono
parents:
diff changeset
743 T => Text,
kono
parents:
diff changeset
744 Ignore_ED => False,
kono
parents:
diff changeset
745 Err => False,
kono
parents:
diff changeset
746 Ignore_Errors => Debug_Flag_I,
kono
parents:
diff changeset
747 Directly_Scanned => True);
kono
parents:
diff changeset
748 end;
kono
parents:
diff changeset
749
kono
parents:
diff changeset
750 Free (Text);
kono
parents:
diff changeset
751 end loop;
kono
parents:
diff changeset
752
kono
parents:
diff changeset
753 -- No_Run_Time mode
kono
parents:
diff changeset
754
kono
parents:
diff changeset
755 if No_Run_Time_Mode then
kono
parents:
diff changeset
756
kono
parents:
diff changeset
757 -- Set standard configuration parameters
kono
parents:
diff changeset
758
kono
parents:
diff changeset
759 Suppress_Standard_Library_On_Target := True;
kono
parents:
diff changeset
760 Configurable_Run_Time_Mode := True;
kono
parents:
diff changeset
761 end if;
kono
parents:
diff changeset
762
kono
parents:
diff changeset
763 -- For main ALI files, even if they are interfaces, we get their
kono
parents:
diff changeset
764 -- dependencies. To be sure, we reset the Interface flag for all main
kono
parents:
diff changeset
765 -- ALI files.
kono
parents:
diff changeset
766
kono
parents:
diff changeset
767 for Index in ALIs.First .. ALIs.Last loop
kono
parents:
diff changeset
768 ALIs.Table (Index).SAL_Interface := False;
kono
parents:
diff changeset
769 end loop;
kono
parents:
diff changeset
770
kono
parents:
diff changeset
771 -- Add System.Standard_Library to list to ensure that these files are
kono
parents:
diff changeset
772 -- included in the bind, even if not directly referenced from Ada code
kono
parents:
diff changeset
773 -- This is suppressed if the appropriate targparm switch is set. Be sure
kono
parents:
diff changeset
774 -- in any case that System is in the closure, as it may contain linker
kono
parents:
diff changeset
775 -- options. Note that it will be automatically added if s-stalib is
kono
parents:
diff changeset
776 -- added.
kono
parents:
diff changeset
777
kono
parents:
diff changeset
778 if not Suppress_Standard_Library_On_Target then
kono
parents:
diff changeset
779 Add_Artificial_ALI_File ("s-stalib.ali");
kono
parents:
diff changeset
780 else
kono
parents:
diff changeset
781 Add_Artificial_ALI_File ("system.ali");
kono
parents:
diff changeset
782 end if;
kono
parents:
diff changeset
783
kono
parents:
diff changeset
784 -- Load ALIs for all dependent units
kono
parents:
diff changeset
785
kono
parents:
diff changeset
786 for Index in ALIs.First .. ALIs.Last loop
kono
parents:
diff changeset
787 Read_Withed_ALIs (Index);
kono
parents:
diff changeset
788 end loop;
kono
parents:
diff changeset
789
kono
parents:
diff changeset
790 -- Quit if some file needs compiling
kono
parents:
diff changeset
791
kono
parents:
diff changeset
792 if No_Object_Specified then
kono
parents:
diff changeset
793 raise Unrecoverable_Error;
kono
parents:
diff changeset
794 end if;
kono
parents:
diff changeset
795
kono
parents:
diff changeset
796 -- Quit with message if we had a GNATprove file
kono
parents:
diff changeset
797
kono
parents:
diff changeset
798 if GNATprove_Mode_Specified then
kono
parents:
diff changeset
799 Error_Msg ("one or more files compiled in GNATprove mode");
kono
parents:
diff changeset
800 raise Unrecoverable_Error;
kono
parents:
diff changeset
801 end if;
kono
parents:
diff changeset
802
kono
parents:
diff changeset
803 -- Output list of ALI files in closure
kono
parents:
diff changeset
804
kono
parents:
diff changeset
805 if Output_ALI_List then
kono
parents:
diff changeset
806 if ALI_List_Filename /= null then
kono
parents:
diff changeset
807 Set_List_File (ALI_List_Filename.all);
kono
parents:
diff changeset
808 end if;
kono
parents:
diff changeset
809
kono
parents:
diff changeset
810 for Index in ALIs.First .. ALIs.Last loop
kono
parents:
diff changeset
811 declare
kono
parents:
diff changeset
812 Full_Afile : constant File_Name_Type :=
kono
parents:
diff changeset
813 Find_File (ALIs.Table (Index).Afile, Library);
kono
parents:
diff changeset
814 begin
kono
parents:
diff changeset
815 Write_Name (Full_Afile);
kono
parents:
diff changeset
816 Write_Eol;
kono
parents:
diff changeset
817 end;
kono
parents:
diff changeset
818 end loop;
kono
parents:
diff changeset
819
kono
parents:
diff changeset
820 if ALI_List_Filename /= null then
kono
parents:
diff changeset
821 Close_List_File;
kono
parents:
diff changeset
822 end if;
kono
parents:
diff changeset
823 end if;
kono
parents:
diff changeset
824
kono
parents:
diff changeset
825 -- Build source file table from the ALI files we have read in
kono
parents:
diff changeset
826
kono
parents:
diff changeset
827 Set_Source_Table;
kono
parents:
diff changeset
828
kono
parents:
diff changeset
829 -- If there is main program to bind, set Main_Lib_File to the first
kono
parents:
diff changeset
830 -- library file, and the name from which to derive the binder generate
kono
parents:
diff changeset
831 -- file to the first ALI file.
kono
parents:
diff changeset
832
kono
parents:
diff changeset
833 if Bind_Main_Program then
kono
parents:
diff changeset
834 Main_Lib_File := First_Main_Lib_File;
kono
parents:
diff changeset
835 Set_Current_File_Name_Index (To => 1);
kono
parents:
diff changeset
836 end if;
kono
parents:
diff changeset
837
kono
parents:
diff changeset
838 -- Check that main library file is a suitable main program
kono
parents:
diff changeset
839
kono
parents:
diff changeset
840 if Bind_Main_Program
kono
parents:
diff changeset
841 and then ALIs.Table (ALIs.First).Main_Program = None
kono
parents:
diff changeset
842 and then not No_Main_Subprogram
kono
parents:
diff changeset
843 then
kono
parents:
diff changeset
844 Get_Name_String
kono
parents:
diff changeset
845 (Units.Table (ALIs.Table (ALIs.First).First_Unit).Uname);
kono
parents:
diff changeset
846
kono
parents:
diff changeset
847 declare
kono
parents:
diff changeset
848 Unit_Name : String := Name_Buffer (1 .. Name_Len - 2);
kono
parents:
diff changeset
849 begin
kono
parents:
diff changeset
850 To_Mixed (Unit_Name);
kono
parents:
diff changeset
851 Get_Name_String (ALIs.Table (ALIs.First).Sfile);
kono
parents:
diff changeset
852 Add_Str_To_Name_Buffer (":1: ");
kono
parents:
diff changeset
853 Add_Str_To_Name_Buffer (Unit_Name);
kono
parents:
diff changeset
854 Add_Str_To_Name_Buffer (" cannot be used as a main program");
kono
parents:
diff changeset
855 Write_Line (Name_Buffer (1 .. Name_Len));
kono
parents:
diff changeset
856 Errors_Detected := Errors_Detected + 1;
kono
parents:
diff changeset
857 end;
kono
parents:
diff changeset
858 end if;
kono
parents:
diff changeset
859
kono
parents:
diff changeset
860 -- Perform consistency and correctness checks. Disable these in CodePeer
kono
parents:
diff changeset
861 -- mode where we want to be more flexible.
kono
parents:
diff changeset
862
kono
parents:
diff changeset
863 if not CodePeer_Mode then
kono
parents:
diff changeset
864 Check_Duplicated_Subunits;
kono
parents:
diff changeset
865 Check_Versions;
kono
parents:
diff changeset
866 Check_Consistency;
kono
parents:
diff changeset
867 Check_Configuration_Consistency;
kono
parents:
diff changeset
868 end if;
kono
parents:
diff changeset
869
kono
parents:
diff changeset
870 -- List restrictions that could be applied to this partition
kono
parents:
diff changeset
871
kono
parents:
diff changeset
872 if List_Restrictions then
kono
parents:
diff changeset
873 List_Applicable_Restrictions;
kono
parents:
diff changeset
874 end if;
kono
parents:
diff changeset
875
kono
parents:
diff changeset
876 -- Complete bind if no errors
kono
parents:
diff changeset
877
kono
parents:
diff changeset
878 if Errors_Detected = 0 then
kono
parents:
diff changeset
879 declare
kono
parents:
diff changeset
880 Elab_Order : Unit_Id_Table;
kono
parents:
diff changeset
881 use Unit_Id_Tables;
kono
parents:
diff changeset
882
kono
parents:
diff changeset
883 begin
kono
parents:
diff changeset
884 Find_Elab_Order (Elab_Order, First_Main_Lib_File);
kono
parents:
diff changeset
885
kono
parents:
diff changeset
886 if Errors_Detected = 0 and then not Check_Only then
kono
parents:
diff changeset
887 Gen_Output_File
kono
parents:
diff changeset
888 (Output_File_Name.all,
kono
parents:
diff changeset
889 Elab_Order => Elab_Order.Table (First .. Last (Elab_Order)));
kono
parents:
diff changeset
890 end if;
kono
parents:
diff changeset
891 end;
kono
parents:
diff changeset
892 end if;
kono
parents:
diff changeset
893
kono
parents:
diff changeset
894 Total_Errors := Total_Errors + Errors_Detected;
kono
parents:
diff changeset
895 Total_Warnings := Total_Warnings + Warnings_Detected;
kono
parents:
diff changeset
896
kono
parents:
diff changeset
897 exception
kono
parents:
diff changeset
898 when Unrecoverable_Error =>
kono
parents:
diff changeset
899 Total_Errors := Total_Errors + Errors_Detected;
kono
parents:
diff changeset
900 Total_Warnings := Total_Warnings + Warnings_Detected;
kono
parents:
diff changeset
901 end;
kono
parents:
diff changeset
902
kono
parents:
diff changeset
903 -- All done. Set the proper exit status.
kono
parents:
diff changeset
904
kono
parents:
diff changeset
905 Finalize_Binderr;
kono
parents:
diff changeset
906 Namet.Finalize;
kono
parents:
diff changeset
907
kono
parents:
diff changeset
908 if Total_Errors > 0 then
kono
parents:
diff changeset
909 Exit_Program (E_Errors);
kono
parents:
diff changeset
910
kono
parents:
diff changeset
911 elsif Total_Warnings > 0 then
kono
parents:
diff changeset
912 Exit_Program (E_Warnings);
kono
parents:
diff changeset
913
kono
parents:
diff changeset
914 else
kono
parents:
diff changeset
915 -- Do not call Exit_Program (E_Success), so that finalization occurs
kono
parents:
diff changeset
916 -- normally.
kono
parents:
diff changeset
917
kono
parents:
diff changeset
918 null;
kono
parents:
diff changeset
919 end if;
kono
parents:
diff changeset
920 end Gnatbind;