PR testsuite/39776
[official-gcc.git] / gcc / ada / mlib-prj.adb
blob67d9330ae9e12d125dfae8c48319c1c47fadc1c6
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- M L I B . P R J --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 2001-2009, AdaCore --
10 -- --
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- --
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- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
24 ------------------------------------------------------------------------------
26 with ALI; use ALI;
27 with Gnatvsn; use Gnatvsn;
28 with MLib.Fil; use MLib.Fil;
29 with MLib.Tgt; use MLib.Tgt;
30 with MLib.Utl; use MLib.Utl;
31 with Opt;
32 with Output; use Output;
33 with Prj.Com; use Prj.Com;
34 with Prj.Env; use Prj.Env;
35 with Prj.Util; use Prj.Util;
36 with Sinput.P;
37 with Snames; use Snames;
38 with Switch; use Switch;
39 with Table;
40 with Targparm; use Targparm;
41 with Tempdir;
42 with Types; use Types;
44 with Ada.Characters.Handling;
46 with GNAT.Directory_Operations; use GNAT.Directory_Operations;
47 with GNAT.HTable;
48 with Interfaces.C_Streams; use Interfaces.C_Streams;
49 with System; use System;
50 with System.Case_Util; use System.Case_Util;
52 package body MLib.Prj is
54 Prj_Add_Obj_Files : Types.Int;
55 pragma Import (C, Prj_Add_Obj_Files, "__gnat_prj_add_obj_files");
56 Add_Object_Files : constant Boolean := Prj_Add_Obj_Files /= 0;
57 -- Indicates if object files in pragmas Linker_Options (found in the
58 -- binder generated file) should be taken when linking a stand-alone
59 -- library. False for Windows, True for other platforms.
61 ALI_Suffix : constant String := ".ali";
63 B_Start : String_Ptr := new String'("b~");
64 -- Prefix of bind file, changed to b__ for VMS
66 S_Osinte_Ads : File_Name_Type := No_File;
67 -- Name_Id for "s-osinte.ads"
69 S_Dec_Ads : File_Name_Type := No_File;
70 -- Name_Id for "dec.ads"
72 G_Trasym_Ads : File_Name_Type := No_File;
73 -- Name_Id for "g-trasym.ads"
75 Arguments : String_List_Access := No_Argument;
76 -- Used to accumulate arguments for the invocation of gnatbind and of
77 -- the compiler. Also used to collect the interface ALI when copying
78 -- the ALI files to the library directory.
80 Argument_Number : Natural := 0;
81 -- Index of the last argument in Arguments
83 Initial_Argument_Max : constant := 10;
85 No_Main_String : aliased String := "-n";
86 No_Main : constant String_Access := No_Main_String'Access;
88 Output_Switch_String : aliased String := "-o";
89 Output_Switch : constant String_Access := Output_Switch_String'Access;
91 Compile_Switch_String : aliased String := "-c";
92 Compile_Switch : constant String_Access := Compile_Switch_String'Access;
94 Auto_Initialize : constant String := "-a";
96 -- List of objects to put inside the library
98 Object_Files : Argument_List_Access;
100 package Objects is new Table.Table
101 (Table_Name => "Mlib.Prj.Objects",
102 Table_Component_Type => String_Access,
103 Table_Index_Type => Natural,
104 Table_Low_Bound => 1,
105 Table_Initial => 50,
106 Table_Increment => 100);
108 package Objects_Htable is new GNAT.HTable.Simple_HTable
109 (Header_Num => Header_Num,
110 Element => Boolean,
111 No_Element => False,
112 Key => Name_Id,
113 Hash => Hash,
114 Equal => "=");
116 -- List of ALI files
118 Ali_Files : Argument_List_Access;
120 package ALIs is new Table.Table
121 (Table_Name => "Mlib.Prj.Alis",
122 Table_Component_Type => String_Access,
123 Table_Index_Type => Natural,
124 Table_Low_Bound => 1,
125 Table_Initial => 50,
126 Table_Increment => 100);
128 -- List of options set in the command line
130 Options : Argument_List_Access;
132 package Opts is new Table.Table
133 (Table_Name => "Mlib.Prj.Opts",
134 Table_Component_Type => String_Access,
135 Table_Index_Type => Natural,
136 Table_Low_Bound => 1,
137 Table_Initial => 5,
138 Table_Increment => 100);
140 -- All the ALI file in the library
142 package Library_ALIs is new GNAT.HTable.Simple_HTable
143 (Header_Num => Header_Num,
144 Element => Boolean,
145 No_Element => False,
146 Key => File_Name_Type,
147 Hash => Hash,
148 Equal => "=");
150 -- The ALI files in the interface sets
152 package Interface_ALIs is new GNAT.HTable.Simple_HTable
153 (Header_Num => Header_Num,
154 Element => Boolean,
155 No_Element => False,
156 Key => File_Name_Type,
157 Hash => Hash,
158 Equal => "=");
160 -- The ALI files that have been processed to check if the corresponding
161 -- library unit is in the interface set.
163 package Processed_ALIs is new GNAT.HTable.Simple_HTable
164 (Header_Num => Header_Num,
165 Element => Boolean,
166 No_Element => False,
167 Key => File_Name_Type,
168 Hash => Hash,
169 Equal => "=");
171 -- The projects imported directly or indirectly
173 package Processed_Projects is new GNAT.HTable.Simple_HTable
174 (Header_Num => Header_Num,
175 Element => Boolean,
176 No_Element => False,
177 Key => Name_Id,
178 Hash => Hash,
179 Equal => "=");
181 -- The library projects imported directly or indirectly
183 package Library_Projs is new Table.Table (
184 Table_Component_Type => Project_Id,
185 Table_Index_Type => Integer,
186 Table_Low_Bound => 1,
187 Table_Initial => 10,
188 Table_Increment => 10,
189 Table_Name => "Make.Library_Projs");
191 type Build_Mode_State is (None, Static, Dynamic, Relocatable);
193 procedure Add_Argument (S : String);
194 -- Add one argument to Arguments array, if array is full, double its size
196 function ALI_File_Name (Source : String) return String;
197 -- Return the ALI file name corresponding to a source
199 procedure Check (Filename : String);
200 -- Check if filename is a regular file. Fail if it is not
202 procedure Check_Context;
203 -- Check each object files in table Object_Files
204 -- Fail if any of them is not a regular file
206 procedure Copy_Interface_Sources
207 (For_Project : Project_Id;
208 In_Tree : Project_Tree_Ref;
209 Interfaces : Argument_List;
210 To_Dir : Path_Name_Type);
211 -- Copy the interface sources of a SAL to directory To_Dir
213 procedure Display (Executable : String);
214 -- Display invocation of gnatbind and of the compiler with the arguments
215 -- in Arguments, except when Quiet_Output is True.
217 function Index (S, Pattern : String) return Natural;
218 -- Return the last occurrence of Pattern in S, or 0 if none
220 procedure Process_Binder_File (Name : String);
221 -- For Stand-Alone libraries, get the Linker Options in the binder
222 -- generated file.
224 procedure Reset_Tables;
225 -- Make sure that all the above tables are empty
226 -- (Objects, Ali_Files, Options).
228 function SALs_Use_Constructors return Boolean;
229 -- Indicate if Stand-Alone Libraries are automatically initialized using
230 -- the constructor mechanism.
232 ------------------
233 -- Add_Argument --
234 ------------------
236 procedure Add_Argument (S : String) is
237 begin
238 if Argument_Number = Arguments'Last then
239 declare
240 New_Args : constant String_List_Access :=
241 new String_List (1 .. 2 * Arguments'Last);
243 begin
244 -- Copy the String_Accesses and set them to null in Arguments
245 -- so that they will not be deallocated by the call to
246 -- Free (Arguments).
248 New_Args (Arguments'Range) := Arguments.all;
249 Arguments.all := (others => null);
250 Free (Arguments);
251 Arguments := New_Args;
252 end;
253 end if;
255 Argument_Number := Argument_Number + 1;
256 Arguments (Argument_Number) := new String'(S);
257 end Add_Argument;
259 -------------------
260 -- ALI_File_Name --
261 -------------------
263 function ALI_File_Name (Source : String) return String is
264 begin
265 -- If the source name has an extension, then replace it with
266 -- the ALI suffix.
268 for Index in reverse Source'First + 1 .. Source'Last loop
269 if Source (Index) = '.' then
270 return Source (Source'First .. Index - 1) & ALI_Suffix;
271 end if;
272 end loop;
274 -- If there is no dot, or if it is the first character, just add the
275 -- ALI suffix.
277 return Source & ALI_Suffix;
278 end ALI_File_Name;
280 -------------------
281 -- Build_Library --
282 -------------------
284 procedure Build_Library
285 (For_Project : Project_Id;
286 In_Tree : Project_Tree_Ref;
287 Gnatbind : String;
288 Gnatbind_Path : String_Access;
289 Gcc : String;
290 Gcc_Path : String_Access;
291 Bind : Boolean := True;
292 Link : Boolean := True)
294 Maximum_Size : Integer;
295 pragma Import (C, Maximum_Size, "__gnat_link_max");
296 -- Maximum number of bytes to put in an invocation of the
297 -- gnatbind.
299 Size : Integer;
300 -- The number of bytes for the invocation of the gnatbind
302 Warning_For_Library : Boolean := False;
303 -- Set to True for the first warning about a unit missing from the
304 -- interface set.
306 Current_Proj : Project_Id;
308 Libgnarl_Needed : Yes_No_Unknown := For_Project.Libgnarl_Needed;
309 -- Set to True if library needs to be linked with libgnarl
311 Libdecgnat_Needed : Boolean := False;
312 -- On OpenVMS, set to True if library needs to be linked with libdecgnat
314 Gtrasymobj_Needed : Boolean := False;
315 -- On OpenVMS, set to True if library needs to be linked with
316 -- g-trasym.obj.
318 Object_Directory_Path : constant String :=
319 Get_Name_String
320 (For_Project.Object_Directory.Display_Name);
322 Standalone : constant Boolean := For_Project.Standalone_Library;
324 Project_Name : constant String := Get_Name_String (For_Project.Name);
326 Current_Dir : constant String := Get_Current_Dir;
328 Lib_Filename : String_Access;
329 Lib_Dirpath : String_Access;
330 Lib_Version : String_Access := new String'("");
332 The_Build_Mode : Build_Mode_State := None;
334 Success : Boolean := False;
336 Library_Options : Variable_Value := Nil_Variable_Value;
338 Driver_Name : Name_Id := No_Name;
340 In_Main_Object_Directory : Boolean := True;
342 Foreign_Sources : Boolean;
344 Rpath : String_Access := null;
345 -- Allocated only if Path Option is supported
347 Rpath_Last : Natural := 0;
348 -- Index of last valid character of Rpath
350 Initial_Rpath_Length : constant := 200;
351 -- Initial size of Rpath, when first allocated
353 Path_Option : String_Access := Linker_Library_Path_Option;
354 -- If null, Path Option is not supported.
355 -- Not a constant so that it can be deallocated.
357 First_ALI : File_Name_Type := No_File;
358 -- Store the ALI file name of a source of the library (the first found)
360 procedure Add_ALI_For (Source : File_Name_Type);
361 -- Add the name of the ALI file corresponding to Source to the
362 -- Arguments.
364 procedure Add_Rpath (Path : String);
365 -- Add a path name to Rpath
367 function Check_Project (P : Project_Id) return Boolean;
368 -- Returns True if P is For_Project or a project extended by For_Project
370 procedure Check_Libs (ALI_File : String; Main_Project : Boolean);
371 -- Set Libgnarl_Needed if the ALI_File indicates that there is a need
372 -- to link with -lgnarl (this is the case when there is a dependency
373 -- on s-osinte.ads). On OpenVMS, set Libdecgnat_Needed if the ALI file
374 -- indicates that there is a need to link with -ldecgnat (this is the
375 -- case when there is a dependency on dec.ads), and set
376 -- Gtrasymobj_Needed if there is a dependency on g-trasym.ads.
378 procedure Process (The_ALI : File_Name_Type);
379 -- Check if the closure of a library unit which is or should be in the
380 -- interface set is also in the interface set. Issue a warning for each
381 -- missing library unit.
383 procedure Process_Imported_Libraries;
384 -- Add the -L and -l switches for the imported Library Project Files,
385 -- and, if Path Option is supported, the library directory path names
386 -- to Rpath.
388 -----------------
389 -- Add_ALI_For --
390 -----------------
392 procedure Add_ALI_For (Source : File_Name_Type) is
393 ALI : constant String := ALI_File_Name (Get_Name_String (Source));
394 ALI_Id : File_Name_Type;
396 begin
397 if Bind then
398 Add_Argument (ALI);
399 end if;
401 Name_Len := 0;
402 Add_Str_To_Name_Buffer (S => ALI);
403 ALI_Id := Name_Find;
405 -- Add the ALI file name to the library ALIs
407 if Bind then
408 Library_ALIs.Set (ALI_Id, True);
409 end if;
411 -- Set First_ALI, if not already done
413 if First_ALI = No_File then
414 First_ALI := ALI_Id;
415 end if;
416 end Add_ALI_For;
418 ---------------
419 -- Add_Rpath --
420 ---------------
422 procedure Add_Rpath (Path : String) is
424 procedure Double;
425 -- Double Rpath size
427 ------------
428 -- Double --
429 ------------
431 procedure Double is
432 New_Rpath : constant String_Access :=
433 new String (1 .. 2 * Rpath'Length);
434 begin
435 New_Rpath (1 .. Rpath_Last) := Rpath (1 .. Rpath_Last);
436 Free (Rpath);
437 Rpath := New_Rpath;
438 end Double;
440 -- Start of processing for Add_Rpath
442 begin
443 -- If first path, allocate initial Rpath
445 if Rpath = null then
446 Rpath := new String (1 .. Initial_Rpath_Length);
447 Rpath_Last := 0;
449 else
450 -- Otherwise, add a path separator between two path names
452 if Rpath_Last = Rpath'Last then
453 Double;
454 end if;
456 Rpath_Last := Rpath_Last + 1;
457 Rpath (Rpath_Last) := Path_Separator;
458 end if;
460 -- Increase Rpath size until it is large enough
462 while Rpath_Last + Path'Length > Rpath'Last loop
463 Double;
464 end loop;
466 -- Add the path name
468 Rpath (Rpath_Last + 1 .. Rpath_Last + Path'Length) := Path;
469 Rpath_Last := Rpath_Last + Path'Length;
470 end Add_Rpath;
472 -------------------
473 -- Check_Project --
474 -------------------
476 function Check_Project (P : Project_Id) return Boolean is
477 begin
478 if P = For_Project then
479 return True;
481 elsif P /= No_Project then
482 declare
483 Proj : Project_Id;
485 begin
486 Proj := For_Project;
487 while Proj.Extends /= No_Project loop
488 if P = Proj.Extends then
489 return True;
490 end if;
492 Proj := Proj.Extends;
493 end loop;
494 end;
495 end if;
497 return False;
498 end Check_Project;
500 ----------------
501 -- Check_Libs --
502 ----------------
504 procedure Check_Libs (ALI_File : String; Main_Project : Boolean) is
505 Lib_File : File_Name_Type;
506 Text : Text_Buffer_Ptr;
507 Id : ALI.ALI_Id;
509 begin
510 if Libgnarl_Needed /= Yes
511 or else
512 (Main_Project
513 and then OpenVMS_On_Target
514 and then ((not Libdecgnat_Needed) or (not Gtrasymobj_Needed)))
515 then
516 -- Scan the ALI file
518 Name_Len := ALI_File'Length;
519 Name_Buffer (1 .. Name_Len) := ALI_File;
520 Lib_File := Name_Find;
521 Text := Read_Library_Info (Lib_File, True);
523 Id := ALI.Scan_ALI
524 (F => Lib_File,
525 T => Text,
526 Ignore_ED => False,
527 Err => True,
528 Read_Lines => "D");
529 Free (Text);
531 -- Look for s-osinte.ads in the dependencies
533 for Index in ALI.ALIs.Table (Id).First_Sdep ..
534 ALI.ALIs.Table (Id).Last_Sdep
535 loop
536 if ALI.Sdep.Table (Index).Sfile = S_Osinte_Ads then
537 Libgnarl_Needed := Yes;
539 if Main_Project then
540 For_Project.Libgnarl_Needed := Yes;
541 else
542 exit;
543 end if;
545 elsif OpenVMS_On_Target then
546 if ALI.Sdep.Table (Index).Sfile = S_Dec_Ads then
547 Libdecgnat_Needed := True;
549 elsif ALI.Sdep.Table (Index).Sfile = G_Trasym_Ads then
550 Gtrasymobj_Needed := True;
551 end if;
552 end if;
553 end loop;
554 end if;
555 end Check_Libs;
557 -------------
558 -- Process --
559 -------------
561 procedure Process (The_ALI : File_Name_Type) is
562 Text : Text_Buffer_Ptr;
563 Idread : ALI_Id;
564 First_Unit : ALI.Unit_Id;
565 Last_Unit : ALI.Unit_Id;
566 Unit_Data : Unit_Record;
567 Afile : File_Name_Type;
569 begin
570 -- Nothing to do if the ALI file has already been processed.
571 -- This happens if an interface imports another interface.
573 if not Processed_ALIs.Get (The_ALI) then
574 Processed_ALIs.Set (The_ALI, True);
575 Text := Read_Library_Info (The_ALI);
577 if Text /= null then
578 Idread :=
579 Scan_ALI
580 (F => The_ALI,
581 T => Text,
582 Ignore_ED => False,
583 Err => True);
584 Free (Text);
586 if Idread /= No_ALI_Id then
587 First_Unit := ALI.ALIs.Table (Idread).First_Unit;
588 Last_Unit := ALI.ALIs.Table (Idread).Last_Unit;
590 -- Process both unit (spec and body) if the body is needed
591 -- by the spec (inline or generic). Otherwise, just process
592 -- the spec.
594 if First_Unit /= Last_Unit and then
595 not ALI.Units.Table (Last_Unit).Body_Needed_For_SAL
596 then
597 First_Unit := Last_Unit;
598 end if;
600 for Unit in First_Unit .. Last_Unit loop
601 Unit_Data := ALI.Units.Table (Unit);
603 -- Check if each withed unit which is in the library is
604 -- also in the interface set, if it has not yet been
605 -- processed.
607 for W in Unit_Data.First_With .. Unit_Data.Last_With loop
608 Afile := Withs.Table (W).Afile;
610 if Afile /= No_File and then Library_ALIs.Get (Afile)
611 and then not Processed_ALIs.Get (Afile)
612 then
613 if not Interface_ALIs.Get (Afile) then
614 if not Warning_For_Library then
615 Write_Str ("Warning: In library project """);
616 Get_Name_String (Current_Proj.Name);
617 To_Mixed (Name_Buffer (1 .. Name_Len));
618 Write_Str (Name_Buffer (1 .. Name_Len));
619 Write_Line ("""");
620 Warning_For_Library := True;
621 end if;
623 Write_Str (" Unit """);
624 Get_Name_String (Withs.Table (W).Uname);
625 To_Mixed (Name_Buffer (1 .. Name_Len - 2));
626 Write_Str (Name_Buffer (1 .. Name_Len - 2));
627 Write_Line (""" is not in the interface set");
628 Write_Str (" but it is needed by ");
630 case Unit_Data.Utype is
631 when Is_Spec =>
632 Write_Str ("the spec of ");
634 when Is_Body =>
635 Write_Str ("the body of ");
637 when others =>
638 null;
639 end case;
641 Write_Str ("""");
642 Get_Name_String (Unit_Data.Uname);
643 To_Mixed (Name_Buffer (1 .. Name_Len - 2));
644 Write_Str (Name_Buffer (1 .. Name_Len - 2));
645 Write_Line ("""");
646 end if;
648 -- Now, process this unit
650 Process (Afile);
651 end if;
652 end loop;
653 end loop;
654 end if;
655 end if;
656 end if;
657 end Process;
659 --------------------------------
660 -- Process_Imported_Libraries --
661 --------------------------------
663 procedure Process_Imported_Libraries is
664 Current : Project_Id;
666 procedure Process_Project (Project : Project_Id);
667 -- Process Project and its imported projects recursively.
668 -- Add any library projects to table Library_Projs.
670 ---------------------
671 -- Process_Project --
672 ---------------------
674 procedure Process_Project (Project : Project_Id) is
675 Imported : Project_List;
677 begin
678 -- Nothing to do if process has already been processed
680 if not Processed_Projects.Get (Project.Name) then
681 Processed_Projects.Set (Project.Name, True);
683 -- Call Process_Project recursively for any imported project.
684 -- We first process the imported projects to guarantee that
685 -- we have a proper reverse order for the libraries.
687 Imported := Project.Imported_Projects;
688 while Imported /= null loop
689 if Imported.Project /= No_Project then
690 Process_Project (Imported.Project);
691 end if;
693 Imported := Imported.Next;
694 end loop;
696 -- If it is a library project, add it to Library_Projs
698 if Project /= For_Project and then Project.Library then
699 Library_Projs.Increment_Last;
700 Library_Projs.Table (Library_Projs.Last) := Project;
702 -- Check if because of this library we need to use libgnarl
704 if Libgnarl_Needed = Unknown then
705 if Project.Libgnarl_Needed = Unknown
706 and then Project.Object_Directory /= No_Path_Information
707 then
708 -- Check if libgnarl is needed for this library
710 declare
711 Object_Dir_Path : constant String :=
712 Get_Name_String
713 (Project.Object_Directory.
714 Display_Name);
715 Object_Dir : Dir_Type;
716 Filename : String (1 .. 255);
717 Last : Natural;
719 begin
720 Open (Object_Dir, Object_Dir_Path);
722 -- For all entries in the object directory
724 loop
725 Read (Object_Dir, Filename, Last);
726 exit when Last = 0;
728 -- Check if it is an object file
730 if Is_Obj (Filename (1 .. Last)) then
731 declare
732 Object_Path : constant String :=
733 Normalize_Pathname
734 (Object_Dir_Path &
735 Directory_Separator &
736 Filename (1 .. Last));
737 ALI_File : constant String :=
738 Ext_To
739 (Object_Path, "ali");
741 begin
742 if Is_Regular_File (ALI_File) then
744 -- Find out if for this ALI file,
745 -- libgnarl is necessary.
747 Check_Libs
748 (ALI_File, Main_Project => False);
750 if Libgnarl_Needed = Yes then
751 Project.Libgnarl_Needed := Yes;
752 For_Project.Libgnarl_Needed := Yes;
753 exit;
754 end if;
755 end if;
756 end;
757 end if;
758 end loop;
760 Close (Object_Dir);
761 end;
762 end if;
764 if Project.Libgnarl_Needed = Yes then
765 Libgnarl_Needed := Yes;
766 For_Project.Libgnarl_Needed := Yes;
767 end if;
768 end if;
769 end if;
770 end if;
771 end Process_Project;
773 -- Start of processing for Process_Imported_Libraries
775 begin
776 -- Build list of library projects imported directly or indirectly,
777 -- in the reverse order.
779 Process_Project (For_Project);
781 -- Add the -L and -l switches and, if the Rpath option is supported,
782 -- add the directory to the Rpath. As the library projects are in the
783 -- wrong order, process from the last to the first.
785 for Index in reverse 1 .. Library_Projs.Last loop
786 Current := Library_Projs.Table (Index);
788 Get_Name_String (Current.Library_Dir.Display_Name);
789 Opts.Increment_Last;
790 Opts.Table (Opts.Last) :=
791 new String'("-L" & Name_Buffer (1 .. Name_Len));
793 if Path_Option /= null then
794 Add_Rpath (Name_Buffer (1 .. Name_Len));
795 end if;
797 Opts.Increment_Last;
798 Opts.Table (Opts.Last) :=
799 new String'("-l" & Get_Name_String (Current.Library_Name));
800 end loop;
801 end Process_Imported_Libraries;
803 -- Start of processing for Build_Library
805 begin
806 Reset_Tables;
808 -- Fail if project is not a library project
810 if not For_Project.Library then
811 Com.Fail ("project """ & Project_Name & """ has no library");
812 end if;
814 -- Do not attempt to build the library if it is externally built
816 if For_Project.Externally_Built then
817 return;
818 end if;
820 -- If this is the first time Build_Library is called, get the Name_Id
821 -- of "s-osinte.ads".
823 if S_Osinte_Ads = No_File then
824 Name_Len := 0;
825 Add_Str_To_Name_Buffer ("s-osinte.ads");
826 S_Osinte_Ads := Name_Find;
827 end if;
829 if S_Dec_Ads = No_File then
830 Name_Len := 0;
831 Add_Str_To_Name_Buffer ("dec.ads");
832 S_Dec_Ads := Name_Find;
833 end if;
835 if G_Trasym_Ads = No_File then
836 Name_Len := 0;
837 Add_Str_To_Name_Buffer ("g-trasym.ads");
838 G_Trasym_Ads := Name_Find;
839 end if;
841 -- We work in the object directory
843 Change_Dir (Object_Directory_Path);
845 if Standalone then
847 -- Call gnatbind only if Bind is True
849 if Bind then
850 if Gnatbind_Path = null then
851 Com.Fail ("unable to locate " & Gnatbind);
852 end if;
854 if Gcc_Path = null then
855 Com.Fail ("unable to locate " & Gcc);
856 end if;
858 -- Allocate Arguments, if it is the first time we see a standalone
859 -- library.
861 if Arguments = No_Argument then
862 Arguments := new String_List (1 .. Initial_Argument_Max);
863 end if;
865 -- Add "-n -o b~<lib>.adb (b__<lib>.adb on VMS) -L<lib>"
867 Argument_Number := 2;
868 Arguments (1) := No_Main;
869 Arguments (2) := Output_Switch;
871 if OpenVMS_On_Target then
872 B_Start := new String'("b__");
873 end if;
875 Add_Argument
876 (B_Start.all
877 & Get_Name_String (For_Project.Library_Name) & ".adb");
878 Add_Argument ("-L" & Get_Name_String (For_Project.Library_Name));
880 if For_Project.Lib_Auto_Init and then SALs_Use_Constructors then
881 Add_Argument (Auto_Initialize);
882 end if;
884 -- Check if Binder'Default_Switches ("Ada") is defined. If it is,
885 -- add these switches to call gnatbind.
887 declare
888 Binder_Package : constant Package_Id :=
889 Value_Of
890 (Name => Name_Binder,
891 In_Packages => For_Project.Decl.Packages,
892 In_Tree => In_Tree);
894 begin
895 if Binder_Package /= No_Package then
896 declare
897 Defaults : constant Array_Element_Id :=
898 Value_Of
899 (Name => Name_Default_Switches,
900 In_Arrays =>
901 In_Tree.Packages.Table
902 (Binder_Package).Decl.Arrays,
903 In_Tree => In_Tree);
904 Switches : Variable_Value := Nil_Variable_Value;
906 Switch : String_List_Id := Nil_String;
908 begin
909 if Defaults /= No_Array_Element then
910 Switches :=
911 Value_Of
912 (Index => Name_Ada,
913 Src_Index => 0,
914 In_Array => Defaults,
915 In_Tree => In_Tree);
917 if not Switches.Default then
918 Switch := Switches.Values;
920 while Switch /= Nil_String loop
921 Add_Argument
922 (Get_Name_String
923 (In_Tree.String_Elements.Table
924 (Switch).Value));
925 Switch := In_Tree.String_Elements.
926 Table (Switch).Next;
927 end loop;
928 end if;
929 end if;
930 end;
931 end if;
932 end;
933 end if;
935 -- Get all the ALI files of the project file. We do that even if
936 -- Bind is False, so that First_ALI is set.
938 declare
939 Unit : Unit_Data;
941 begin
942 Library_ALIs.Reset;
943 Interface_ALIs.Reset;
944 Processed_ALIs.Reset;
946 for Source in Unit_Table.First ..
947 Unit_Table.Last (In_Tree.Units)
948 loop
949 Unit := In_Tree.Units.Table (Source);
951 if Unit.File_Names (Body_Part).Name /= No_File
952 and then Unit.File_Names (Body_Part).Path.Name /= Slash
953 then
955 Check_Project (Unit.File_Names (Body_Part).Project)
956 then
957 if Unit.File_Names (Specification).Name = No_File then
958 declare
959 Src_Ind : Source_File_Index;
961 begin
962 Src_Ind := Sinput.P.Load_Project_File
963 (Get_Name_String
964 (Unit.File_Names
965 (Body_Part).Path.Name));
967 -- Add the ALI file only if it is not a subunit
969 if not
970 Sinput.P.Source_File_Is_Subunit (Src_Ind)
971 then
972 Add_ALI_For
973 (Unit.File_Names (Body_Part).Name);
974 exit when not Bind;
975 end if;
976 end;
978 else
979 Add_ALI_For (Unit.File_Names (Body_Part).Name);
980 exit when not Bind;
981 end if;
982 end if;
984 elsif Unit.File_Names (Specification).Name /= No_File
985 and then Unit.File_Names (Specification).Path.Name /= Slash
986 and then Check_Project
987 (Unit.File_Names (Specification).Project)
988 then
989 Add_ALI_For (Unit.File_Names (Specification).Name);
990 exit when not Bind;
991 end if;
992 end loop;
993 end;
995 -- Continue setup and call gnatbind if Bind is True
997 if Bind then
999 -- Get an eventual --RTS from the ALI file
1001 if First_ALI /= No_File then
1002 declare
1003 T : Text_Buffer_Ptr;
1004 A : ALI_Id;
1006 begin
1007 -- Load the ALI file
1009 T := Read_Library_Info (First_ALI, True);
1011 -- Read it
1013 A := Scan_ALI
1014 (First_ALI, T, Ignore_ED => False, Err => False);
1016 if A /= No_ALI_Id then
1017 for Index in
1018 ALI.Units.Table
1019 (ALI.ALIs.Table (A).First_Unit).First_Arg ..
1020 ALI.Units.Table
1021 (ALI.ALIs.Table (A).First_Unit).Last_Arg
1022 loop
1023 -- Look for --RTS. If found, add the switch to call
1024 -- gnatbind.
1026 declare
1027 Arg : String_Ptr renames Args.Table (Index);
1028 begin
1029 if Arg'Length >= 6 and then
1030 Arg (Arg'First + 2 .. Arg'First + 5) = "RTS="
1031 then
1032 Add_Argument (Arg.all);
1033 exit;
1034 end if;
1035 end;
1036 end loop;
1037 end if;
1038 end;
1039 end if;
1041 -- Set the paths
1043 Set_Ada_Paths
1044 (Project => For_Project,
1045 In_Tree => In_Tree,
1046 Including_Libraries => True);
1048 -- Display the gnatbind command, if not in quiet output
1050 Display (Gnatbind);
1052 Size := 0;
1053 for J in 1 .. Argument_Number loop
1054 Size := Size + Arguments (J)'Length + 1;
1055 end loop;
1057 -- Invoke gnatbind with the arguments if the size is not too large
1059 if Size <= Maximum_Size then
1060 Spawn
1061 (Gnatbind_Path.all,
1062 Arguments (1 .. Argument_Number),
1063 Success);
1065 else
1066 -- Otherwise create a temporary response file
1068 declare
1069 FD : File_Descriptor;
1070 Path : Path_Name_Type;
1071 Args : Argument_List (1 .. 1);
1072 EOL : constant String (1 .. 1) := (1 => ASCII.LF);
1073 Status : Integer;
1074 Succ : Boolean;
1075 Quotes_Needed : Boolean;
1076 Last_Char : Natural;
1077 Ch : Character;
1079 begin
1080 Tempdir.Create_Temp_File (FD, Path);
1081 Args (1) := new String'("@" & Get_Name_String (Path));
1083 for J in 1 .. Argument_Number loop
1085 -- Check if the argument should be quoted
1087 Quotes_Needed := False;
1088 Last_Char := Arguments (J)'Length;
1090 for K in Arguments (J)'Range loop
1091 Ch := Arguments (J) (K);
1093 if Ch = ' ' or else Ch = ASCII.HT or else Ch = '"' then
1094 Quotes_Needed := True;
1095 exit;
1096 end if;
1097 end loop;
1099 if Quotes_Needed then
1101 -- Quote the argument, doubling '"'
1103 declare
1104 Arg : String (1 .. Arguments (J)'Length * 2 + 2);
1106 begin
1107 Arg (1) := '"';
1108 Last_Char := 1;
1110 for K in Arguments (J)'Range loop
1111 Ch := Arguments (J) (K);
1112 Last_Char := Last_Char + 1;
1113 Arg (Last_Char) := Ch;
1115 if Ch = '"' then
1116 Last_Char := Last_Char + 1;
1117 Arg (Last_Char) := '"';
1118 end if;
1119 end loop;
1121 Last_Char := Last_Char + 1;
1122 Arg (Last_Char) := '"';
1124 Status := Write (FD, Arg'Address, Last_Char);
1125 end;
1127 else
1128 Status := Write
1129 (FD,
1130 Arguments (J) (Arguments (J)'First)'Address,
1131 Last_Char);
1132 end if;
1134 if Status /= Last_Char then
1135 Fail ("disk full");
1136 end if;
1138 Status := Write (FD, EOL (1)'Address, 1);
1140 if Status /= 1 then
1141 Fail ("disk full");
1142 end if;
1143 end loop;
1145 Close (FD);
1147 -- And invoke gnatbind with this response file
1149 Spawn (Gnatbind_Path.all, Args, Success);
1151 Delete_File (Get_Name_String (Path), Succ);
1153 if not Succ then
1154 null;
1155 end if;
1156 end;
1157 end if;
1159 if not Success then
1160 Com.Fail ("could not bind standalone library "
1161 & Get_Name_String (For_Project.Library_Name));
1162 end if;
1163 end if;
1165 -- Compile the binder generated file only if Link is true
1167 if Link then
1169 -- Set the paths
1171 Set_Ada_Paths
1172 (Project => For_Project,
1173 In_Tree => In_Tree,
1174 Including_Libraries => True);
1176 -- Invoke <gcc> -c b__<lib>.adb
1178 -- Allocate Arguments, if it is the first time we see a standalone
1179 -- library.
1181 if Arguments = No_Argument then
1182 Arguments := new String_List (1 .. Initial_Argument_Max);
1183 end if;
1185 Argument_Number := 1;
1186 Arguments (1) := Compile_Switch;
1188 if OpenVMS_On_Target then
1189 B_Start := new String'("b__");
1190 end if;
1192 Add_Argument
1193 (B_Start.all
1194 & Get_Name_String (For_Project.Library_Name) & ".adb");
1196 -- If necessary, add the PIC option
1198 if PIC_Option /= "" then
1199 Add_Argument (PIC_Option);
1200 end if;
1202 -- Get the back-end switches and --RTS from the ALI file
1204 if First_ALI /= No_File then
1205 declare
1206 T : Text_Buffer_Ptr;
1207 A : ALI_Id;
1209 begin
1210 -- Load the ALI file
1212 T := Read_Library_Info (First_ALI, True);
1214 -- Read it
1216 A :=
1217 Scan_ALI (First_ALI, T, Ignore_ED => False, Err => False);
1219 if A /= No_ALI_Id then
1220 for Index in
1221 ALI.Units.Table
1222 (ALI.ALIs.Table (A).First_Unit).First_Arg ..
1223 ALI.Units.Table
1224 (ALI.ALIs.Table (A).First_Unit).Last_Arg
1225 loop
1226 -- Do not compile with the front end switches except
1227 -- for --RTS.
1229 declare
1230 Arg : String_Ptr renames Args.Table (Index);
1231 begin
1232 if not Is_Front_End_Switch (Arg.all)
1233 or else
1234 Arg (Arg'First + 2 .. Arg'First + 5) = "RTS="
1235 then
1236 Add_Argument (Arg.all);
1237 end if;
1238 end;
1239 end loop;
1240 end if;
1241 end;
1242 end if;
1244 -- Now that all the arguments are set, compile the binder
1245 -- generated file.
1247 Display (Gcc);
1248 Spawn
1249 (Gcc_Path.all, Arguments (1 .. Argument_Number), Success);
1251 if not Success then
1252 Com.Fail
1253 ("could not compile binder generated file for library "
1254 & Get_Name_String (For_Project.Library_Name));
1255 end if;
1257 -- Process binder generated file for pragmas Linker_Options
1259 Process_Binder_File (Arguments (2).all & ASCII.NUL);
1260 end if;
1261 end if;
1263 -- Build the library only if Link is True
1265 if Link then
1267 -- If attributes Library_GCC or Linker'Driver were specified, get the
1268 -- driver name.
1270 if For_Project.Config.Shared_Lib_Driver /= No_File then
1271 Driver_Name := Name_Id (For_Project.Config.Shared_Lib_Driver);
1272 end if;
1274 -- If attribute Library_Options was specified, add these additional
1275 -- options.
1277 Library_Options := Value_Of
1278 (Name_Library_Options, For_Project.Decl.Attributes, In_Tree);
1280 if not Library_Options.Default then
1281 declare
1282 Current : String_List_Id;
1283 Element : String_Element;
1285 begin
1286 Current := Library_Options.Values;
1287 while Current /= Nil_String loop
1288 Element := In_Tree.String_Elements.Table (Current);
1289 Get_Name_String (Element.Value);
1291 if Name_Len /= 0 then
1292 Opts.Increment_Last;
1293 Opts.Table (Opts.Last) :=
1294 new String'(Name_Buffer (1 .. Name_Len));
1295 end if;
1297 Current := Element.Next;
1298 end loop;
1299 end;
1300 end if;
1302 Lib_Dirpath :=
1303 new String'(Get_Name_String (For_Project.Library_Dir.Display_Name));
1304 Lib_Filename := new String'
1305 (Get_Name_String (For_Project.Library_Name));
1307 case For_Project.Library_Kind is
1308 when Static =>
1309 The_Build_Mode := Static;
1311 when Dynamic =>
1312 The_Build_Mode := Dynamic;
1314 when Relocatable =>
1315 The_Build_Mode := Relocatable;
1317 if PIC_Option /= "" then
1318 Opts.Increment_Last;
1319 Opts.Table (Opts.Last) := new String'(PIC_Option);
1320 end if;
1321 end case;
1323 -- Get the library version, if any
1325 if For_Project.Lib_Internal_Name /= No_Name then
1326 Lib_Version :=
1327 new String'(Get_Name_String (For_Project.Lib_Internal_Name));
1328 end if;
1330 -- Add the objects found in the object directory and the object
1331 -- directories of the extended files, if any, except for generated
1332 -- object files (b~.. or B__..) from extended projects.
1333 -- When there are one or more extended files, only add an object file
1334 -- if no object file with the same name have already been added.
1336 In_Main_Object_Directory := True;
1338 Foreign_Sources := Has_Foreign_Sources (For_Project);
1339 Current_Proj := For_Project;
1341 loop
1342 if Current_Proj.Object_Directory /= No_Path_Information then
1343 declare
1344 Object_Dir_Path : constant String :=
1345 Get_Name_String
1346 (Current_Proj.Object_Directory
1347 .Display_Name);
1348 Object_Dir : Dir_Type;
1349 Filename : String (1 .. 255);
1350 Last : Natural;
1351 Id : Name_Id;
1353 begin
1354 Open (Dir => Object_Dir, Dir_Name => Object_Dir_Path);
1356 -- For all entries in the object directory
1358 loop
1359 Read (Object_Dir, Filename, Last);
1361 exit when Last = 0;
1363 -- Check if it is an object file
1365 if Is_Obj (Filename (1 .. Last)) then
1366 declare
1367 Object_Path : constant String :=
1368 Normalize_Pathname
1369 (Object_Dir_Path &
1370 Directory_Separator &
1371 Filename (1 .. Last));
1372 C_Object_Path : String := Object_Path;
1373 C_Filename : String := Filename (1 .. Last);
1375 begin
1376 Canonical_Case_File_Name (C_Object_Path);
1377 Canonical_Case_File_Name (C_Filename);
1379 -- If in the object directory of an extended
1380 -- project, do not consider generated object files.
1382 if In_Main_Object_Directory
1383 or else Last < 5
1384 or else
1385 C_Filename (1 .. B_Start'Length) /= B_Start.all
1386 then
1387 Name_Len := Last;
1388 Name_Buffer (1 .. Name_Len) :=
1389 C_Filename (1 .. Last);
1390 Id := Name_Find;
1392 if not Objects_Htable.Get (Id) then
1393 declare
1394 ALI_File : constant String :=
1395 Ext_To
1396 (C_Filename
1397 (1 .. Last), "ali");
1398 ALI_Path : constant String :=
1399 Ext_To (C_Object_Path, "ali");
1400 Add_It : Boolean :=
1401 Foreign_Sources
1402 or else
1403 (Last > 5
1404 and then
1405 C_Filename
1406 (1 .. B_Start'Length) =
1407 B_Start.all);
1408 Fname : File_Name_Type;
1409 Proj : Project_Id;
1411 begin
1412 if Is_Regular_File (ALI_Path) then
1414 -- If there is an ALI file, check if
1415 -- the object file should be added to
1416 -- the library. If there are foreign
1417 -- sources we put all object files in
1418 -- the library.
1420 if not Add_It then
1421 for Index in
1422 1 .. Unit_Table.Last
1423 (In_Tree.Units)
1424 loop
1425 if In_Tree.Units.Table
1426 (Index).File_Names
1427 (Body_Part).Name /= No_File
1428 then
1429 Proj :=
1430 In_Tree.Units.Table (Index).
1431 File_Names
1432 (Body_Part).Project;
1433 Fname :=
1434 In_Tree.Units.Table (Index).
1435 File_Names (Body_Part).Name;
1437 elsif
1438 In_Tree.Units.Table
1439 (Index).File_Names
1440 (Specification).Name /=
1441 No_File
1442 then
1443 Proj :=
1444 In_Tree.Units.Table
1445 (Index).File_Names
1446 (Specification).Project;
1447 Fname :=
1448 In_Tree.Units.Table
1449 (Index).File_Names
1450 (Specification).Name;
1452 else
1453 Proj := No_Project;
1454 end if;
1456 Add_It := Proj /= No_Project;
1458 -- If the source is in the
1459 -- project or a project it
1460 -- extends, we may put it in
1461 -- the library.
1463 if Add_It then
1464 Add_It := Check_Project (Proj);
1465 end if;
1467 -- But we don't, if the ALI file
1468 -- does not correspond to the
1469 -- unit.
1471 if Add_It then
1472 declare
1473 F : constant String :=
1474 Ext_To
1475 (Get_Name_String
1476 (Fname), "ali");
1477 begin
1478 Add_It := F = ALI_File;
1479 end;
1480 end if;
1482 exit when Add_It;
1483 end loop;
1484 end if;
1486 if Add_It then
1487 Objects_Htable.Set (Id, True);
1488 Objects.Append
1489 (new String'(Object_Path));
1491 -- Record the ALI file
1493 ALIs.Append (new String'(ALI_Path));
1495 -- Find out if for this ALI file,
1496 -- libgnarl or libdecgnat or
1497 -- g-trasym.obj (on OpenVMS) is
1498 -- necessary.
1500 Check_Libs (ALI_Path, True);
1501 end if;
1503 elsif Foreign_Sources then
1504 Objects.Append
1505 (new String'(Object_Path));
1506 end if;
1507 end;
1508 end if;
1509 end if;
1510 end;
1511 end if;
1512 end loop;
1514 Close (Dir => Object_Dir);
1516 exception
1517 when Directory_Error =>
1518 Com.Fail ("cannot find object directory """
1519 & Get_Name_String
1520 (Current_Proj.Object_Directory.Display_Name)
1521 & """");
1522 end;
1523 end if;
1525 exit when Current_Proj.Extends = No_Project;
1527 In_Main_Object_Directory := False;
1528 Current_Proj := Current_Proj.Extends;
1529 end loop;
1531 -- Add the -L and -l switches for the imported Library Project Files,
1532 -- and, if Path Option is supported, the library directory path names
1533 -- to Rpath.
1535 Process_Imported_Libraries;
1537 -- Link with libgnat and possibly libgnarl
1539 Opts.Increment_Last;
1540 Opts.Table (Opts.Last) := new String'("-L" & Lib_Directory);
1542 -- If Path Option is supported, add libgnat directory path name to
1543 -- Rpath.
1545 if Path_Option /= null then
1546 declare
1547 Libdir : constant String := Lib_Directory;
1548 GCC_Index : Natural := 0;
1550 begin
1551 Add_Rpath (Libdir);
1553 -- For shared libraries, add to the Path Option the directory
1554 -- of the shared version of libgcc.
1556 if The_Build_Mode /= Static then
1557 GCC_Index := Index (Libdir, "/lib/");
1559 if GCC_Index = 0 then
1560 GCC_Index :=
1561 Index
1562 (Libdir,
1563 Directory_Separator & "lib" & Directory_Separator);
1564 end if;
1566 if GCC_Index /= 0 then
1567 Add_Rpath (Libdir (Libdir'First .. GCC_Index + 3));
1568 end if;
1569 end if;
1570 end;
1571 end if;
1573 if Libgnarl_Needed = Yes then
1574 Opts.Increment_Last;
1576 if The_Build_Mode = Static then
1577 Opts.Table (Opts.Last) := new String'("-lgnarl");
1578 else
1579 Opts.Table (Opts.Last) := new String'(Shared_Lib ("gnarl"));
1580 end if;
1581 end if;
1583 if Gtrasymobj_Needed then
1584 Opts.Increment_Last;
1585 Opts.Table (Opts.Last) :=
1586 new String'(Lib_Directory & "/g-trasym.obj");
1587 end if;
1589 if Libdecgnat_Needed then
1590 Opts.Increment_Last;
1592 Opts.Table (Opts.Last) :=
1593 new String'("-L" & Lib_Directory & "/../declib");
1595 Opts.Increment_Last;
1597 if The_Build_Mode = Static then
1598 Opts.Table (Opts.Last) := new String'("-ldecgnat");
1599 else
1600 Opts.Table (Opts.Last) := new String'(Shared_Lib ("decgnat"));
1601 end if;
1602 end if;
1604 Opts.Increment_Last;
1606 if The_Build_Mode = Static then
1607 Opts.Table (Opts.Last) := new String'("-lgnat");
1608 else
1609 Opts.Table (Opts.Last) := new String'(Shared_Lib ("gnat"));
1610 end if;
1612 -- If Path Option is supported, add the necessary switch with the
1613 -- content of Rpath. As Rpath contains at least libgnat directory
1614 -- path name, it is guaranteed that it is not null.
1616 if Path_Option /= null then
1617 Opts.Increment_Last;
1618 Opts.Table (Opts.Last) :=
1619 new String'(Path_Option.all & Rpath (1 .. Rpath_Last));
1620 Free (Path_Option);
1621 Free (Rpath);
1622 end if;
1624 Object_Files :=
1625 new Argument_List'
1626 (Argument_List (Objects.Table (1 .. Objects.Last)));
1628 Ali_Files :=
1629 new Argument_List'(Argument_List (ALIs.Table (1 .. ALIs.Last)));
1631 Options :=
1632 new Argument_List'(Argument_List (Opts.Table (1 .. Opts.Last)));
1634 -- We fail if there are no object to put in the library
1635 -- (Ada or foreign objects).
1637 if Object_Files'Length = 0 then
1638 Com.Fail ("no object files for library """ &
1639 Lib_Filename.all & '"');
1640 end if;
1642 if not Opt.Quiet_Output then
1643 Write_Eol;
1644 Write_Str ("building ");
1645 Write_Str (Ada.Characters.Handling.To_Lower
1646 (Build_Mode_State'Image (The_Build_Mode)));
1647 Write_Str (" library for project ");
1648 Write_Line (Project_Name);
1650 -- Only output list of object files and ALI files in verbose mode
1652 if Opt.Verbose_Mode then
1653 Write_Eol;
1655 Write_Line ("object files:");
1657 for Index in Object_Files'Range loop
1658 Write_Str (" ");
1659 Write_Line (Object_Files (Index).all);
1660 end loop;
1662 Write_Eol;
1664 if Ali_Files'Length = 0 then
1665 Write_Line ("NO ALI files");
1667 else
1668 Write_Line ("ALI files:");
1670 for Index in Ali_Files'Range loop
1671 Write_Str (" ");
1672 Write_Line (Ali_Files (Index).all);
1673 end loop;
1674 end if;
1676 Write_Eol;
1677 end if;
1678 end if;
1680 -- We check that all object files are regular files
1682 Check_Context;
1684 -- Delete the existing library file, if it exists. Fail if the
1685 -- library file is not writable, or if it is not possible to delete
1686 -- the file.
1688 declare
1689 DLL_Name : aliased String :=
1690 Lib_Dirpath.all & Directory_Separator & DLL_Prefix &
1691 Lib_Filename.all & "." & DLL_Ext;
1693 Archive_Name : aliased String :=
1694 Lib_Dirpath.all & Directory_Separator & "lib" &
1695 Lib_Filename.all & "." & Archive_Ext;
1697 type Str_Ptr is access all String;
1698 -- This type is necessary to meet the accessibility rules of Ada.
1699 -- It is not possible to use String_Access here.
1701 Full_Lib_Name : Str_Ptr;
1702 -- Designates the full library path name. Either DLL_Name or
1703 -- Archive_Name, depending on the library kind.
1705 Success : Boolean;
1706 pragma Warnings (Off, Success);
1707 -- Used to call Delete_File
1709 begin
1710 if The_Build_Mode = Static then
1711 Full_Lib_Name := Archive_Name'Access;
1712 else
1713 Full_Lib_Name := DLL_Name'Access;
1714 end if;
1716 if Is_Regular_File (Full_Lib_Name.all) then
1717 if Is_Writable_File (Full_Lib_Name.all) then
1718 Delete_File (Full_Lib_Name.all, Success);
1719 end if;
1721 if Is_Regular_File (Full_Lib_Name.all) then
1722 Com.Fail ("could not delete """ & Full_Lib_Name.all & """");
1723 end if;
1724 end if;
1725 end;
1727 Argument_Number := 0;
1729 -- If we have a standalone library, gather all the interface ALI.
1730 -- They are passed to Build_Dynamic_Library, where they are used by
1731 -- some platforms (VMS, for example) to decide what symbols should be
1732 -- exported. They are also flagged as Interface when we copy them to
1733 -- the library directory (by Copy_ALI_Files, below).
1735 if Standalone then
1736 Current_Proj := For_Project;
1738 declare
1739 Iface : String_List_Id := For_Project.Lib_Interface_ALIs;
1740 ALI : File_Name_Type;
1742 begin
1743 while Iface /= Nil_String loop
1744 ALI :=
1745 File_Name_Type
1746 (In_Tree.String_Elements.Table (Iface).Value);
1747 Interface_ALIs.Set (ALI, True);
1748 Get_Name_String
1749 (In_Tree.String_Elements.Table (Iface).Value);
1750 Add_Argument (Name_Buffer (1 .. Name_Len));
1751 Iface := In_Tree.String_Elements.Table (Iface).Next;
1752 end loop;
1754 Iface := For_Project.Lib_Interface_ALIs;
1756 if not Opt.Quiet_Output then
1758 -- Check that the interface set is complete: any unit in the
1759 -- library that is needed by an interface should also be an
1760 -- interface. If it is not the case, output a warning.
1762 while Iface /= Nil_String loop
1763 ALI :=
1764 File_Name_Type
1765 (In_Tree.String_Elements.Table (Iface).Value);
1766 Process (ALI);
1767 Iface := In_Tree.String_Elements.Table (Iface).Next;
1768 end loop;
1769 end if;
1770 end;
1771 end if;
1773 declare
1774 Current_Dir : constant String := Get_Current_Dir;
1775 Dir : Dir_Type;
1777 Name : String (1 .. 200);
1778 Last : Natural;
1780 Disregard : Boolean;
1781 pragma Warnings (Off, Disregard);
1783 DLL_Name : aliased constant String :=
1784 Lib_Filename.all & "." & DLL_Ext;
1786 Archive_Name : aliased constant String :=
1787 Lib_Filename.all & "." & Archive_Ext;
1789 Delete : Boolean := False;
1791 begin
1792 -- Clean the library directory: remove any file with the name of
1793 -- the library file and any ALI file of a source of the project.
1795 begin
1796 Get_Name_String (For_Project.Library_Dir.Name);
1797 Change_Dir (Name_Buffer (1 .. Name_Len));
1799 exception
1800 when others =>
1801 Com.Fail
1802 ("unable to access library directory """
1803 & Name_Buffer (1 .. Name_Len)
1804 & """");
1805 end;
1807 Open (Dir, ".");
1809 loop
1810 Read (Dir, Name, Last);
1811 exit when Last = 0;
1813 declare
1814 Filename : constant String := Name (1 .. Last);
1816 begin
1817 if Is_Regular_File (Filename) then
1818 Canonical_Case_File_Name (Name (1 .. Last));
1819 Delete := False;
1821 if (The_Build_Mode = Static and then
1822 Name (1 .. Last) = Archive_Name)
1823 or else
1824 ((The_Build_Mode = Dynamic or else
1825 The_Build_Mode = Relocatable)
1826 and then
1827 Name (1 .. Last) = DLL_Name)
1828 then
1829 Delete := True;
1831 elsif Last > 4
1832 and then Name (Last - 3 .. Last) = ".ali"
1833 then
1834 declare
1835 Unit : Unit_Data;
1837 begin
1838 -- Compare with ALI file names of the project
1840 for Index in
1841 1 .. Unit_Table.Last (In_Tree.Units)
1842 loop
1843 Unit := In_Tree.Units.Table (Index);
1845 if Unit.File_Names (Body_Part).Project /=
1846 No_Project
1847 then
1848 if Ultimate_Extending_Project_Of
1849 (Unit.File_Names (Body_Part).Project) =
1850 For_Project
1851 then
1852 Get_Name_String
1853 (Unit.File_Names (Body_Part).Name);
1854 Name_Len := Name_Len -
1855 File_Extension
1856 (Name (1 .. Name_Len))'Length;
1857 if Name_Buffer (1 .. Name_Len) =
1858 Name (1 .. Last - 4)
1859 then
1860 Delete := True;
1861 exit;
1862 end if;
1863 end if;
1865 elsif Ultimate_Extending_Project_Of
1866 (Unit.File_Names (Specification).Project) =
1867 For_Project
1868 then
1869 Get_Name_String
1870 (Unit.File_Names (Specification).Name);
1871 Name_Len :=
1872 Name_Len -
1873 File_Extension
1874 (Name (1 .. Name_Len))'Length;
1876 if Name_Buffer (1 .. Name_Len) =
1877 Name (1 .. Last - 4)
1878 then
1879 Delete := True;
1880 exit;
1881 end if;
1882 end if;
1883 end loop;
1884 end;
1885 end if;
1887 if Delete then
1888 Set_Writable (Filename);
1889 Delete_File (Filename, Disregard);
1890 end if;
1891 end if;
1892 end;
1893 end loop;
1895 Close (Dir);
1897 Change_Dir (Current_Dir);
1898 end;
1900 -- Call procedure to build the library, depending on the build mode
1902 case The_Build_Mode is
1903 when Dynamic | Relocatable =>
1904 Build_Dynamic_Library
1905 (Ofiles => Object_Files.all,
1906 Options => Options.all,
1907 Interfaces => Arguments (1 .. Argument_Number),
1908 Lib_Filename => Lib_Filename.all,
1909 Lib_Dir => Lib_Dirpath.all,
1910 Symbol_Data => Current_Proj.Symbol_Data,
1911 Driver_Name => Driver_Name,
1912 Lib_Version => Lib_Version.all,
1913 Auto_Init => Current_Proj.Lib_Auto_Init);
1915 when Static =>
1916 MLib.Build_Library
1917 (Object_Files.all,
1918 Lib_Filename.all,
1919 Lib_Dirpath.all);
1921 when None =>
1922 null;
1923 end case;
1925 -- We need to copy the ALI files from the object directory to the
1926 -- library ALI directory, so that the linker find them there, and
1927 -- does not need to look in the object directory where it would also
1928 -- find the object files; and we don't want that: we want the linker
1929 -- to use the library.
1931 -- Copy the ALI files and make the copies read-only. For interfaces,
1932 -- mark the copies as interfaces.
1934 Copy_ALI_Files
1935 (Files => Ali_Files.all,
1936 To => For_Project.Library_ALI_Dir.Name,
1937 Interfaces => Arguments (1 .. Argument_Number));
1939 -- Copy interface sources if Library_Src_Dir specified
1941 if Standalone
1942 and then For_Project.Library_Src_Dir /= No_Path_Information
1943 then
1944 -- Clean the interface copy directory: remove any source that
1945 -- could be a source of the project.
1947 begin
1948 Get_Name_String (For_Project.Library_Src_Dir.Name);
1949 Change_Dir (Name_Buffer (1 .. Name_Len));
1951 exception
1952 when others =>
1953 Com.Fail
1954 ("unable to access library source copy directory """
1955 & Name_Buffer (1 .. Name_Len)
1956 & """");
1957 end;
1959 declare
1960 Dir : Dir_Type;
1961 Delete : Boolean := False;
1962 Unit : Unit_Data;
1964 Name : String (1 .. 200);
1965 Last : Natural;
1967 Disregard : Boolean;
1968 pragma Warnings (Off, Disregard);
1970 begin
1971 Open (Dir, ".");
1973 loop
1974 Read (Dir, Name, Last);
1975 exit when Last = 0;
1977 if Is_Regular_File (Name (1 .. Last)) then
1978 Canonical_Case_File_Name (Name (1 .. Last));
1979 Delete := False;
1981 -- Compare with source file names of the project
1983 for Index in 1 .. Unit_Table.Last (In_Tree.Units) loop
1984 Unit := In_Tree.Units.Table (Index);
1986 if Ultimate_Extending_Project_Of
1987 (Unit.File_Names (Body_Part).Project) = For_Project
1988 and then
1989 Get_Name_String
1990 (Unit.File_Names (Body_Part).Name) =
1991 Name (1 .. Last)
1992 then
1993 Delete := True;
1994 exit;
1995 end if;
1997 if Ultimate_Extending_Project_Of
1998 (Unit.File_Names (Specification).Project) =
1999 For_Project
2000 and then
2001 Get_Name_String
2002 (Unit.File_Names (Specification).Name) =
2003 Name (1 .. Last)
2004 then
2005 Delete := True;
2006 exit;
2007 end if;
2008 end loop;
2009 end if;
2011 if Delete then
2012 Set_Writable (Name (1 .. Last));
2013 Delete_File (Name (1 .. Last), Disregard);
2014 end if;
2015 end loop;
2017 Close (Dir);
2018 end;
2020 Copy_Interface_Sources
2021 (For_Project => For_Project,
2022 In_Tree => In_Tree,
2023 Interfaces => Arguments (1 .. Argument_Number),
2024 To_Dir => For_Project.Library_Src_Dir.Display_Name);
2025 end if;
2026 end if;
2028 -- Reset the current working directory to its previous value
2030 Change_Dir (Current_Dir);
2031 end Build_Library;
2033 -----------
2034 -- Check --
2035 -----------
2037 procedure Check (Filename : String) is
2038 begin
2039 if not Is_Regular_File (Filename) then
2040 Com.Fail (Filename & " not found.");
2041 end if;
2042 end Check;
2044 -------------------
2045 -- Check_Context --
2046 -------------------
2048 procedure Check_Context is
2049 begin
2050 -- Check that each object file exists
2052 for F in Object_Files'Range loop
2053 Check (Object_Files (F).all);
2054 end loop;
2055 end Check_Context;
2057 -------------------
2058 -- Check_Library --
2059 -------------------
2061 procedure Check_Library
2062 (For_Project : Project_Id; In_Tree : Project_Tree_Ref)
2064 Lib_TS : Time_Stamp_Type;
2065 Current : constant Dir_Name_Str := Get_Current_Dir;
2067 begin
2068 -- No need to build the library if there is no object directory,
2069 -- hence no object files to build the library.
2071 if For_Project.Library then
2072 declare
2073 Lib_Name : constant File_Name_Type :=
2074 Library_File_Name_For (For_Project, In_Tree);
2075 begin
2076 Change_Dir (Get_Name_String (For_Project.Library_Dir.Name));
2077 Lib_TS := File_Stamp (Lib_Name);
2078 For_Project.Library_TS := Lib_TS;
2079 end;
2081 if not For_Project.Externally_Built
2082 and then not For_Project.Need_To_Build_Lib
2083 and then For_Project.Object_Directory /= No_Path_Information
2084 then
2085 declare
2086 Obj_TS : Time_Stamp_Type;
2087 Object_Dir : Dir_Type;
2089 begin
2090 if OpenVMS_On_Target then
2091 B_Start := new String'("b__");
2092 end if;
2094 -- If the library file does not exist, then the time stamp will
2095 -- be Empty_Time_Stamp, earlier than any other time stamp.
2097 Change_Dir
2098 (Get_Name_String (For_Project.Object_Directory.Name));
2099 Open (Dir => Object_Dir, Dir_Name => ".");
2101 -- For all entries in the object directory
2103 loop
2104 Read (Object_Dir, Name_Buffer, Name_Len);
2105 exit when Name_Len = 0;
2107 -- Check if it is an object file, but ignore any binder
2108 -- generated file.
2110 if Is_Obj (Name_Buffer (1 .. Name_Len))
2111 and then Name_Buffer (1 .. B_Start'Length) /= B_Start.all
2112 then
2113 -- Get the object file time stamp
2115 Obj_TS := File_Stamp (File_Name_Type'(Name_Find));
2117 -- If library file time stamp is earlier, set
2118 -- Need_To_Build_Lib and return. String comparison is
2119 -- used, otherwise time stamps may be too close and the
2120 -- comparison would return True, which would trigger
2121 -- an unnecessary rebuild of the library.
2123 if String (Lib_TS) < String (Obj_TS) then
2125 -- Library must be rebuilt
2127 For_Project.Need_To_Build_Lib := True;
2128 exit;
2129 end if;
2130 end if;
2131 end loop;
2133 Close (Object_Dir);
2134 end;
2135 end if;
2137 Change_Dir (Current);
2138 end if;
2139 end Check_Library;
2141 ----------------------------
2142 -- Copy_Interface_Sources --
2143 ----------------------------
2145 procedure Copy_Interface_Sources
2146 (For_Project : Project_Id;
2147 In_Tree : Project_Tree_Ref;
2148 Interfaces : Argument_List;
2149 To_Dir : Path_Name_Type)
2151 Current : constant Dir_Name_Str := Get_Current_Dir;
2152 -- The current directory, where to return to at the end
2154 Target : constant Dir_Name_Str := Get_Name_String (To_Dir);
2155 -- The directory where to copy sources
2157 Text : Text_Buffer_Ptr;
2158 The_ALI : ALI.ALI_Id;
2159 Lib_File : File_Name_Type;
2161 First_Unit : ALI.Unit_Id;
2162 Second_Unit : ALI.Unit_Id;
2164 Data : Unit_Data;
2166 Copy_Subunits : Boolean := False;
2167 -- When True, indicates that subunits, if any, need to be copied too
2169 procedure Copy (File_Name : File_Name_Type);
2170 -- Copy one source of the project to the target directory
2172 function Is_Same_Or_Extension
2173 (Extending : Project_Id;
2174 Extended : Project_Id) return Boolean;
2175 -- Return True if project Extending is equal to or extends project
2176 -- Extended.
2178 ----------
2179 -- Copy --
2180 ----------
2182 procedure Copy (File_Name : File_Name_Type) is
2183 Success : Boolean;
2184 pragma Warnings (Off, Success);
2186 begin
2187 Unit_Loop :
2188 for Index in Unit_Table.First ..
2189 Unit_Table.Last (In_Tree.Units)
2190 loop
2191 Data := In_Tree.Units.Table (Index);
2193 -- Find and copy the immediate or inherited source
2195 for J in Data.File_Names'Range loop
2196 if Is_Same_Or_Extension
2197 (For_Project, Data.File_Names (J).Project)
2198 and then Data.File_Names (J).Name = File_Name
2199 then
2200 Copy_File
2201 (Get_Name_String (Data.File_Names (J).Path.Name),
2202 Target,
2203 Success,
2204 Mode => Overwrite,
2205 Preserve => Preserve);
2206 exit Unit_Loop;
2207 end if;
2208 end loop;
2209 end loop Unit_Loop;
2210 end Copy;
2212 --------------------------
2213 -- Is_Same_Or_Extension --
2214 --------------------------
2216 function Is_Same_Or_Extension
2217 (Extending : Project_Id;
2218 Extended : Project_Id) return Boolean
2220 Ext : Project_Id;
2222 begin
2223 Ext := Extending;
2224 while Ext /= No_Project loop
2225 if Ext = Extended then
2226 return True;
2227 end if;
2229 Ext := Ext.Extends;
2230 end loop;
2232 return False;
2233 end Is_Same_Or_Extension;
2235 -- Start of processing for Copy_Interface_Sources
2237 begin
2238 -- Change the working directory to the object directory
2240 Change_Dir (Get_Name_String (For_Project.Object_Directory.Name));
2242 for Index in Interfaces'Range loop
2244 -- First, load the ALI file
2246 Name_Len := 0;
2247 Add_Str_To_Name_Buffer (Interfaces (Index).all);
2248 Lib_File := Name_Find;
2249 Text := Read_Library_Info (Lib_File);
2250 The_ALI := Scan_ALI (Lib_File, Text, Ignore_ED => False, Err => True);
2251 Free (Text);
2253 Second_Unit := No_Unit_Id;
2254 First_Unit := ALI.ALIs.Table (The_ALI).First_Unit;
2255 Copy_Subunits := True;
2257 -- If there is both a spec and a body, check if they are both needed
2259 if ALI.Units.Table (First_Unit).Utype = Is_Body then
2260 Second_Unit := ALI.ALIs.Table (The_ALI).Last_Unit;
2262 -- If the body is not needed, then reset First_Unit
2264 if not ALI.Units.Table (Second_Unit).Body_Needed_For_SAL then
2265 First_Unit := No_Unit_Id;
2266 Copy_Subunits := False;
2267 end if;
2269 elsif ALI.Units.Table (First_Unit).Utype = Is_Spec_Only then
2270 Copy_Subunits := False;
2271 end if;
2273 -- Copy the file(s) that need to be copied
2275 if First_Unit /= No_Unit_Id then
2276 Copy (File_Name => ALI.Units.Table (First_Unit).Sfile);
2277 end if;
2279 if Second_Unit /= No_Unit_Id then
2280 Copy (File_Name => ALI.Units.Table (Second_Unit).Sfile);
2281 end if;
2283 -- Copy all the separates, if any
2285 if Copy_Subunits then
2286 for Dep in ALI.ALIs.Table (The_ALI).First_Sdep ..
2287 ALI.ALIs.Table (The_ALI).Last_Sdep
2288 loop
2289 if Sdep.Table (Dep).Subunit_Name /= No_Name then
2290 Copy (File_Name => Sdep.Table (Dep).Sfile);
2291 end if;
2292 end loop;
2293 end if;
2294 end loop;
2296 -- Restore the initial working directory
2298 Change_Dir (Current);
2299 end Copy_Interface_Sources;
2301 -------------
2302 -- Display --
2303 -------------
2305 procedure Display (Executable : String) is
2306 begin
2307 if not Opt.Quiet_Output then
2308 Write_Str (Executable);
2310 for Index in 1 .. Argument_Number loop
2311 Write_Char (' ');
2312 Write_Str (Arguments (Index).all);
2313 end loop;
2315 Write_Eol;
2316 end if;
2317 end Display;
2319 -----------
2320 -- Index --
2321 -----------
2323 function Index (S, Pattern : String) return Natural is
2324 Len : constant Natural := Pattern'Length;
2326 begin
2327 for J in reverse S'First .. S'Last - Len + 1 loop
2328 if Pattern = S (J .. J + Len - 1) then
2329 return J;
2330 end if;
2331 end loop;
2333 return 0;
2334 end Index;
2336 -------------------------
2337 -- Process_Binder_File --
2338 -------------------------
2340 procedure Process_Binder_File (Name : String) is
2341 Fd : FILEs;
2342 -- Binder file's descriptor
2344 Read_Mode : constant String := "r" & ASCII.NUL;
2345 -- For fopen
2347 Status : Interfaces.C_Streams.int;
2348 pragma Unreferenced (Status);
2349 -- For fclose
2351 Begin_Info : constant String := "-- BEGIN Object file/option list";
2352 End_Info : constant String := "-- END Object file/option list ";
2354 Next_Line : String (1 .. 1000);
2355 -- Current line value
2356 -- Where does this odd constant 1000 come from, looks suspicious ???
2358 Nlast : Integer;
2359 -- End of line slice (the slice does not contain the line terminator)
2361 procedure Get_Next_Line;
2362 -- Read the next line from the binder file without the line terminator
2364 -------------------
2365 -- Get_Next_Line --
2366 -------------------
2368 procedure Get_Next_Line is
2369 Fchars : chars;
2371 begin
2372 Fchars := fgets (Next_Line'Address, Next_Line'Length, Fd);
2374 if Fchars = System.Null_Address then
2375 Fail ("Error reading binder output");
2376 end if;
2378 Nlast := 1;
2379 while Nlast <= Next_Line'Last
2380 and then Next_Line (Nlast) /= ASCII.LF
2381 and then Next_Line (Nlast) /= ASCII.CR
2382 loop
2383 Nlast := Nlast + 1;
2384 end loop;
2386 Nlast := Nlast - 1;
2387 end Get_Next_Line;
2389 -- Start of processing for Process_Binder_File
2391 begin
2392 Fd := fopen (Name'Address, Read_Mode'Address);
2394 if Fd = NULL_Stream then
2395 Fail ("Failed to open binder output");
2396 end if;
2398 -- Skip up to the Begin Info line
2400 loop
2401 Get_Next_Line;
2402 exit when Next_Line (1 .. Nlast) = Begin_Info;
2403 end loop;
2405 -- Find the first switch
2407 loop
2408 Get_Next_Line;
2410 exit when Next_Line (1 .. Nlast) = End_Info;
2412 -- As the binder generated file is in Ada, remove the first eight
2413 -- characters " -- ".
2415 Next_Line (1 .. Nlast - 8) := Next_Line (9 .. Nlast);
2416 Nlast := Nlast - 8;
2418 -- Stop when the first switch is found
2420 exit when Next_Line (1) = '-';
2421 end loop;
2423 if Next_Line (1 .. Nlast) /= End_Info then
2424 loop
2425 -- Ignore -static and -shared, since -shared will be used
2426 -- in any case.
2428 -- Ignore -lgnat, -lgnarl and -ldecgnat as they will be added
2429 -- later, because they are also needed for non Stand-Alone shared
2430 -- libraries.
2432 -- Also ignore the shared libraries which are :
2434 -- UNIX / Windows VMS
2435 -- -lgnat-<version> -lgnat_<version> (7 + version'length chars)
2436 -- -lgnarl-<version> -lgnarl_<version> (8 + version'length chars)
2438 if Next_Line (1 .. Nlast) /= "-static" and then
2439 Next_Line (1 .. Nlast) /= "-shared" and then
2440 Next_Line (1 .. Nlast) /= "-ldecgnat" and then
2441 Next_Line (1 .. Nlast) /= "-lgnarl" and then
2442 Next_Line (1 .. Nlast) /= "-lgnat" and then
2443 Next_Line
2444 (1 .. Natural'Min (Nlast, 10 + Library_Version'Length)) /=
2445 Shared_Lib ("decgnat") and then
2446 Next_Line
2447 (1 .. Natural'Min (Nlast, 8 + Library_Version'Length)) /=
2448 Shared_Lib ("gnarl") and then
2449 Next_Line
2450 (1 .. Natural'Min (Nlast, 7 + Library_Version'Length)) /=
2451 Shared_Lib ("gnat")
2452 then
2453 if Next_Line (1) /= '-' then
2455 -- This is not an option, should we add it?
2457 if Add_Object_Files then
2458 Opts.Increment_Last;
2459 Opts.Table (Opts.Last) :=
2460 new String'(Next_Line (1 .. Nlast));
2461 end if;
2463 else
2464 -- Add all other options
2466 Opts.Increment_Last;
2467 Opts.Table (Opts.Last) :=
2468 new String'(Next_Line (1 .. Nlast));
2469 end if;
2470 end if;
2472 -- Next option, if any
2474 Get_Next_Line;
2475 exit when Next_Line (1 .. Nlast) = End_Info;
2477 -- Remove first eight characters " -- "
2479 Next_Line (1 .. Nlast - 8) := Next_Line (9 .. Nlast);
2480 Nlast := Nlast - 8;
2481 end loop;
2482 end if;
2484 Status := fclose (Fd);
2486 -- Is it really right to ignore any close error ???
2488 end Process_Binder_File;
2490 ------------------
2491 -- Reset_Tables --
2492 ------------------
2494 procedure Reset_Tables is
2495 begin
2496 Objects.Init;
2497 Objects_Htable.Reset;
2498 ALIs.Init;
2499 Opts.Init;
2500 Processed_Projects.Reset;
2501 Library_Projs.Init;
2502 end Reset_Tables;
2504 ---------------------------
2505 -- SALs_Use_Constructors --
2506 ---------------------------
2508 function SALs_Use_Constructors return Boolean is
2509 function C_SALs_Init_Using_Constructors return Integer;
2510 pragma Import (C, C_SALs_Init_Using_Constructors,
2511 "__gnat_sals_init_using_constructors");
2512 begin
2513 return C_SALs_Init_Using_Constructors /= 0;
2514 end SALs_Use_Constructors;
2516 end MLib.Prj;