41intnam.ads, [...]: Merge in ACT changes.
[gcc.git] / gcc / ada / lib-writ.ads
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- L I B . W R I T --
6 -- --
7 -- S p e c --
8 -- --
9 -- $Revision$
10 -- --
11 -- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
12 -- --
13 -- GNAT is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNAT; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
23 -- --
24 -- GNAT was originally developed by the GNAT team at New York University. --
25 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
26 -- --
27 ------------------------------------------------------------------------------
28
29 -- This package contains the routines for writing the library information
30
31 package Lib.Writ is
32
33 -----------------------------------
34 -- Format of Library Information --
35 -----------------------------------
36
37 -- Note: the contents of the ali file are summarized in the GNAT
38 -- user's guide, so if any non-trivial changes are made to this
39 -- section, they should be reflected in the user's guide.
40
41 -- This section describes the format of the library information that is
42 -- associated with object files. The exact method of this association is
43 -- potentially implementation dependent and is described and implemented
44 -- in package From the point of view of the description here, all we
45 -- need to know is that the information is represented as a string of
46 -- characters that is somehow associated with an object file, and can be
47 -- retrieved. If no library information exists for a given object file,
48 -- then we take this as equivalent to the non-existence of the object
49 -- file, as if source file has not been previously compiled.
50
51 -- The library information is written as a series of lines of the form:
52
53 -- Key_Character parameter parameter ...
54
55 ------------------
56 -- Header Lines --
57 ------------------
58
59 -- The initial header lines in the file give information about the
60 -- compilation environment, and identify other special information
61 -- such as main program parameters.
62
63 -- ----------------
64 -- -- V Version --
65 -- ----------------
66
67 -- V "xxxxxxxxxxxxxxxx"
68 --
69 -- This line indicates the library output version, as defined in
70 -- Gnatvsn. It ensures that separate object modules of a program are
71 -- consistent. It has to be changed if anything changes which would
72 -- affect successful binding of separately compiled modules.
73 -- Examples of such changes are modifications in the format of the
74 -- library info described in this package, or modifications to
75 -- calling sequences, or to the way that data is represented.
76
77 -- ---------------------
78 -- -- M Main Program --
79 -- ---------------------
80
81 -- M type [priority] [T=time-slice] W=?
82
83 -- This line appears only if the main unit for this file is
84 -- suitable for use as a main program. The parameters are:
85
86 -- type
87
88 -- P for a parameterless procedure
89 -- F for a function returning a value of integral type
90 -- (used for writing a main program returning an exit status)
91
92 -- priority
93
94 -- Present only if there was a valid pragma Priority in the
95 -- corresponding unit to set the main task priority. It is
96 -- an unsigned decimal integer.
97
98 -- T=time-slice
99
100 -- Present only if there was a valid pragma Time_Slice in the
101 -- corresponding unit. It is an unsigned decimal integer in
102 -- the range 0 .. 10**9 giving the time slice value in units
103 -- of milliseconds. The actual significance of this parameter
104 -- is target dependent.
105
106 -- W=?
107
108 -- This parameter indicates the wide character encoding
109 -- method used when compiling the main program file. The ?
110 -- character is the single character used in the -gnatW?
111 -- switch. This is used to provide the default wide-character
112 -- encoding for Wide_Text_IO files.
113
114 -- -----------------
115 -- -- A Argument --
116 -- -----------------
117
118 -- A argument
119
120 -- One of these lines appears for each of the arguments present
121 -- in the call to the gnat1 program. This can be used if it is
122 -- necessary to reconstruct this call (e.g. for fix and continue)
123
124 -- -------------------
125 -- -- P Parameters --
126 -- -------------------
127
128 -- P <<parameters>>
129
130 -- Indicates various information that applies to the compilation
131 -- of the corresponding source unit. Parameters is a sequence of
132 -- zero or more two letter codes that indicate configuration
133 -- pragmas and other parameters that apply:
134 --
135 -- Present if the unit uses tasking directly or indirectly and
136 -- has one or more valid xxx_Policy pragmas that apply to the unit.
137 -- The arguments are as follows:
138 --
139 -- CE Compilation errors. If this is present it means that the
140 -- ali file resulted from a compilation with the -gnatQ
141 -- switch set, and illegalities were detected. The ali
142 -- file contents may not be completely reliable, but the
143 -- format will be correct and complete. Note that NO is
144 -- always present if CE is present.
145 --
146 -- FD Configuration pragmas apply to all the units in this
147 -- file specifying a possibly non-standard floating point
148 -- format (VAX float with Long_Float using D_Float)
149 --
150 -- FG Configuration pragmas apply to all the units in this
151 -- file specifying a possibly non-standard floating point
152 -- format (VAX float with Long_Float using G_Float)
153 --
154 -- FI Configuration pragmas apply to all the units in this
155 -- file specifying a possibly non-standard floating point
156 -- format (IEEE Float)
157 --
158 -- Lx A valid Locking_Policy pragma applies to all the units
159 -- in this file, where x is the first character (upper case)
160 -- of the policy name (e.g. 'C' for Ceiling_Locking)
161 --
162 -- NO No object. This flag indicates that the units in this
163 -- file were not compiled to produce an object. This can
164 -- occur as a result of the use of -gnatc, or if no object
165 -- can be produced (e.g. when a package spec is compiled
166 -- instead of the body, or a subunit on its own).
167 --
168 -- NR No_Run_Time pragma in effect for all units in this file
169 --
170 -- NS Normalize_Scalars pragma in effect for all units in
171 -- this file
172 --
173 -- Qx A valid Queueing_Policy pragma applies to all the units
174 -- in this file, where x is the first character (upper case)
175 -- of the policy name (e.g. 'P' for Priority_Queueing).
176 --
177 -- Tx A valid Task_Dispatching_Policy pragma applies to all
178 -- the units in this file, where x is the first character
179 -- (upper case) of the corresponding policy name (e.g. 'F'
180 -- for FIFO_Within_Priorities).
181 --
182 -- UA Unreserve_All_Interrupts pragma was processed in one or
183 -- more units in this file
184 --
185 -- UX Generated code contains unit exception table pointer
186 -- (i.e. it uses zero-cost exceptions, and there is at
187 -- least one subprogram present).
188 --
189 -- ZX Units in this file use zero-cost exceptions and have
190 -- generated exception tables. If ZX is not present, the
191 -- longjmp/setjmp exception scheme is in use.
192 --
193 -- Note that language defined units never output policy (Lx,Tx,Qx)
194 -- parameters. Language defined units must correctly handle all
195 -- possible cases. These values are checked for consistency by the
196 -- binder and then copied to the generated binder output file.
197
198 -- ---------------------
199 -- -- R Restrictions --
200 -- ---------------------
201
202 -- R <<restriction-characters>>
203
204 -- This line records information regarding restrictions. The
205 -- parameter is a string of characters, one for each entry in
206 -- Restrict.Compilation_Unit_Restrictions, in order. There are
207 -- three settings possible settings for each restriction:
208
209 -- r Restricted. Unit was compiled under control of a pragma
210 -- Restrictions for the corresponding restriction. In
211 -- this case the unit certainly does not violate the
212 -- Restriction, since this would have been detected by
213 -- the compiler.
214
215 -- n Not used. The unit was not compiled under control of a
216 -- pragma Restrictions for the corresponding restriction,
217 -- and does not make any use of the referenced feature.
218
219 -- v Violated. The unit was not compiled under control of a
220 -- pragma Restrictions for the corresponding restriction,
221 -- and it does indeed use the referenced feature.
222
223 -- This information is used in the binder to check consistency,
224 -- i.e. to detect cases where one unit has "r" and another unit
225 -- has "v", which is not permitted, since these restrictions
226 -- are partition-wide.
227
228 ----------------------------
229 -- Compilation Unit Lines --
230 ----------------------------
231
232 -- Following these header lines, a set of information lines appears for
233 -- each compilation unit that appears in the corresponding object file.
234 -- In particular, when a package body or subprogram body is compiled,
235 -- there will be two sets of information, one for the spec and one for
236 -- the body. with the entry for the body appearing first. This is the
237 -- only case in which a single ALI file contains more than one unit (in
238 -- particular note that subunits do *not* count as compilation units for
239 -- this purpose, and generate no library information, since they are
240 -- inlined).
241
242 -- --------------------
243 -- -- U Unit Header --
244 -- --------------------
245
246 -- The lines for each compilation unit have the following form.
247
248 -- U unit-name source-name version <<attributes>>
249 --
250 -- This line identifies the unit to which this section of the
251 -- library information file applies. The first three parameters are
252 -- the unit name in internal format, as described in package Uname,
253 -- and the name of the source file containing the unit.
254 --
255 -- Version is the version given as eight hexadecimal characters
256 -- with upper case letters. This value is the exclusive or of the
257 -- source checksums of the unit and all its semantically dependent
258 -- units.
259 --
260 -- The <<attributes>> are a series of two letter codes indicating
261 -- information about the unit:
262 --
263 -- DE Dynamic Elaboration. This unit was compiled with the
264 -- dynamic elaboration model, as set by either the -gnatE
265 -- switch or pragma Elaboration_Checks (Dynamic).
266 --
267 -- EB Unit has pragma Elaborate_Body
268 --
269 -- EE Elaboration entity is present which must be set true when
270 -- the unit is elaborated. The name of the elaboration entity
271 -- is formed from the unit name in the usual way. If EE is
272 -- present, then this boolean must be set True as part of the
273 -- elaboration processing routine generated by the binder.
274 -- Note that EE can be set even if NE is set. This happens
275 -- when the boolean is needed solely for checking for the
276 -- case of access before elaboration.
277 --
278 -- GE Unit is a generic declaration, or corresponding body
279 --
280 -- IL Unit source uses a style with identifiers in all lower
281 -- IU case (IL) or all upper case (IU). If the standard mixed-
282 -- case usage is detected, or the compiler cannot determine
283 -- the style, then no I parameter will appear.
284 --
285 -- IS Initialize_Scalars pragma applies to this unit
286 --
287 -- KM Unit source uses a style with keywords in mixed case
288 -- KU (KM) or all upper case (KU). If the standard lower-case
289 -- usage is detected, or the compiler cannot determine the
290 -- style, then no K parameter will appear.
291 --
292 -- NE Unit has no elaboration routine. All subprogram bodies
293 -- and specs are in this category. Package bodies and specs
294 -- may or may not have NE set, depending on whether or not
295 -- elaboration code is required. Set if N_Compilation_Unit
296 -- node has flag Has_No_Elaboration_Code set.
297 --
298 -- PK Unit is package, rather than a subprogram
299 --
300 -- PU Unit has pragma Pure
301 --
302 -- PR Unit has pragma Preelaborate
303 --
304 -- RA Unit declares a Remote Access to Class-Wide (RACW) type
305 --
306 -- RC Unit has pragma Remote_Call_Interface
307 --
308 -- RT Unit has pragma Remote_Types
309 --
310 -- SP Unit has pragma Shared_Passive.
311 --
312 -- SU Unit is a subprogram, rather than a package
313 --
314 -- The attributes may appear in any order, separated by spaces.
315
316 -- ---------------------
317 -- -- W Withed Units --
318 -- ---------------------
319
320 -- Following each U line, is a series of lines of the form
321
322 -- W unit-name [source-name lib-name] [E] [EA] [ED]
323 --
324 -- One of these lines is present for each unit that is mentioned in
325 -- an explicit with clause by the current unit. The first parameter
326 -- is the unit name in internal format. The second parameter is the
327 -- file name of the file that must be compiled to compile this unit
328 -- (which is usually the file for the body, except for packages
329 -- which have no body). The third parameter is the file name of the
330 -- library information file that contains the results of compiling
331 -- this unit. The optional modifiers are used as follows:
332 --
333 -- E pragma Elaborate applies to this unit
334 --
335 -- EA pragma Elaborate_All applies to this unit
336 --
337 -- ED Elaborate_All_Desirable set for this unit, which means
338 -- that there is no Elaborate_All, but the analysis suggests
339 -- that Program_Error may be raised if the Elaborate_All
340 -- conditions cannot be satisfied. The binder will attempt
341 -- to treat ED as EA if it can.
342 --
343 -- The parameter source-name and lib-name are omitted for the case
344 -- of a generic unit compiled with earlier versions of GNAT which
345 -- did not generate object or ali files for generics.
346
347 -- -----------------------
348 -- -- L Linker_Options --
349 -- -----------------------
350
351 -- Following the W lines (if any, or the U line if not), are an
352 -- optional series of lines that indicates the usage of the pragma
353 -- Linker_Options in the associated unit. For each appearence of a
354 -- pragma Linker_Options (or Link_With) in the unit, a line is
355 -- present with the form:
356
357 -- L "string"
358
359 -- where string is the string from the unit line enclosed in quotes.
360 -- Within the quotes the following can occur:
361
362 -- c graphic characters in range 20-7E other than " or {
363 -- "" indicating a single " character
364 -- {hh} indicating a character whose code is hex hh (0-9,A-F)
365 -- {00} [ASCII.NUL] is used as a separator character
366 -- to separate multiple arguments of a single
367 -- Linker_Options pragma.
368
369 -- For further details, see Stringt.Write_String_Table_Entry. Note
370 -- that wide characters in the form {hhhh} cannot be produced, since
371 -- pragma Linker_Option accepts only String, not Wide_String.
372
373 -- The L lines are required to appear in the same order as the
374 -- corresponding Linker_Options (or Link_With) pragmas appear in
375 -- the source file, so that this order is preserved by the binder
376 -- in constructing the set of linker arguments.
377
378 ---------------------
379 -- Reference Lines --
380 ---------------------
381
382 -- The reference lines contain information about references from
383 -- any of the units in the compilation (including, body version
384 -- and version attributes, linker options pragmas and source
385 -- dependencies.
386
387 -- ------------------------------------
388 -- -- E External Version References --
389 -- ------------------------------------
390
391 -- One of these lines is present for each use of 'Body_Version or
392 -- 'Version in any of the units of the compilation. These are used
393 -- by the linker to determine which version symbols must be output.
394 -- The format is simply:
395
396 -- E name
397
398 -- where name is the external name, i.e. the unit name with either
399 -- a S or a B for spec or body version referenced (Body_Version
400 -- always references the body, Version references the Spec, except
401 -- in the case of a reference to a subprogram with no separate spec).
402 -- Upper half and wide character codes are encoded using the same
403 -- method as in Namet (Uhh for upper half, Whhhh for wide character,
404 -- where hh are hex digits).
405
406 -- ---------------------
407 -- -- D Dependencies --
408 -- ---------------------
409
410 -- The dependency lines indicate the source files on which the compiled
411 -- units depend. This is used by the binder for consistency checking.
412 -- These lines are also referenced by the cross-reference information.
413
414 -- D source-name time-stamp checksum [subunit-name] line:file-name
415
416 -- The time-stamp field contains the time stamp of the
417 -- corresponding source file. See types.ads for details on
418 -- time stamp representation.
419
420 -- The checksum is an 8-hex digit representation of the source
421 -- file checksum, with letters given in lower case.
422
423 -- The subunit name is present only if the dependency line is for
424 -- a subunit. It contains the fully qualified name of the subunit
425 -- in all lower case letters.
426
427 -- The line:file-name entry is present only if a Source_Reference
428 -- pragma appeared in the source file identified by source-name.
429 -- In this case, it gives the information from this pragma. Note
430 -- that this allows cross-reference information to be related back
431 -- to the original file. Note: the reason the line number comes
432 -- first is that a leading digit immediately identifies this as
433 -- a Source_Reference entry, rather than a subunit-name.
434
435 -- A line number of zero for line: in this entry indicates that
436 -- there is more than one source reference pragma. In this case,
437 -- the line numbers in the cross-reference are correct, and refer
438 -- to the original line number, but there is no information that
439 -- allows a reader of the ALI file to determine the exact mapping
440 -- of physical line numbers back to the original source.
441
442 -- Note: blank lines are ignored when the library information is
443 -- read, and separate sections of the file are separated by blank
444 -- lines to ease readability. Blanks between fields are also
445 -- ignored.
446
447 -- For entries corresponding to files that were not present (and
448 -- thus resulted in error messages), or for files that are not
449 -- part of the dependency set, both the time stamp and checksum
450 -- are set to all zero characters. These dummy entries are ignored
451 -- by the binder in dependency checking, but must be present for
452 -- proper interpretation of the cross-reference data.
453
454 --------------------------
455 -- Cross-Reference Data --
456 --------------------------
457
458 -- The cross-reference data follows the dependency lines. See
459 -- the spec of Lib.Xref for details on the format of this data.
460
461 -----------------
462 -- Subprograms --
463 -----------------
464
465 procedure Ensure_System_Dependency;
466 -- This procedure ensures that a dependency is created on system.ads.
467 -- Even if there is no semantic dependency, Targparm has read the
468 -- file to acquire target parameters, so we need a source dependency.
469
470 procedure Write_ALI (Object : Boolean);
471 -- This procedure writes the library information for the current main unit
472 -- The Object parameter is true if an object file is created, and false
473 -- otherwise.
474 --
475 -- Note: in the case where we are not generating code (-gnatc mode), this
476 -- routine only writes an ALI file if it cannot find an existing up to
477 -- date ALI file. If it *can* find an existing up to date ALI file, then
478 -- it reads this file and sets the Lib.Compilation_Arguments table from
479 -- the A lines in this file.
480
481 end Lib.Writ;