1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2005, AdaCore --
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 2, 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 COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
28 with Gnatvsn; use Gnatvsn;
30 with MLib.Fil; use MLib.Fil;
31 with MLib.Tgt; use MLib.Tgt;
32 with MLib.Utl; use MLib.Utl;
33 with Namet; use Namet;
35 with Output; use Output;
36 with Prj.Com; use Prj.Com;
37 with Prj.Env; use Prj.Env;
38 with Prj.Util; use Prj.Util;
40 with Snames; use Snames;
41 with Switch; use Switch;
44 with Ada.Characters.Handling;
46 with GNAT.Directory_Operations; use GNAT.Directory_Operations;
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 aq stand-alone
60 -- False for Windows, True for other platforms.
62 ALI_Suffix : constant String := ".ali";
63 B_Start : String := "b~";
65 S_Osinte_Ads : Name_Id := No_Name;
66 -- Name_Id for "s-osinte.ads"
68 S_Dec_Ads : Name_Id := No_Name;
69 -- Name_Id for "dec.ads"
71 G_Trasym_Ads : Name_Id := No_Name;
72 -- Name_Id for "g-trasym.ads"
74 No_Argument_List : aliased String_List := (1 .. 0 => null);
75 No_Argument : constant String_List_Access := No_Argument_List'Access;
77 Arguments : String_List_Access := No_Argument;
78 -- Used to accumulate arguments for the invocation of gnatbind and of
79 -- the compiler. Also used to collect the interface ALI when copying
80 -- the ALI files to the library directory.
82 Argument_Number : Natural := 0;
83 -- Index of the last argument in Arguments
85 Initial_Argument_Max : constant := 10;
87 No_Main_String : aliased String := "-n";
88 No_Main : constant String_Access := No_Main_String'Access;
90 Output_Switch_String : aliased String := "-o";
91 Output_Switch : constant String_Access := Output_Switch_String'Access;
93 Compile_Switch_String : aliased String := "-c";
94 Compile_Switch : constant String_Access := Compile_Switch_String'Access;
96 Auto_Initialize : constant String := "-a";
98 -- List of objects to put inside the library
100 Object_Files : Argument_List_Access;
102 package Objects is new Table.Table
103 (Table_Name => "Mlib.Prj.Objects",
104 Table_Component_Type => String_Access,
105 Table_Index_Type => Natural,
106 Table_Low_Bound => 1,
108 Table_Increment => 100);
110 package Objects_Htable is new GNAT.HTable.Simple_HTable
111 (Header_Num => Header_Num,
118 -- List of non-Ada object files
120 Foreign_Objects : Argument_List_Access;
122 package Foreigns is new Table.Table
123 (Table_Name => "Mlib.Prj.Foreigns",
124 Table_Component_Type => String_Access,
125 Table_Index_Type => Natural,
126 Table_Low_Bound => 1,
128 Table_Increment => 100);
132 Ali_Files : Argument_List_Access;
134 package ALIs is new Table.Table
135 (Table_Name => "Mlib.Prj.Alis",
136 Table_Component_Type => String_Access,
137 Table_Index_Type => Natural,
138 Table_Low_Bound => 1,
140 Table_Increment => 100);
142 -- List of options set in the command line
144 Options : Argument_List_Access;
146 package Opts is new Table.Table
147 (Table_Name => "Mlib.Prj.Opts",
148 Table_Component_Type => String_Access,
149 Table_Index_Type => Natural,
150 Table_Low_Bound => 1,
152 Table_Increment => 100);
154 -- All the ALI file in the library
156 package Library_ALIs is new GNAT.HTable.Simple_HTable
157 (Header_Num => Header_Num,
164 -- The ALI files in the interface sets
166 package Interface_ALIs is new GNAT.HTable.Simple_HTable
167 (Header_Num => Header_Num,
174 -- The ALI files that have been processed to check if the corresponding
175 -- library unit is in the interface set.
177 package Processed_ALIs is new GNAT.HTable.Simple_HTable
178 (Header_Num => Header_Num,
185 -- The projects imported directly or indirectly
187 package Processed_Projects is new GNAT.HTable.Simple_HTable
188 (Header_Num => Header_Num,
195 -- The library projects imported directly or indirectly
197 package Library_Projs is new Table.Table (
198 Table_Component_Type => Project_Id,
199 Table_Index_Type => Integer,
200 Table_Low_Bound => 1,
202 Table_Increment => 10,
203 Table_Name => "Make.Library_Projs");
205 type Build_Mode_State is (None, Static, Dynamic, Relocatable);
207 procedure Add_Argument (S : String);
208 -- Add one argument to Arguments array, if array is full, double its size
210 function ALI_File_Name (Source : String) return String;
211 -- Return the ALI file name corresponding to a source
213 procedure Check (Filename : String);
214 -- Check if filename is a regular file. Fail if it is not
216 procedure Check_Context;
217 -- Check each object files in table Object_Files
218 -- Fail if any of them is not a regular file
220 procedure Copy_Interface_Sources
221 (For_Project : Project_Id;
222 In_Tree : Project_Tree_Ref;
223 Interfaces : Argument_List;
225 -- Copy the interface sources of a SAL to directory To_Dir
227 procedure Display (Executable : String);
228 -- Display invocation of gnatbind and of the compiler with the arguments
229 -- in Arguments, except when Quiet_Output is True.
231 procedure Process_Binder_File (Name : String);
232 -- For Stand-Alone libraries, get the Linker Options in the binder
235 procedure Reset_Tables;
236 -- Make sure that all the above tables are empty
237 -- (Objects, Foreign_Objects, Ali_Files, Options).
239 function SALs_Use_Constructors return Boolean;
240 -- Indicate if Stand-Alone Libraries are automatically initialized using
241 -- the constructor mechanism.
243 function Ultimate_Extension_Of
244 (Project : Project_Id;
245 In_Tree : Project_Tree_Ref) return Project_Id;
246 -- Returns the Project_Id of project Project. Returns No_Project
247 -- if Project is No_Project.
253 procedure Add_Argument (S : String) is
255 if Argument_Number = Arguments'Last then
257 New_Args : constant String_List_Access :=
258 new String_List (1 .. 2 * Arguments'Last);
261 -- Copy the String_Accesses and set them to null in Arguments
262 -- so that they will not be deallocated by the call to
265 New_Args (Arguments'Range) := Arguments.all;
266 Arguments.all := (others => null);
268 Arguments := New_Args;
272 Argument_Number := Argument_Number + 1;
273 Arguments (Argument_Number) := new String'(S);
280 function ALI_File_Name (Source : String) return String is
282 -- If the source name has an extension, then replace it with
285 for Index in reverse Source'First + 1 .. Source'Last loop
286 if Source (Index) = '.' then
287 return Source (Source'First .. Index - 1) & ALI_Suffix;
291 -- If there is no dot, or if it is the first character, just add the
294 return Source & ALI_Suffix;
301 procedure Build_Library
302 (For_Project : Project_Id;
303 In_Tree : Project_Tree_Ref;
305 Gnatbind_Path : String_Access;
307 Gcc_Path : String_Access;
308 Bind : Boolean := True;
309 Link : Boolean := True)
311 Warning_For_Library : Boolean := False;
312 -- Set to True for the first warning about a unit missing from the
315 Libgnarl_Needed : Boolean := False;
316 -- Set to True if library needs to be linked with libgnarl
318 Libdecgnat_Needed : Boolean := False;
319 -- On OpenVMS, set to True if library needs to be linked with libdecgnat
321 Gtrasymobj_Needed : Boolean := False;
322 -- On OpenVMS, set to True if library needs to be linked with
325 Data : Project_Data := In_Tree.Projects.Table (For_Project);
327 Object_Directory_Path : constant String :=
328 Get_Name_String (Data.Object_Directory);
330 Standalone : constant Boolean := Data.Standalone_Library;
332 Project_Name : constant String := Get_Name_String (Data.Name);
334 Current_Dir : constant String := Get_Current_Dir;
336 Lib_Filename : String_Access;
337 Lib_Dirpath : String_Access;
338 Lib_Version : String_Access := new String'("");
340 The_Build_Mode : Build_Mode_State := None;
342 Success : Boolean := False;
344 Library_Options : Variable_Value := Nil_Variable_Value;
346 Library_GCC : Variable_Value := Nil_Variable_Value;
348 Driver_Name : Name_Id := No_Name;
350 In_Main_Object_Directory : Boolean := True;
352 Rpath : String_Access := null;
353 -- Allocated only if Path Option is supported
355 Rpath_Last : Natural := 0;
356 -- Index of last valid character of Rpath
358 Initial_Rpath_Length : constant := 200;
359 -- Initial size of Rpath, when first allocated
361 Path_Option : String_Access := Linker_Library_Path_Option;
362 -- If null, Path Option is not supported.
363 -- Not a constant so that it can be deallocated.
365 First_ALI : Name_Id := No_Name;
366 -- Store the ALI file name of a source of the library (the first found)
368 procedure Add_ALI_For (Source : Name_Id);
369 -- Add the name of the ALI file corresponding to Source to the
372 procedure Add_Rpath (Path : String);
373 -- Add a path name to Rpath
375 function Check_Project (P : Project_Id) return Boolean;
376 -- Returns True if P is For_Project or a project extended by For_Project
378 procedure Check_Libs (ALI_File : String);
379 -- Set Libgnarl_Needed if the ALI_File indicates that there is a need
380 -- to link with -lgnarl (this is the case when there is a dependency
381 -- on s-osinte.ads). On OpenVMS, set Libdecgnat_Needed if the ALI file
382 -- indicates that there is a need to link with -ldecgnat (this is the
383 -- case when there is a dependency on dec.ads), and set
384 -- Gtrasymobj_Needed if there is a dependency on g-trasym.ads.
386 procedure Process (The_ALI : File_Name_Type);
387 -- Check if the closure of a library unit which is or should be in the
388 -- interface set is also in the interface set. Issue a warning for each
389 -- missing library unit.
391 procedure Process_Imported_Libraries;
392 -- Add the -L and -l switches for the imported Library Project Files,
393 -- and, if Path Option is supported, the library directory path names
400 procedure Add_ALI_For (Source : Name_Id) is
401 ALI : constant String := ALI_File_Name (Get_Name_String (Source));
410 Add_Str_To_Name_Buffer (S => ALI);
413 -- Add the ALI file name to the library ALIs
416 Library_ALIs.Set (ALI_Id, True);
419 -- Set First_ALI, if not already done
421 if First_ALI = No_Name then
430 procedure Add_Rpath (Path : String) is
440 New_Rpath : constant String_Access :=
441 new String (1 .. 2 * Rpath'Length);
443 New_Rpath (1 .. Rpath_Last) := Rpath (1 .. Rpath_Last);
448 -- Start of processing for Add_Rpath
451 -- If firt path, allocate initial Rpath
454 Rpath := new String (1 .. Initial_Rpath_Length);
458 -- Otherwise, add a path separator between two path names
460 if Rpath_Last = Rpath'Last then
464 Rpath_Last := Rpath_Last + 1;
465 Rpath (Rpath_Last) := Path_Separator;
468 -- Increase Rpath size until it is large enough
470 while Rpath_Last + Path'Length > Rpath'Last loop
476 Rpath (Rpath_Last + 1 .. Rpath_Last + Path'Length) := Path;
477 Rpath_Last := Rpath_Last + Path'Length;
484 function Check_Project (P : Project_Id) return Boolean is
486 if P = For_Project then
489 elsif P /= No_Project then
491 Data : Project_Data :=
492 In_Tree.Projects.Table (For_Project);
494 while Data.Extends /= No_Project loop
495 if P = Data.Extends then
499 Data := In_Tree.Projects.Table (Data.Extends);
511 procedure Check_Libs (ALI_File : String) is
513 Text : Text_Buffer_Ptr;
517 if not Libgnarl_Needed or
518 (Hostparm.OpenVMS and then
519 ((not Libdecgnat_Needed) or
520 (not Gtrasymobj_Needed)))
524 Name_Len := ALI_File'Length;
525 Name_Buffer (1 .. Name_Len) := ALI_File;
526 Lib_File := Name_Find;
527 Text := Read_Library_Info (Lib_File, True);
537 -- Look for s-osinte.ads in the dependencies
539 for Index in ALI.ALIs.Table (Id).First_Sdep ..
540 ALI.ALIs.Table (Id).Last_Sdep
542 if ALI.Sdep.Table (Index).Sfile = S_Osinte_Ads then
543 Libgnarl_Needed := True;
545 elsif Hostparm.OpenVMS 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;
561 procedure Process (The_ALI : File_Name_Type) is
562 Text : Text_Buffer_Ptr;
564 First_Unit : ALI.Unit_Id;
565 Last_Unit : ALI.Unit_Id;
566 Unit_Data : Unit_Record;
567 Afile : File_Name_Type;
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);
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
594 if First_Unit /= Last_Unit and then
595 not ALI.Units.Table (Last_Unit).Body_Needed_For_SAL
597 First_Unit := Last_Unit;
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
607 for W in Unit_Data.First_With .. Unit_Data.Last_With loop
608 Afile := Withs.Table (W).Afile;
610 if Afile /= No_Name and then Library_ALIs.Get (Afile)
611 and then not Processed_ALIs.Get (Afile)
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 (Data.Name);
617 To_Mixed (Name_Buffer (1 .. Name_Len));
618 Write_Str (Name_Buffer (1 .. Name_Len));
620 Warning_For_Library := True;
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
632 Write_Str ("the spec of ");
635 Write_Str ("the body of ");
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));
648 -- Now, process this unit
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 Data : constant Project_Data :=
676 In_Tree.Projects.Table (Project);
677 Imported : Project_List := Data.Imported_Projects;
678 Element : Project_Element;
681 -- Nothing to do if process has already been processed
683 if not Processed_Projects.Get (Data.Name) then
684 Processed_Projects.Set (Data.Name, True);
686 -- Call Process_Project recursively for any imported project.
687 -- We first process the imported projects to guarantee that
688 -- we have a proper reverse order for the libraries.
690 while Imported /= Empty_Project_List loop
692 In_Tree.Project_Lists.Table (Imported);
694 if Element.Project /= No_Project then
695 Process_Project (Element.Project);
698 Imported := Element.Next;
701 -- If it is a library project, add it to Library_Projs
703 if Project /= For_Project and then Data.Library then
704 Library_Projs.Increment_Last;
705 Library_Projs.Table (Library_Projs.Last) := Project;
711 -- Start of processing for Process_Imported_Libraries
714 -- Build list of library projects imported directly or indirectly,
715 -- in the reverse order.
717 Process_Project (For_Project);
719 -- Add the -L and -l switches and, if the Rpath option is supported,
720 -- add the directory to the Rpath.
721 -- As the library projects are in the wrong order, process from the
722 -- last to the first.
724 for Index in reverse 1 .. Library_Projs.Last loop
725 Current := Library_Projs.Table (Index);
728 (In_Tree.Projects.Table (Current).Library_Dir);
730 Opts.Table (Opts.Last) :=
731 new String'("-L" & Name_Buffer (1 .. Name_Len));
733 if Path_Option /= null then
734 Add_Rpath (Name_Buffer (1 .. Name_Len));
738 Opts.Table (Opts.Last) :=
742 (In_Tree.Projects.Table
743 (Current).Library_Name));
745 end Process_Imported_Libraries;
747 -- Start of processing for Build_Library
752 -- Fail if project is not a library project
754 if not Data.Library then
755 Com.Fail ("project """, Project_Name, """ has no library");
758 -- If this is the first time Build_Library is called, get the Name_Id
759 -- of "s-osinte.ads".
761 if S_Osinte_Ads = No_Name then
763 Add_Str_To_Name_Buffer ("s-osinte.ads");
764 S_Osinte_Ads := Name_Find;
767 if S_Dec_Ads = No_Name then
769 Add_Str_To_Name_Buffer ("dec.ads");
770 S_Dec_Ads := Name_Find;
773 if G_Trasym_Ads = No_Name then
775 Add_Str_To_Name_Buffer ("g-trasym.ads");
776 G_Trasym_Ads := Name_Find;
779 -- We work in the object directory
781 Change_Dir (Object_Directory_Path);
784 -- Call gnatbind only if Bind is True
787 if Gnatbind_Path = null then
788 Com.Fail ("unable to locate ", Gnatbind);
791 if Gcc_Path = null then
792 Com.Fail ("unable to locate ", Gcc);
795 -- Allocate Arguments, if it is the first time we see a standalone
798 if Arguments = No_Argument then
799 Arguments := new String_List (1 .. Initial_Argument_Max);
802 -- Add "-n -o b~<lib>.adb (b$<lib>.adb on VMS) -L<lib>"
804 Argument_Number := 2;
805 Arguments (1) := No_Main;
806 Arguments (2) := Output_Switch;
808 if Hostparm.OpenVMS then
809 B_Start (B_Start'Last) := '$';
813 (B_Start & Get_Name_String (Data.Library_Name) & ".adb");
814 Add_Argument ("-L" & Get_Name_String (Data.Library_Name));
816 if Data.Lib_Auto_Init and then SALs_Use_Constructors then
817 Add_Argument (Auto_Initialize);
820 -- Check if Binder'Default_Switches ("Ada") is defined. If it is,
821 -- add these switches to call gnatbind.
824 Binder_Package : constant Package_Id :=
826 (Name => Name_Binder,
827 In_Packages => Data.Decl.Packages,
831 if Binder_Package /= No_Package then
833 Defaults : constant Array_Element_Id :=
835 (Name => Name_Default_Switches,
837 In_Tree.Packages.Table
838 (Binder_Package).Decl.Arrays,
840 Switches : Variable_Value := Nil_Variable_Value;
842 Switch : String_List_Id := Nil_String;
845 if Defaults /= No_Array_Element then
850 In_Array => Defaults,
853 if not Switches.Default then
854 Switch := Switches.Values;
856 while Switch /= Nil_String loop
859 (In_Tree.String_Elements.Table
861 Switch := In_Tree.String_Elements.
871 -- Get all the ALI files of the project file. We do that even if
872 -- Bind is False, so that First_ALI is set.
879 Interface_ALIs.Reset;
880 Processed_ALIs.Reset;
882 for Source in Unit_Table.First ..
883 Unit_Table.Last (In_Tree.Units)
885 Unit := In_Tree.Units.Table (Source);
887 if Unit.File_Names (Body_Part).Name /= No_Name
888 and then Unit.File_Names (Body_Part).Path /= Slash
891 Check_Project (Unit.File_Names (Body_Part).Project)
893 if Unit.File_Names (Specification).Name = No_Name then
895 Src_Ind : Source_File_Index;
898 Src_Ind := Sinput.P.Load_Project_File
903 -- Add the ALI file only if it is not a subunit
906 not Sinput.P.Source_File_Is_Subunit (Src_Ind)
909 (Unit.File_Names (Body_Part).Name);
915 Add_ALI_For (Unit.File_Names (Body_Part).Name);
920 elsif Unit.File_Names (Specification).Name /= No_Name
921 and then Unit.File_Names (Specification).Path /= Slash
922 and then Check_Project
923 (Unit.File_Names (Specification).Project)
925 Add_ALI_For (Unit.File_Names (Specification).Name);
931 -- Continue setup and call gnatbind if Bind is True
935 -- Get an eventual --RTS from the ALI file
937 if First_ALI /= No_Name then
945 T := Read_Library_Info (First_ALI, True);
950 (First_ALI, T, Ignore_ED => False, Err => False);
952 if A /= No_ALI_Id then
955 (ALI.ALIs.Table (A).First_Unit).First_Arg ..
957 (ALI.ALIs.Table (A).First_Unit).Last_Arg
959 -- Look for --RTS. If found, add the switch to call
963 Arg : String_Ptr renames Args.Table (Index);
965 if Arg'Length >= 6 and then
966 Arg (Arg'First + 2 .. Arg'First + 5) = "RTS="
968 Add_Argument (Arg.all);
980 (Project => For_Project,
982 Including_Libraries => True);
984 -- Display the gnatbind command, if not in quiet output
991 (Gnatbind_Path.all, Arguments (1 .. Argument_Number), Success);
994 Com.Fail ("could not bind standalone library ",
995 Get_Name_String (Data.Library_Name));
999 -- Compile the binder generated file only if Link is true
1005 (Project => For_Project,
1007 Including_Libraries => True);
1009 -- Invoke <gcc> -c b$$<lib>.adb
1011 -- Allocate Arguments, if it is the first time we see a standalone
1014 if Arguments = No_Argument then
1015 Arguments := new String_List (1 .. Initial_Argument_Max);
1018 Argument_Number := 1;
1019 Arguments (1) := Compile_Switch;
1021 if Hostparm.OpenVMS then
1022 B_Start (B_Start'Last) := '$';
1026 (B_Start & Get_Name_String (Data.Library_Name) & ".adb");
1028 -- If necessary, add the PIC option
1030 if PIC_Option /= "" then
1031 Add_Argument (PIC_Option);
1034 -- Get the back-end switches and --RTS from the ALI file
1036 if First_ALI /= No_Name then
1038 T : Text_Buffer_Ptr;
1042 -- Load the ALI file
1044 T := Read_Library_Info (First_ALI, True);
1049 (First_ALI, T, Ignore_ED => False, Err => False);
1051 if A /= No_ALI_Id then
1054 (ALI.ALIs.Table (A).First_Unit).First_Arg ..
1056 (ALI.ALIs.Table (A).First_Unit).Last_Arg
1058 -- Do not compile with the front end switches except
1062 Arg : String_Ptr renames Args.Table (Index);
1064 if not Is_Front_End_Switch (Arg.all)
1066 Arg (Arg'First + 2 .. Arg'First + 5) = "RTS="
1068 Add_Argument (Arg.all);
1076 -- Now that all the arguments are set, compile the binder
1081 (Gcc_Path.all, Arguments (1 .. Argument_Number), Success);
1085 ("could not compile binder generated file for library ",
1086 Get_Name_String (Data.Library_Name));
1089 -- Process binder generated file for pragmas Linker_Options
1091 Process_Binder_File (Arguments (2).all & ASCII.NUL);
1095 -- Build the library only if Link is True
1098 -- If attribute Library_GCC was specified, get the driver name
1101 Value_Of (Name_Library_GCC, Data.Decl.Attributes, In_Tree);
1103 if not Library_GCC.Default then
1104 Driver_Name := Library_GCC.Value;
1107 -- If attribute Library_Options was specified, add these additional
1111 Value_Of (Name_Library_Options, Data.Decl.Attributes, In_Tree);
1113 if not Library_Options.Default then
1115 Current : String_List_Id := Library_Options.Values;
1116 Element : String_Element;
1119 while Current /= Nil_String loop
1121 In_Tree.String_Elements.Table (Current);
1122 Get_Name_String (Element.Value);
1124 if Name_Len /= 0 then
1125 Opts.Increment_Last;
1126 Opts.Table (Opts.Last) :=
1127 new String'(Name_Buffer (1 .. Name_Len));
1130 Current := Element.Next;
1135 Lib_Dirpath := new String'(Get_Name_String (Data.Library_Dir));
1136 Lib_Filename := new String'(Get_Name_String (Data.Library_Name));
1138 case Data.Library_Kind is
1140 The_Build_Mode := Static;
1143 The_Build_Mode := Dynamic;
1146 The_Build_Mode := Relocatable;
1148 if PIC_Option /= "" then
1149 Opts.Increment_Last;
1150 Opts.Table (Opts.Last) := new String'(PIC_Option);
1154 -- Get the library version, if any
1156 if Data.Lib_Internal_Name /= No_Name then
1158 new String'(Get_Name_String (Data.Lib_Internal_Name));
1161 -- Add the objects found in the object directory and the object
1162 -- directories of the extended files, if any, except for generated
1163 -- object files (b~.. or B$..) from extended projects.
1164 -- When there are one or more extended files, only add an object file
1165 -- if no object file with the same name have already been added.
1167 In_Main_Object_Directory := True;
1171 Object_Dir_Path : constant String :=
1172 Get_Name_String (Data.Object_Directory);
1173 Object_Dir : Dir_Type;
1174 Filename : String (1 .. 255);
1179 Open (Dir => Object_Dir, Dir_Name => Object_Dir_Path);
1181 -- For all entries in the object directory
1184 Read (Object_Dir, Filename, Last);
1188 -- Check if it is an object file
1190 if Is_Obj (Filename (1 .. Last)) then
1192 Object_Path : String :=
1194 (Object_Dir_Path & Directory_Separator &
1195 Filename (1 .. Last));
1198 Canonical_Case_File_Name (Object_Path);
1199 Canonical_Case_File_Name (Filename (1 .. Last));
1201 -- If in the object directory of an extended project,
1202 -- do not consider generated object files.
1204 if In_Main_Object_Directory
1206 or else Filename (1 .. B_Start'Length) /= B_Start
1209 Name_Buffer (1 .. Name_Len) := Filename (1 .. Last);
1212 if not Objects_Htable.Get (Id) then
1214 -- Record this object file
1216 Objects_Htable.Set (Id, True);
1217 Objects.Increment_Last;
1218 Objects.Table (Objects.Last) :=
1219 new String'(Object_Path);
1222 ALI_File : constant String :=
1223 Ext_To (Object_Path, "ali");
1226 if Is_Regular_File (ALI_File) then
1228 -- Record the ALI file
1230 ALIs.Increment_Last;
1231 ALIs.Table (ALIs.Last) :=
1232 new String'(ALI_File);
1234 -- Find out if for this ALI file,
1235 -- libgnarl or libdecgnat or g-trasym.obj
1236 -- (on OpenVMS) is necessary.
1238 Check_Libs (ALI_File);
1241 -- Object file is a foreign object file
1243 Foreigns.Increment_Last;
1244 Foreigns.Table (Foreigns.Last) :=
1245 new String'(Object_Path);
1254 Close (Dir => Object_Dir);
1257 when Directory_Error =>
1258 Com.Fail ("cannot find object directory """,
1259 Get_Name_String (Data.Object_Directory),
1263 exit when Data.Extends = No_Project;
1265 In_Main_Object_Directory := False;
1266 Data := In_Tree.Projects.Table (Data.Extends);
1269 -- Add the -L and -l switches for the imported Library Project Files,
1270 -- and, if Path Option is supported, the library directory path names
1273 Process_Imported_Libraries;
1275 -- Link with libgnat and possibly libgnarl
1277 Opts.Increment_Last;
1278 Opts.Table (Opts.Last) := new String'("-L" & Lib_Directory);
1280 -- If Path Option is supported, add libgnat directory path name to
1283 if Path_Option /= null then
1284 Add_Rpath (Lib_Directory);
1287 if Libgnarl_Needed then
1288 Opts.Increment_Last;
1290 if The_Build_Mode = Static then
1291 Opts.Table (Opts.Last) := new String'("-lgnarl");
1293 Opts.Table (Opts.Last) := new String'(Shared_Lib ("gnarl"));
1297 if Gtrasymobj_Needed then
1298 Opts.Increment_Last;
1299 Opts.Table (Opts.Last) :=
1300 new String'(Lib_Directory & "/g-trasym.obj");
1303 if Libdecgnat_Needed then
1304 Opts.Increment_Last;
1305 Opts.Table (Opts.Last) :=
1306 new String'("-L" & Lib_Directory & "/../declib");
1307 Opts.Increment_Last;
1308 Opts.Table (Opts.Last) := new String'("-ldecgnat");
1311 Opts.Increment_Last;
1313 if The_Build_Mode = Static then
1314 Opts.Table (Opts.Last) := new String'("-lgnat");
1316 Opts.Table (Opts.Last) := new String'(Shared_Lib ("gnat"));
1319 -- If Path Option is supported, add the necessary switch with the
1320 -- content of Rpath. As Rpath contains at least libgnat directory
1321 -- path name, it is guaranteed that it is not null.
1323 if Path_Option /= null then
1324 Opts.Increment_Last;
1325 Opts.Table (Opts.Last) :=
1326 new String'(Path_Option.all & Rpath (1 .. Rpath_Last));
1333 (Argument_List (Objects.Table (1 .. Objects.Last)));
1336 new Argument_List'(Argument_List
1337 (Foreigns.Table (1 .. Foreigns.Last)));
1340 new Argument_List'(Argument_List (ALIs.Table (1 .. ALIs.Last)));
1343 new Argument_List'(Argument_List (Opts.Table (1 .. Opts.Last)));
1345 -- We fail if there are no object to put in the library
1346 -- (Ada or foreign objects).
1348 if Object_Files'Length = 0 then
1349 Com.Fail ("no object files for library """ &
1350 Lib_Filename.all & '"');
1353 if not Opt.Quiet_Output then
1355 Write_Str ("building ");
1356 Write_Str (Ada.Characters.Handling.To_Lower
1357 (Build_Mode_State'Image (The_Build_Mode)));
1358 Write_Str (" library for project ");
1359 Write_Line (Project_Name);
1363 Write_Line ("object files:");
1365 for Index in Object_Files'Range loop
1367 Write_Line (Object_Files (Index).all);
1372 if Ali_Files'Length = 0 then
1373 Write_Line ("NO ALI files");
1376 Write_Line ("ALI files:");
1378 for Index in Ali_Files'Range loop
1380 Write_Line (Ali_Files (Index).all);
1387 -- We check that all object files are regular files
1391 -- Delete the existing library file, if it exists.
1392 -- Fail if the library file is not writable, or if it is not possible
1393 -- to delete the file.
1396 DLL_Name : aliased String :=
1397 Lib_Dirpath.all & '/' & DLL_Prefix &
1398 Lib_Filename.all & "." & DLL_Ext;
1400 Archive_Name : aliased String :=
1401 Lib_Dirpath.all & "/lib" &
1402 Lib_Filename.all & "." & Archive_Ext;
1404 type Str_Ptr is access all String;
1405 -- This type is necessary to meet the accessibility rules of Ada.
1406 -- It is not possible to use String_Access here.
1408 Full_Lib_Name : Str_Ptr;
1409 -- Designates the full library path name. Either DLL_Name or
1410 -- Archive_Name, depending on the library kind.
1412 Success : Boolean := False;
1413 -- Used to call Delete_File
1416 if The_Build_Mode = Static then
1417 Full_Lib_Name := Archive_Name'Access;
1419 Full_Lib_Name := DLL_Name'Access;
1422 if Is_Regular_File (Full_Lib_Name.all) then
1423 if Is_Writable_File (Full_Lib_Name.all) then
1424 Delete_File (Full_Lib_Name.all, Success);
1427 if Is_Regular_File (Full_Lib_Name.all) then
1428 Com.Fail ("could not delete """ & Full_Lib_Name.all & """");
1433 Argument_Number := 0;
1435 -- If we have a standalone library, gather all the interface ALI.
1436 -- They are passed to Build_Dynamic_Library, where they are used by
1437 -- some platforms (VMS, for example) to decide what symbols should be
1438 -- exported. They are also flagged as Interface when we copy them to
1439 -- the library directory (by Copy_ALI_Files, below).
1442 Data := In_Tree.Projects.Table (For_Project);
1445 Iface : String_List_Id := Data.Lib_Interface_ALIs;
1446 ALI : File_Name_Type;
1449 while Iface /= Nil_String loop
1451 In_Tree.String_Elements.Table (Iface).Value;
1452 Interface_ALIs.Set (ALI, True);
1454 (In_Tree.String_Elements.Table (Iface).Value);
1455 Add_Argument (Name_Buffer (1 .. Name_Len));
1457 In_Tree.String_Elements.Table (Iface).Next;
1460 Iface := Data.Lib_Interface_ALIs;
1462 if not Opt.Quiet_Output then
1464 -- Check that the interface set is complete: any unit in the
1465 -- library that is needed by an interface should also be an
1466 -- interface. If it is not the case, output a warning.
1468 while Iface /= Nil_String loop
1469 ALI := In_Tree.String_Elements.Table
1473 In_Tree.String_Elements.Table (Iface).Next;
1480 Current_Dir : constant String := Get_Current_Dir;
1483 Name : String (1 .. 200);
1486 Disregard : Boolean;
1488 DLL_Name : aliased constant String :=
1489 Lib_Filename.all & "." & DLL_Ext;
1491 Archive_Name : aliased constant String :=
1492 Lib_Filename.all & "." & Archive_Ext;
1494 Delete : Boolean := False;
1497 -- Clean the library directory: remove any file with the name of
1498 -- the library file and any ALI file of a source of the project.
1502 (In_Tree.Projects.Table (For_Project).Library_Dir);
1503 Change_Dir (Name_Buffer (1 .. Name_Len));
1508 ("unable to access library directory """,
1509 Name_Buffer (1 .. Name_Len),
1516 Read (Dir, Name, Last);
1519 if Is_Regular_File (Name (1 .. Last)) then
1520 Canonical_Case_File_Name (Name (1 .. Last));
1523 if (The_Build_Mode = Static and then
1524 Name (1 .. Last) = Archive_Name)
1526 ((The_Build_Mode = Dynamic or else
1527 The_Build_Mode = Relocatable)
1529 Name (1 .. Last) = DLL_Name)
1533 elsif Last > 4 and then Name (Last - 3 .. Last) = ".ali" then
1537 -- Compare with ALI file names of the project
1539 for Index in 1 .. Unit_Table.Last (In_Tree.Units) loop
1540 Unit := In_Tree.Units.Table (Index);
1542 if Unit.File_Names (Body_Part).Project /=
1545 if Ultimate_Extension_Of
1546 (Unit.File_Names (Body_Part).Project, In_Tree)
1550 (Unit.File_Names (Body_Part).Name);
1551 Name_Len := Name_Len -
1553 (Name (1 .. Name_Len))'Length;
1554 if Name_Buffer (1 .. Name_Len) =
1555 Name (1 .. Last - 4)
1562 elsif Ultimate_Extension_Of
1563 (Unit.File_Names (Specification).Project, In_Tree)
1567 (Unit.File_Names (Specification).Name);
1568 Name_Len := Name_Len -
1569 File_Extension (Name (1 .. Name_Len))'Length;
1571 if Name_Buffer (1 .. Name_Len) =
1572 Name (1 .. Last - 4)
1583 Set_Writable (Name (1 .. Last));
1584 Delete_File (Name (1 .. Last), Disregard);
1591 Change_Dir (Current_Dir);
1594 -- Call procedure to build the library, depending on the build mode
1596 case The_Build_Mode is
1597 when Dynamic | Relocatable =>
1598 Build_Dynamic_Library
1599 (Ofiles => Object_Files.all,
1600 Foreign => Foreign_Objects.all,
1601 Afiles => Ali_Files.all,
1602 Options => Options.all,
1603 Options_2 => No_Argument_List,
1604 Interfaces => Arguments (1 .. Argument_Number),
1605 Lib_Filename => Lib_Filename.all,
1606 Lib_Dir => Lib_Dirpath.all,
1607 Symbol_Data => Data.Symbol_Data,
1608 Driver_Name => Driver_Name,
1609 Lib_Version => Lib_Version.all,
1610 Auto_Init => Data.Lib_Auto_Init);
1623 -- We need to copy the ALI files from the object directory to
1624 -- the library ALI directory, so that the linker find them there,
1625 -- and does not need to look in the object directory where it
1626 -- would also find the object files; and we don't want that:
1627 -- we want the linker to use the library.
1629 -- Copy the ALI files and make the copies read-only. For interfaces,
1630 -- mark the copies as interfaces.
1633 (Files => Ali_Files.all,
1634 To => In_Tree.Projects.Table (For_Project).Library_ALI_Dir,
1635 Interfaces => Arguments (1 .. Argument_Number));
1637 -- Copy interface sources if Library_Src_Dir specified
1640 and then In_Tree.Projects.Table
1641 (For_Project).Library_Src_Dir /= No_Name
1643 -- Clean the interface copy directory: remove any source that
1644 -- could be a source of the project.
1648 (In_Tree.Projects.Table (For_Project).Library_Src_Dir);
1649 Change_Dir (Name_Buffer (1 .. Name_Len));
1654 ("unable to access library source copy directory """,
1655 Name_Buffer (1 .. Name_Len),
1664 Name : String (1 .. 200);
1667 Disregard : Boolean;
1673 Read (Dir, Name, Last);
1676 if Is_Regular_File (Name (1 .. Last)) then
1677 Canonical_Case_File_Name (Name (1 .. Last));
1680 -- Compare with source file names of the project
1682 for Index in 1 .. Unit_Table.Last (In_Tree.Units) loop
1683 Unit := In_Tree.Units.Table (Index);
1685 if Ultimate_Extension_Of
1686 (Unit.File_Names (Body_Part).Project, In_Tree) =
1690 (Unit.File_Names (Body_Part).Name) =
1697 if Ultimate_Extension_Of
1698 (Unit.File_Names (Specification).Project, In_Tree) =
1702 (Unit.File_Names (Specification).Name) =
1712 Set_Writable (Name (1 .. Last));
1713 Delete_File (Name (1 .. Last), Disregard);
1720 Copy_Interface_Sources
1721 (For_Project => For_Project,
1723 Interfaces => Arguments (1 .. Argument_Number),
1724 To_Dir => In_Tree.Projects.Table
1725 (For_Project).Library_Src_Dir);
1729 -- Reset the current working directory to its previous value
1731 Change_Dir (Current_Dir);
1738 procedure Check (Filename : String) is
1740 if not Is_Regular_File (Filename) then
1741 Com.Fail (Filename, " not found.");
1749 procedure Check_Context is
1751 -- Check that each object file exists
1753 for F in Object_Files'Range loop
1754 Check (Object_Files (F).all);
1762 procedure Check_Library
1763 (For_Project : Project_Id; In_Tree : Project_Tree_Ref)
1765 Data : constant Project_Data :=
1766 In_Tree.Projects.Table (For_Project);
1767 Lib_TS : Time_Stamp_Type;
1768 Current : constant Dir_Name_Str := Get_Current_Dir;
1771 -- No need to build the library if there is no object directory,
1772 -- hence no object files to build the library.
1774 if Data.Library then
1776 Lib_Name : constant Name_Id :=
1777 Library_File_Name_For (For_Project, In_Tree);
1779 Change_Dir (Get_Name_String (Data.Library_Dir));
1780 Lib_TS := File_Stamp (Lib_Name);
1781 In_Tree.Projects.Table (For_Project).Library_TS := Lib_TS;
1784 if not Data.Externally_Built
1785 and then not Data.Need_To_Build_Lib
1786 and then Data.Object_Directory /= No_Name
1789 Obj_TS : Time_Stamp_Type;
1790 Object_Dir : Dir_Type;
1793 if Hostparm.OpenVMS then
1794 B_Start (B_Start'Last) := '$';
1797 -- If the library file does not exist, then the time stamp will
1798 -- be Empty_Time_Stamp, earlier than any other time stamp.
1800 Change_Dir (Get_Name_String (Data.Object_Directory));
1801 Open (Dir => Object_Dir, Dir_Name => ".");
1803 -- For all entries in the object directory
1806 Read (Object_Dir, Name_Buffer, Name_Len);
1807 exit when Name_Len = 0;
1809 -- Check if it is an object file, but ignore any binder
1812 if Is_Obj (Name_Buffer (1 .. Name_Len))
1813 and then Name_Buffer (1 .. B_Start'Length) /= B_Start
1815 -- Get the object file time stamp
1817 Obj_TS := File_Stamp (Name_Find);
1819 -- If library file time stamp is earlier, set
1820 -- Need_To_Build_Lib and return. String comparaison is
1821 -- used, otherwise time stamps may be too close and the
1822 -- comparaison would return True, which would trigger
1823 -- an unnecessary rebuild of the library.
1825 if String (Lib_TS) < String (Obj_TS) then
1827 -- Library must be rebuilt
1829 In_Tree.Projects.Table
1830 (For_Project).Need_To_Build_Lib := True;
1840 Change_Dir (Current);
1844 ----------------------------
1845 -- Copy_Interface_Sources --
1846 ----------------------------
1848 procedure Copy_Interface_Sources
1849 (For_Project : Project_Id;
1850 In_Tree : Project_Tree_Ref;
1851 Interfaces : Argument_List;
1854 Current : constant Dir_Name_Str := Get_Current_Dir;
1855 -- The current directory, where to return to at the end
1857 Target : constant Dir_Name_Str := Get_Name_String (To_Dir);
1858 -- The directory where to copy sources
1860 Text : Text_Buffer_Ptr;
1861 The_ALI : ALI.ALI_Id;
1864 First_Unit : ALI.Unit_Id;
1865 Second_Unit : ALI.Unit_Id;
1869 Copy_Subunits : Boolean := False;
1870 -- When True, indicates that subunits, if any, need to be copied too
1872 procedure Copy (File_Name : Name_Id);
1873 -- Copy one source of the project to the target directory
1875 function Is_Same_Or_Extension
1876 (Extending : Project_Id;
1877 Extended : Project_Id) return Boolean;
1878 -- Return True if project Extending is equal to or extends project
1885 procedure Copy (File_Name : Name_Id) is
1886 Success : Boolean := False;
1890 for Index in Unit_Table.First ..
1891 Unit_Table.Last (In_Tree.Units)
1893 Data := In_Tree.Units.Table (Index);
1895 -- Find and copy the immediate or inherited source
1897 for J in Data.File_Names'Range loop
1898 if Is_Same_Or_Extension
1899 (For_Project, Data.File_Names (J).Project)
1900 and then Data.File_Names (J).Name = File_Name
1903 (Get_Name_String (Data.File_Names (J).Path),
1907 Preserve => Preserve);
1914 --------------------------
1915 -- Is_Same_Or_Extension --
1916 --------------------------
1918 function Is_Same_Or_Extension
1919 (Extending : Project_Id;
1920 Extended : Project_Id) return Boolean
1922 Ext : Project_Id := Extending;
1925 while Ext /= No_Project loop
1926 if Ext = Extended then
1930 Ext := In_Tree.Projects.Table (Ext).Extends;
1934 end Is_Same_Or_Extension;
1936 -- Start of processing for Copy_Interface_Sources
1939 -- Change the working directory to the object directory
1943 (In_Tree.Projects.Table
1944 (For_Project).Object_Directory));
1946 for Index in Interfaces'Range loop
1948 -- First, load the ALI file
1951 Add_Str_To_Name_Buffer (Interfaces (Index).all);
1952 Lib_File := Name_Find;
1953 Text := Read_Library_Info (Lib_File);
1954 The_ALI := Scan_ALI (Lib_File, Text, Ignore_ED => False, Err => True);
1957 Second_Unit := No_Unit_Id;
1958 First_Unit := ALI.ALIs.Table (The_ALI).First_Unit;
1959 Copy_Subunits := True;
1961 -- If there is both a spec and a body, check if they are both needed
1963 if ALI.Units.Table (First_Unit).Utype = Is_Body then
1964 Second_Unit := ALI.ALIs.Table (The_ALI).Last_Unit;
1966 -- If the body is not needed, then reset First_Unit
1968 if not ALI.Units.Table (Second_Unit).Body_Needed_For_SAL then
1969 First_Unit := No_Unit_Id;
1970 Copy_Subunits := False;
1973 elsif ALI.Units.Table (First_Unit).Utype = Is_Spec_Only then
1974 Copy_Subunits := False;
1977 -- Copy the file(s) that need to be copied
1979 if First_Unit /= No_Unit_Id then
1980 Copy (File_Name => ALI.Units.Table (First_Unit).Sfile);
1983 if Second_Unit /= No_Unit_Id then
1984 Copy (File_Name => ALI.Units.Table (Second_Unit).Sfile);
1987 -- Copy all the separates, if any
1989 if Copy_Subunits then
1990 for Dep in ALI.ALIs.Table (The_ALI).First_Sdep ..
1991 ALI.ALIs.Table (The_ALI).Last_Sdep
1993 if Sdep.Table (Dep).Subunit_Name /= No_Name then
1994 Copy (File_Name => Sdep.Table (Dep).Sfile);
2000 -- Restore the initial working directory
2002 Change_Dir (Current);
2003 end Copy_Interface_Sources;
2009 procedure Display (Executable : String) is
2011 if not Opt.Quiet_Output then
2012 Write_Str (Executable);
2014 for Index in 1 .. Argument_Number loop
2016 Write_Str (Arguments (Index).all);
2023 -------------------------
2024 -- Process_Binder_File --
2025 -------------------------
2027 procedure Process_Binder_File (Name : String) is
2029 -- Binder file's descriptor
2031 Read_Mode : constant String := "r" & ASCII.Nul;
2034 Status : Interfaces.C_Streams.int;
2035 pragma Unreferenced (Status);
2038 Begin_Info : constant String := "-- BEGIN Object file/option list";
2039 End_Info : constant String := "-- END Object file/option list ";
2041 Next_Line : String (1 .. 1000);
2042 -- Current line value
2043 -- Where does this odd constant 1000 come from, looks suspicious ???
2046 -- End of line slice (the slice does not contain the line terminator)
2048 procedure Get_Next_Line;
2049 -- Read the next line from the binder file without the line terminator
2055 procedure Get_Next_Line is
2059 Fchars := fgets (Next_Line'Address, Next_Line'Length, Fd);
2061 if Fchars = System.Null_Address then
2062 Fail ("Error reading binder output");
2066 while Nlast <= Next_Line'Last
2067 and then Next_Line (Nlast) /= ASCII.LF
2068 and then Next_Line (Nlast) /= ASCII.CR
2076 -- Start of processing for Process_Binder_File
2079 Fd := fopen (Name'Address, Read_Mode'Address);
2081 if Fd = NULL_Stream then
2082 Fail ("Failed to open binder output");
2085 -- Skip up to the Begin Info line
2089 exit when Next_Line (1 .. Nlast) = Begin_Info;
2092 -- Find the first switch
2097 exit when Next_Line (1 .. Nlast) = End_Info;
2099 -- As the binder generated file is in Ada, remove the first eight
2100 -- characters " -- ".
2102 Next_Line (1 .. Nlast - 8) := Next_Line (9 .. Nlast);
2105 -- Stop when the first switch is found
2107 exit when Next_Line (1) = '-';
2110 if Next_Line (1 .. Nlast) /= End_Info then
2112 -- Ignore -static and -shared, since -shared will be used
2115 -- Ignore -lgnat, -lgnarl and -ldecgnat as they will be added
2116 -- later, because they are also needed for non Stand-Alone shared
2119 -- Also ignore the shared libraries which are :
2121 -- UNIX / Windows VMS
2122 -- -lgnat-<version> -lgnat_<version> (7 + version'length chars)
2123 -- -lgnarl-<version> -lgnarl_<version> (8 + version'length chars)
2125 if Next_Line (1 .. Nlast) /= "-static" and then
2126 Next_Line (1 .. Nlast) /= "-shared" and then
2127 Next_Line (1 .. Nlast) /= "-ldecgnat" and then
2128 Next_Line (1 .. Nlast) /= "-lgnarl" and then
2129 Next_Line (1 .. Nlast) /= "-lgnat" and then
2131 (1 .. Natural'Min (Nlast, 8 + Library_Version'Length)) /=
2132 Shared_Lib ("gnarl") and then
2134 (1 .. Natural'Min (Nlast, 7 + Library_Version'Length)) /=
2137 if Next_Line (1) /= '-' then
2139 -- This is not an option, should we add it?
2141 if Add_Object_Files then
2142 Opts.Increment_Last;
2143 Opts.Table (Opts.Last) :=
2144 new String'(Next_Line (1 .. Nlast));
2148 -- Add all other options
2150 Opts.Increment_Last;
2151 Opts.Table (Opts.Last) :=
2152 new String'(Next_Line (1 .. Nlast));
2156 -- Next option, if any
2159 exit when Next_Line (1 .. Nlast) = End_Info;
2161 -- Remove first eight characters " -- "
2163 Next_Line (1 .. Nlast - 8) := Next_Line (9 .. Nlast);
2168 Status := fclose (Fd);
2170 -- Is it really right to ignore any close error ???
2172 end Process_Binder_File;
2178 procedure Reset_Tables is
2181 Objects_Htable.Reset;
2185 Processed_Projects.Reset;
2189 ---------------------------
2190 -- SALs_Use_Constructors --
2191 ---------------------------
2193 function SALs_Use_Constructors return Boolean is
2194 function C_SALs_Init_Using_Constructors return Integer;
2195 pragma Import (C, C_SALs_Init_Using_Constructors,
2196 "__gnat_sals_init_using_constructors");
2198 return C_SALs_Init_Using_Constructors /= 0;
2199 end SALs_Use_Constructors;
2201 ---------------------------
2202 -- Ultimate_Extension_Of --
2203 ---------------------------
2205 function Ultimate_Extension_Of
2206 (Project : Project_Id;
2207 In_Tree : Project_Tree_Ref) return Project_Id
2209 Result : Project_Id := Project;
2210 Data : Project_Data;
2213 if Project /= No_Project then
2215 Data := In_Tree.Projects.Table (Result);
2216 exit when Data.Extended_By = No_Project;
2217 Result := Data.Extended_By;
2222 end Ultimate_Extension_Of;