2004-09-09 Vincent Celier <celier@gnat.com> * a-direct.ads: Add pragma Ada_05 (Directory_Entry_Type): Give default value to component Kind to avoid not initialized warnings. * a-direct.adb (Current_Directory): Remove directory separator at the end. (Delete_Directory, Delete_Tree): Raise Name_Error if Directory is not an existing directory. (Fetch_Next_Entry): Give default value to variable Kind to avoid warning (Size (String)): Function C_Size returns Long_Integer, not File_Size. Convert the result to File_Size. * prj.ads: (Project_Error): New exception * prj-attr.adb: Except in procedure Initialize, Fail comes from Prj.Com, not from Osint. (Attrs, Package_Attributes): Tables moved to private part of spec (Add_Attribute, Add_Unknown_Package): Moved to new child package Prj.Attr.PM. (Register_New_Package (Name, Attributes), Register_New_Attribute): Raise Prj.Project_Error after call to Fail. (Register_New_Package (Name, Id)): Set Id to Empty_Package after calling Fail. Check that package name is not already in use. * prj-attr.ads: Comment updates to indicate that all subprograms may be used by tools, not only by the project manager, and to indicate that exception Prj.Prj_Error may be raised in case of problem. (Add_Unknown_Package, Add_Attribute): Moved to new child package Prj.Attr.PM. (Attrs, Package_Attributes): Table instantiations moved from the body to the private part to be accessible from Prj.Attr.PM body. * prj-dect.adb (Parse_Package_Declaration): Call Add_Unknown_Package from new package Prj.Attr.PM. (Parse_Attribute_Declaration): Call Add_Attribute from new package Prj.Attr.PM. * Makefile.in: Add prj-attr-pm.o to gnatmake object list * gnatbind.adb (Gnatbind): Correct warning message (Elaboration_Check instead of Elaboration_Checks). * a-calend.adb: Minor reformatting 2004-09-09 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> * gigi.h (maybe_pad_type): New declaration. (create_subprog_type): New arg RETURNS_BY_TARGET_PTR. * ada-tree.h: (TYPE_RETURNS_BY_TARGET_PTR_P): New macro. * cuintp.c: Convert to use buildN. * decl.c (maybe_pad_type): No longer static. (gnat_to_gnu_entity, case E_Function): Handle case of returning by target pointer. Convert to use buildN. * trans.c (call_to_gnu): Add arg GNU_TARGET; support TYPE_RETURNS_BY_TARGET_PTR_P. All callers changed. (gnat_to_gnu, case N_Assignment_Statement): Call call_to_gnu if call on RHS. (gnat_to_gnu, case N_Return): Handle TYPE_RETURN_BY_TARGET_PTR_P. (gnat_gimplify_expr, case ADDR_EXPR): New case. Convert to use buildN. * utils2.c (gnat_build_constructor): Also set TREE_INVARIANT and TREE_READONLY for const. Convert to use buildN. * utils.c (create_subprog_type): New operand RETURNS_BY_TARGET_PTR. (create_var_decl): Refine when TREE_STATIC is set. Convert to use buildN. 2004-09-09 Gary Dismukes <dismukes@gnat.com> * gnat_ugn.texi: Delete text relating to checking of ali and object consistency. * a-except.adb (Rcheck_*): Add pragmas No_Return for each of these routines. 2004-09-09 Jose Ruiz <ruiz@act-europe.fr> * gnat_ugn.texi: Add Detect_Blocking to the list of configuration pragmas recognized by GNAT. * gnat_rm.texi: Document pragma Detect_Blocking. * s-solita.adb (Timed_Delay_T): When pragma Detect_Blocking is active, raise Program_Error if called from a protected operation. * s-taprob.adb (Lock): When pragma Detect_Blocking is active increase the protected action nesting level. (Lock_Read_Only): When pragma Detect_Blocking is active increase the protected action nesting level. (Unlock): When pragma Detect_Blocking is active decrease the protected action nesting level. * s-taskin.adb (Initialize_ATCB): Initialize to 0 the Protected_Action_Nesting. * s-taskin.ads: Adding the field Protected_Action_Nesting to the Common_ATCB record. It contains the dynamic level of protected action nesting for each task. It is needed for checking whether potentially blocking operations are called from protected operations. (Detect_Blocking): Adding a Boolean constant reflecting whether pragma Detect_Blocking is active or not in the partition. * s-tasren.adb (Call_Simple): When pragma Detect_Blocking is active, raise Program_Error if called from a protected operation. (Task_Entry_Call): When pragma Detect_Blocking is active, raise Program_Error if called from a protected operation. (Timed_Task_Entry_Call): When pragma Detect_Blocking is active, raise Program_Error if called from a protected operation. * s-tassta.adb (Abort_Tasks): When pragma Detect_Blocking is active, raise Program_Error if called from a protected operation. * s-tpoben.adb (Lock_Entries): When pragma Detect_Blocking is active, raise Program_Error if called from a protected operation, and increase the protected action nesting level. (Lock_Read_Only_Entries): When pragma Detect_Blocking is active, raise Program_Error if called from a protected operation, and increase the protected action nesting level. (Unlock_Entries): When pragma Detect_Blocking is active decrease the protected action nesting level. * s-tposen.adb (Lock_Entry): When pragma Detect_Blocking is active, raise Program_Error if called from a protected operation, and increase the protected action nesting level. (Lock_Read_Only_Entry): When pragma Detect_Blocking is active, raise Program_Error if called from a protected operation, and increase the protected action nesting level. (Protected_Single_Entry_Call): When pragma Detect_Blocking is active, raise Program_Error if called from a protected operation. (Timed_Protected_Single_Entry_Call): When pragma Detect_Blocking is active, raise Program_Error if called from a protected operation. (Unlock_Entry): When pragma Detect_Blocking is active decrease the protected action nesting level. * sem_util.adb (Check_Potentially_Blocking_Operation): Remove the insertion of the statement raising Program_Error. The run time contains the required machinery for handling that. * sem_util.ads: Change comment associated to procedure Check_Potentially_Blocking_Operation. This procedure does not insert a call for raising the exception because that is currently done by the run time. * raise.h (__gnat_set_globals): Pass the detect_blocking parameter. * init.c: Add the global variable __gl_detect_blocking that indicates whether pragma Detect_Blocking is active (1) or not (0). Needed for making the pragma available at run time. (__gnat_set_globals): Pass and update the detect_blocking parameter. * lib-writ.adb (Write_ALI): Set the DB flag in the ali file if pragma Detect_Blocking is active. * lib-writ.ads: Document the Detect_Blocking flag (DB) in ali files. * ali.adb (Scan_ALI): Set the Detect_Blocking value to true if the flag DB is found in the ali file. Any unit compiled with pragma Detect_Blocking active forces its effect in the whole partition. * a-retide.adb (Delay_Until): Raise Program_Error if pragma Detect_Blocking is active and delay is called from a protected operation. * bindgen.adb (Gen_Adainit_Ada): When generating the call to __gnat_set_globals, pass 1 as Detect_Blocking parameter if pragma Detect_Blocking is active (0 otherwise). (Gen_Adainit_C): When generating the call to __gnat_set_globals, pass 1 as Detect_Blocking parameter if pragma Detect_Blocking is active (0 otherwise). 2004-09-09 Thomas Quinot <quinot@act-europe.fr> * gnat_rm.texi: Rename GNAT.Perfect_Hash.Generators to GNAT.Perfect_Hash_Generators, and remove the empty GNAT.Perfect_Hash package. * s-parint.ads, s-parint.adb (Get_RAS_Info): New subprogram. (Register_Receiving_Stub): Add Subp_Info formal parameter. Update API in placeholder implemetation of s-parint to reflect changes in distribution runtime library. * sem_ch3.adb (Expand_Derived_Record): Rename to Expand_Record_Extension. * sem_disp.adb (Check_Controlling_Formals): Improve error message for primitive operations of potentially distributed object types that have non-controlling anonymous access formals. * sem_dist.ads, sem_dist.adb (Build_RAS_Primitive_Specification): New subprogram. New implementation of expansion for remote access-to-subprogram types, based on the RACW infrastructure. This version of sem_dist is compatible with PolyORB/DSA as well as GLADE. * sem_prag.adb (Analyze_Pragma, case Pragma_Asynchronous): For a pragma Asynchrronous that applies to a remote access-to-subprogram type, mark the underlying RACW type as asynchronous. * link.c: FreeBSD uses GNU ld: set __gnat_objlist_file_supported and __gnat_using_gnu_linker to 1. * Makefile.rtl, impunit.adb, g-perhas.ads, g-pehage.ads, g-pehage.adb: Rename GNAT.Perfect_Hash.Generators to GNAT.Perfect_Hash_Generators, and remove the empty GNAT.Perfect_Hash package. * atree.adb: Minor reformatting * exp_ch3.adb (Expand_Derived_Record): Rename to Expand_Record_Extension. (Build_Record_Init_Proc.Build_Assignment): The default expression in a component declaration must remain attached at that point in the tree so New_Copy_Tree copies it if the enclosing record type is derived. It is therefore necessary to take a copy of the expression when building the corresponding assignment statement in the init proc. As a side effect, in the case of a derived record type, we now see the original expression, without any rewriting that could have occurred during expansion of the ancestor type's init proc, and we do not need to go back to Original_Node. * exp_ch3.ads (Expand_Derived_Record): Rename to Expand_Record_Extension. * exp_dist.ads, exp_dist.adb (Underlying_RACW_Type): New subprogram. Returns the RACW type used to implement a remote access-to-subprogram type. (Add_RAS_Proxy_And_Analyze, Build_Remote_Subprogram_Proxy_Type): New subprograms. Used to create a proxy tagged object for a remote subprogram. The proxy object is used as the designated object for RAS values on the same partition (unless All_Calls_Remote applies). (Build_Get_Unique_RP_Call): New subprogram. Build a call to System.Partition_Interface.Get_Unique_Remote_Pointer. (Add_RAS_Access_TSS, Add_RAS_Dereference_TSS): Renamed from Add_RAS_*_Attribute. (Add_Receiving_Stubs_To_Declarations): Generate a table of local subprograms. New implementation of expansion for remote access-to-subprogram types, based on the RACW infrastructure. * exp_dist.ads (Copy_Specification): Update comment to note that this function can copy the specification from either a subprogram specification or an access-to-subprogram type definition. 2004-09-09 Ed Schonberg <schonberg@gnat.com> * sem_type.adb (Disambiguate): Handle properly an accidental ambiguity in an instance, between an explicit subprogram an one inherited from a type derived from an actual. * exp_ch6.adb (Expand_N_Subprogram_Body): If polling is enabled, do not add a polling call if the subprogram is to be inlined by the back-end, to avoid repeated calls with multiple inlinings. * checks.adb (Apply_Alignment_Check): If the expression in the address clause is a call whose name is not a static entity (e.g. a dispatching call), treat as dynamic. 2004-09-09 Robert Dewar <dewar@gnat.com> * g-trasym.ads: Minor reformatting * exp_ch3.adb (Component_Needs_Simple_Initialization): Don't except packed arrays, since unused bits are expected to be zero for a comparison. 2004-09-09 Eric Botcazou <ebotcazou@act-europe.fr> * exp_pakd.ads: Fix an inacurracy and a couple of typos in the head comment. 2004-09-09 Pascal Obry <obry@gnat.com> * mdll.ads, mdll.adb (Build_Dynamic_Library): New parameter Map_File to enable map file generation. Add the right option to generate the map file if Map_File is set to True. * gnatdll.adb (Gen_Map_File): New variable. (Syntax): Add info about new -m (Map_File) option. (Parse_Command_Line): Add support for -m option. (gnatdll): Pass Gen_Map_File to Build_Dynamic_Library calls. Minor reformatting. 2004-09-09 Laurent Pautet <pautet@act-europe.fr> * gnatls.adb: Add a very verbose mode -V. Such mode is required by the new gnatdist implementation. Define a subpackage isolating the output routines specific to this verbose mode. 2004-09-09 Joel Brobecker <brobecker@gnat.com> * Makefile.rtl: (GNATRTL_NONTASKING_OBJS): Add g-dynhta. * gnat_ugn.texi (Main Subprograms): Fix typo. Deduced, not deducted. 2004-09-09 Cyrille Comar <comar@act-europe.fr> * opt.adb (Set_Opt_Config_Switches): Use Ada_Version_Runtime to compile internal unit. * opt.ads: Add Ada_Version_Runtime constant used to decide which version of the language is used to compile the run time. 2004-09-09 Arnaud Charlet <charlet@act-europe.fr> * sem_util.adb (Requires_Transient_Scope): Re-enable handling of variable length temporaries for function return now that the back-end and gigi support it. From-SVN: r87435
696 lines
21 KiB
Ada
696 lines
21 KiB
Ada
------------------------------------------------------------------------------
|
|
-- --
|
|
-- GNAT COMPILER COMPONENTS --
|
|
-- --
|
|
-- G N A T B I N D --
|
|
-- --
|
|
-- B o d y --
|
|
-- --
|
|
-- Copyright (C) 1992-2004 Free Software Foundation, Inc. --
|
|
-- --
|
|
-- GNAT is free software; you can redistribute it and/or modify it under --
|
|
-- terms of the GNU General Public License as published by the Free Soft- --
|
|
-- ware Foundation; either version 2, or (at your option) any later ver- --
|
|
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
|
|
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
|
|
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
|
|
-- for more details. You should have received a copy of the GNU General --
|
|
-- Public License distributed with GNAT; see file COPYING. If not, write --
|
|
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
|
|
-- MA 02111-1307, USA. --
|
|
-- --
|
|
-- GNAT was originally developed by the GNAT team at New York University. --
|
|
-- Extensive contributions were provided by Ada Core Technologies Inc. --
|
|
-- --
|
|
------------------------------------------------------------------------------
|
|
|
|
with ALI; use ALI;
|
|
with ALI.Util; use ALI.Util;
|
|
with Bcheck; use Bcheck;
|
|
with Binde; use Binde;
|
|
with Binderr; use Binderr;
|
|
with Bindgen; use Bindgen;
|
|
with Bindusg;
|
|
with Butil; use Butil;
|
|
with Casing; use Casing;
|
|
with Csets;
|
|
with Debug; use Debug;
|
|
with Fmap;
|
|
with Gnatvsn; use Gnatvsn;
|
|
with Namet; use Namet;
|
|
with Opt; use Opt;
|
|
with Osint; use Osint;
|
|
with Osint.B; use Osint.B;
|
|
with Output; use Output;
|
|
with Rident; use Rident;
|
|
with Snames;
|
|
with Switch; use Switch;
|
|
with Switch.B; use Switch.B;
|
|
with Targparm; use Targparm;
|
|
with Types; use Types;
|
|
|
|
with System.Case_Util; use System.Case_Util;
|
|
|
|
procedure Gnatbind is
|
|
|
|
Total_Errors : Nat := 0;
|
|
-- Counts total errors in all files
|
|
|
|
Total_Warnings : Nat := 0;
|
|
-- Total warnings in all files
|
|
|
|
Main_Lib_File : File_Name_Type;
|
|
-- Current main library file
|
|
|
|
Std_Lib_File : File_Name_Type;
|
|
-- Standard library
|
|
|
|
Text : Text_Buffer_Ptr;
|
|
Next_Arg : Positive;
|
|
|
|
Output_File_Name_Seen : Boolean := False;
|
|
Output_File_Name : String_Ptr := new String'("");
|
|
|
|
L_Switch_Seen : Boolean := False;
|
|
|
|
Mapping_File : String_Ptr := null;
|
|
|
|
procedure List_Applicable_Restrictions;
|
|
-- List restrictions that apply to this partition if option taken
|
|
|
|
procedure Scan_Bind_Arg (Argv : String);
|
|
-- Scan and process binder specific arguments. Argv is a single argument.
|
|
-- All the one character arguments are still handled by Switch. This
|
|
-- routine handles -aO -aI and -I-.
|
|
|
|
----------------------------------
|
|
-- List_Applicable_Restrictions --
|
|
----------------------------------
|
|
|
|
procedure List_Applicable_Restrictions is
|
|
|
|
-- Define those restrictions that should be output if the gnatbind
|
|
-- -r switch is used. Not all restrictions are output for the reasons
|
|
-- given above in the list, and this array is used to test whether
|
|
-- the corresponding pragma should be listed. True means that it
|
|
-- should not be listed.
|
|
|
|
No_Restriction_List : constant array (All_Restrictions) of Boolean :=
|
|
(No_Exceptions => True,
|
|
-- Has unexpected Suppress (All_Checks) effect
|
|
|
|
No_Implicit_Conditionals => True,
|
|
-- This could modify and pessimize generated code
|
|
|
|
No_Implicit_Dynamic_Code => True,
|
|
-- This could modify and pessimize generated code
|
|
|
|
No_Implicit_Loops => True,
|
|
-- This could modify and pessimize generated code
|
|
|
|
No_Recursion => True,
|
|
-- Not checkable at compile time
|
|
|
|
No_Reentrancy => True,
|
|
-- Not checkable at compile time
|
|
|
|
Max_Entry_Queue_Length => True,
|
|
-- Not checkable at compile time
|
|
|
|
Max_Storage_At_Blocking => True,
|
|
-- Not checkable at compile time
|
|
|
|
others => False);
|
|
|
|
Additional_Restrictions_Listed : Boolean := False;
|
|
-- Set True if we have listed header for restrictions
|
|
|
|
begin
|
|
-- Loop through restrictions
|
|
|
|
for R in All_Restrictions loop
|
|
if not No_Restriction_List (R) then
|
|
|
|
-- We list a restriction if it is not violated, or if
|
|
-- it is violated but the violation count is exactly known.
|
|
|
|
if Cumulative_Restrictions.Violated (R) = False
|
|
or else (R in All_Parameter_Restrictions
|
|
and then
|
|
Cumulative_Restrictions.Unknown (R) = False)
|
|
then
|
|
if not Additional_Restrictions_Listed then
|
|
Write_Eol;
|
|
Write_Line
|
|
("The following additional restrictions may be" &
|
|
" applied to this partition:");
|
|
Additional_Restrictions_Listed := True;
|
|
end if;
|
|
|
|
Write_Str ("pragma Restrictions (");
|
|
|
|
declare
|
|
S : constant String := Restriction_Id'Image (R);
|
|
begin
|
|
Name_Len := S'Length;
|
|
Name_Buffer (1 .. Name_Len) := S;
|
|
end;
|
|
|
|
Set_Casing (Mixed_Case);
|
|
Write_Str (Name_Buffer (1 .. Name_Len));
|
|
|
|
if R in All_Parameter_Restrictions then
|
|
Write_Str (" => ");
|
|
Write_Int (Int (Cumulative_Restrictions.Count (R)));
|
|
end if;
|
|
|
|
Write_Str (");");
|
|
Write_Eol;
|
|
end if;
|
|
end if;
|
|
end loop;
|
|
end List_Applicable_Restrictions;
|
|
|
|
-------------------
|
|
-- Scan_Bind_Arg --
|
|
-------------------
|
|
|
|
procedure Scan_Bind_Arg (Argv : String) is
|
|
begin
|
|
-- Now scan arguments that are specific to the binder and are not
|
|
-- handled by the common circuitry in Switch.
|
|
|
|
if Opt.Output_File_Name_Present
|
|
and then not Output_File_Name_Seen
|
|
then
|
|
Output_File_Name_Seen := True;
|
|
|
|
if Argv'Length = 0
|
|
or else (Argv'Length >= 1 and then Argv (1) = '-')
|
|
then
|
|
Fail ("output File_Name missing after -o");
|
|
|
|
else
|
|
Output_File_Name := new String'(Argv);
|
|
end if;
|
|
|
|
elsif Argv'Length >= 2 and then Argv (1) = '-' then
|
|
|
|
-- -I-
|
|
|
|
if Argv (2 .. Argv'Last) = "I-" then
|
|
Opt.Look_In_Primary_Dir := False;
|
|
|
|
-- -Idir
|
|
|
|
elsif Argv (2) = 'I' then
|
|
Add_Src_Search_Dir (Argv (3 .. Argv'Last));
|
|
Add_Lib_Search_Dir (Argv (3 .. Argv'Last));
|
|
|
|
-- -Ldir
|
|
|
|
elsif Argv (2) = 'L' then
|
|
if Argv'Length >= 3 then
|
|
|
|
-- Remember that the -L switch was specified, so that if this
|
|
-- is on OpenVMS, the export names are put in uppercase.
|
|
-- This is not known before the target parameters are read.
|
|
|
|
L_Switch_Seen := True;
|
|
|
|
Opt.Bind_For_Library := True;
|
|
Opt.Ada_Init_Name :=
|
|
new String'(Argv (3 .. Argv'Last) & Opt.Ada_Init_Suffix);
|
|
Opt.Ada_Final_Name :=
|
|
new String'(Argv (3 .. Argv'Last) & Opt.Ada_Final_Suffix);
|
|
Opt.Ada_Main_Name :=
|
|
new String'(Argv (3 .. Argv'Last) & Opt.Ada_Main_Name_Suffix);
|
|
|
|
-- This option (-Lxxx) implies -n
|
|
|
|
Opt.Bind_Main_Program := False;
|
|
|
|
else
|
|
Fail
|
|
("Prefix of initialization and finalization " &
|
|
"procedure names missing in -L");
|
|
end if;
|
|
|
|
-- -Sin -Slo -Shi -Sxx
|
|
|
|
elsif Argv'Length = 4
|
|
and then Argv (2) = 'S'
|
|
then
|
|
declare
|
|
C1 : Character := Argv (3);
|
|
C2 : Character := Argv (4);
|
|
|
|
begin
|
|
-- Fold to upper case
|
|
|
|
if C1 in 'a' .. 'z' then
|
|
C1 := Character'Val (Character'Pos (C1) - 32);
|
|
end if;
|
|
|
|
if C2 in 'a' .. 'z' then
|
|
C2 := Character'Val (Character'Pos (C2) - 32);
|
|
end if;
|
|
|
|
-- Test valid option and set mode accordingly
|
|
|
|
if C1 = 'E' and then C2 = 'V' then
|
|
null;
|
|
|
|
elsif C1 = 'I' and then C2 = 'N' then
|
|
null;
|
|
|
|
elsif C1 = 'L' and then C2 = 'O' then
|
|
null;
|
|
|
|
elsif C1 = 'H' and then C2 = 'I' then
|
|
null;
|
|
|
|
elsif (C1 in '0' .. '9' or else C1 in 'A' .. 'F')
|
|
and then
|
|
(C2 in '0' .. '9' or else C2 in 'A' .. 'F')
|
|
then
|
|
null;
|
|
|
|
-- Invalid -S switch, let Switch give error, set defalut of IN
|
|
|
|
else
|
|
Scan_Binder_Switches (Argv);
|
|
C1 := 'I';
|
|
C2 := 'N';
|
|
end if;
|
|
|
|
Initialize_Scalars_Mode1 := C1;
|
|
Initialize_Scalars_Mode2 := C2;
|
|
end;
|
|
|
|
-- -aIdir
|
|
|
|
elsif Argv'Length >= 3
|
|
and then Argv (2 .. 3) = "aI"
|
|
then
|
|
Add_Src_Search_Dir (Argv (4 .. Argv'Last));
|
|
|
|
-- -aOdir
|
|
|
|
elsif Argv'Length >= 3
|
|
and then Argv (2 .. 3) = "aO"
|
|
then
|
|
Add_Lib_Search_Dir (Argv (4 .. Argv'Last));
|
|
|
|
-- -nostdlib
|
|
|
|
elsif Argv (2 .. Argv'Last) = "nostdlib" then
|
|
Opt.No_Stdlib := True;
|
|
|
|
-- -nostdinc
|
|
|
|
elsif Argv (2 .. Argv'Last) = "nostdinc" then
|
|
Opt.No_Stdinc := True;
|
|
|
|
-- -static
|
|
|
|
elsif Argv (2 .. Argv'Last) = "static" then
|
|
Opt.Shared_Libgnat := False;
|
|
|
|
-- -shared
|
|
|
|
elsif Argv (2 .. Argv'Last) = "shared" then
|
|
Opt.Shared_Libgnat := True;
|
|
|
|
-- -F=mapping_file
|
|
|
|
elsif Argv'Length >= 4 and then Argv (2 .. 3) = "F=" then
|
|
if Mapping_File /= null then
|
|
Fail ("cannot specify several mapping files");
|
|
end if;
|
|
|
|
Mapping_File := new String'(Argv (4 .. Argv'Last));
|
|
|
|
-- -Mname
|
|
|
|
elsif Argv'Length >= 3 and then Argv (2) = 'M' then
|
|
Opt.Bind_Alternate_Main_Name := True;
|
|
Opt.Alternate_Main_Name := new String'(Argv (3 .. Argv'Last));
|
|
|
|
-- All other options are single character and are handled
|
|
-- by Scan_Binder_Switches.
|
|
|
|
else
|
|
Scan_Binder_Switches (Argv);
|
|
end if;
|
|
|
|
-- Not a switch, so must be a file name (if non-empty)
|
|
|
|
elsif Argv'Length /= 0 then
|
|
if Argv'Length > 4
|
|
and then Argv (Argv'Last - 3 .. Argv'Last) = ".ali"
|
|
then
|
|
Add_File (Argv);
|
|
else
|
|
Add_File (Argv & ".ali");
|
|
end if;
|
|
end if;
|
|
end Scan_Bind_Arg;
|
|
|
|
-- Start of processing for Gnatbind
|
|
|
|
begin
|
|
|
|
-- Set default for Shared_Libgnat option
|
|
|
|
declare
|
|
Shared_Libgnat_Default : Character;
|
|
pragma Import
|
|
(C, Shared_Libgnat_Default, "__gnat_shared_libgnat_default");
|
|
|
|
SHARED : constant Character := 'H';
|
|
STATIC : constant Character := 'T';
|
|
|
|
begin
|
|
pragma Assert
|
|
(Shared_Libgnat_Default = SHARED
|
|
or else
|
|
Shared_Libgnat_Default = STATIC);
|
|
Shared_Libgnat := (Shared_Libgnat_Default = SHARED);
|
|
end;
|
|
|
|
-- Use low level argument routines to avoid dragging in the secondary stack
|
|
|
|
Next_Arg := 1;
|
|
Scan_Args : while Next_Arg < Arg_Count loop
|
|
declare
|
|
Next_Argv : String (1 .. Len_Arg (Next_Arg));
|
|
|
|
begin
|
|
Fill_Arg (Next_Argv'Address, Next_Arg);
|
|
Scan_Bind_Arg (Next_Argv);
|
|
end;
|
|
Next_Arg := Next_Arg + 1;
|
|
end loop Scan_Args;
|
|
|
|
-- Test for trailing -o switch
|
|
|
|
if Opt.Output_File_Name_Present
|
|
and then not Output_File_Name_Seen
|
|
then
|
|
Fail ("output file name missing after -o");
|
|
end if;
|
|
|
|
-- Output usage if requested
|
|
|
|
if Usage_Requested then
|
|
Bindusg;
|
|
end if;
|
|
|
|
-- Check that the Ada binder file specified has extension .adb and that
|
|
-- the C binder file has extension .c
|
|
|
|
if Opt.Output_File_Name_Present
|
|
and then Output_File_Name_Seen
|
|
then
|
|
Check_Extensions : declare
|
|
Length : constant Natural := Output_File_Name'Length;
|
|
Last : constant Natural := Output_File_Name'Last;
|
|
|
|
begin
|
|
if Ada_Bind_File then
|
|
if Length <= 4
|
|
or else Output_File_Name (Last - 3 .. Last) /= ".adb"
|
|
then
|
|
Fail ("output file name should have .adb extension");
|
|
end if;
|
|
|
|
else
|
|
if Length <= 2
|
|
or else Output_File_Name (Last - 1 .. Last) /= ".c"
|
|
then
|
|
Fail ("output file name should have .c extension");
|
|
end if;
|
|
end if;
|
|
end Check_Extensions;
|
|
end if;
|
|
|
|
Osint.Add_Default_Search_Dirs;
|
|
|
|
-- Carry out package initializations. These are initializations which
|
|
-- might logically be performed at elaboration time, but Namet at
|
|
-- least can't be done that way (because it is used in the Compiler),
|
|
-- and we decide to be consistent. Like elaboration, the order in
|
|
-- which these calls are made is in some cases important.
|
|
|
|
Csets.Initialize;
|
|
Namet.Initialize;
|
|
Snames.Initialize;
|
|
|
|
-- Acquire target parameters
|
|
|
|
Targparm.Get_Target_Parameters;
|
|
|
|
-- Initialize Cumulative_Restrictions with the restrictions on the target
|
|
-- scanned from the system.ads file. Then as we read ALI files, we will
|
|
-- accumulate additional restrictions specified in other files.
|
|
|
|
Cumulative_Restrictions := Targparm.Restrictions_On_Target;
|
|
|
|
-- On OpenVMS, when -L is used, all external names used in pragmas Export
|
|
-- are in upper case. The reason is that on OpenVMS, the macro-assembler
|
|
-- MACASM-32, used to build Stand-Alone Libraries, only understands
|
|
-- uppercase.
|
|
|
|
if L_Switch_Seen and then OpenVMS_On_Target then
|
|
To_Upper (Opt.Ada_Init_Name.all);
|
|
To_Upper (Opt.Ada_Final_Name.all);
|
|
To_Upper (Opt.Ada_Main_Name.all);
|
|
end if;
|
|
|
|
-- Acquire configurable run-time mode
|
|
|
|
if Configurable_Run_Time_On_Target then
|
|
Configurable_Run_Time_Mode := True;
|
|
end if;
|
|
|
|
-- Output copyright notice if in verbose mode
|
|
|
|
if Verbose_Mode then
|
|
Write_Eol;
|
|
Write_Str ("GNATBIND ");
|
|
Write_Str (Gnat_Version_String);
|
|
Write_Str (" Copyright 1995-2004 Free Software Foundation, Inc.");
|
|
Write_Eol;
|
|
end if;
|
|
|
|
-- Output usage information if no files
|
|
|
|
if not More_Lib_Files then
|
|
Bindusg;
|
|
Exit_Program (E_Fatal);
|
|
end if;
|
|
|
|
-- If a mapping file was specified, initialize the file mapping
|
|
|
|
if Mapping_File /= null then
|
|
Fmap.Initialize (Mapping_File.all);
|
|
end if;
|
|
|
|
-- The block here is to catch the Unrecoverable_Error exception in the
|
|
-- case where we exceed the maximum number of permissible errors or some
|
|
-- other unrecoverable error occurs.
|
|
|
|
begin
|
|
-- Initialize binder packages
|
|
|
|
Initialize_Binderr;
|
|
Initialize_ALI;
|
|
Initialize_ALI_Source;
|
|
|
|
if Verbose_Mode then
|
|
Write_Eol;
|
|
end if;
|
|
|
|
-- Input ALI files
|
|
|
|
while More_Lib_Files loop
|
|
Main_Lib_File := Next_Main_Lib_File;
|
|
|
|
if Verbose_Mode then
|
|
if Check_Only then
|
|
Write_Str ("Checking: ");
|
|
else
|
|
Write_Str ("Binding: ");
|
|
end if;
|
|
|
|
Write_Name (Main_Lib_File);
|
|
Write_Eol;
|
|
end if;
|
|
|
|
Text := Read_Library_Info (Main_Lib_File, True);
|
|
|
|
declare
|
|
Id : ALI_Id;
|
|
pragma Warnings (Off, Id);
|
|
|
|
begin
|
|
Id := Scan_ALI
|
|
(F => Main_Lib_File,
|
|
T => Text,
|
|
Ignore_ED => Force_RM_Elaboration_Order,
|
|
Err => False,
|
|
Ignore_Errors => Debug_Flag_I);
|
|
end;
|
|
|
|
Free (Text);
|
|
end loop;
|
|
|
|
-- No_Run_Time mode
|
|
|
|
if No_Run_Time_Mode then
|
|
|
|
-- Set standard configuration parameters
|
|
|
|
Suppress_Standard_Library_On_Target := True;
|
|
Configurable_Run_Time_Mode := True;
|
|
end if;
|
|
|
|
-- For main ALI files, even if they are interfaces, we get their
|
|
-- dependencies. To be sure, we reset the Interface flag for all main
|
|
-- ALI files.
|
|
|
|
for Index in ALIs.First .. ALIs.Last loop
|
|
ALIs.Table (Index).Interface := False;
|
|
end loop;
|
|
|
|
-- Add System.Standard_Library to list to ensure that these files are
|
|
-- included in the bind, even if not directly referenced from Ada code
|
|
-- This is suppressed if the appropriate targparm switch is set.
|
|
|
|
if not Suppress_Standard_Library_On_Target then
|
|
Name_Buffer (1 .. 12) := "s-stalib.ali";
|
|
Name_Len := 12;
|
|
Std_Lib_File := Name_Find;
|
|
Text := Read_Library_Info (Std_Lib_File, True);
|
|
|
|
declare
|
|
Id : ALI_Id;
|
|
pragma Warnings (Off, Id);
|
|
|
|
begin
|
|
Id :=
|
|
Scan_ALI
|
|
(F => Std_Lib_File,
|
|
T => Text,
|
|
Ignore_ED => Force_RM_Elaboration_Order,
|
|
Err => False,
|
|
Ignore_Errors => Debug_Flag_I);
|
|
end;
|
|
|
|
Free (Text);
|
|
end if;
|
|
|
|
-- Acquire all information in ALI files that have been read in
|
|
|
|
for Index in ALIs.First .. ALIs.Last loop
|
|
Read_ALI (Index);
|
|
end loop;
|
|
|
|
-- Warn if -f switch used
|
|
|
|
if Force_RM_Elaboration_Order then
|
|
Error_Msg
|
|
("?-f is obsolescent and should not be used");
|
|
Error_Msg
|
|
("?may result in missing run-time elaboration checks");
|
|
Error_Msg
|
|
("?use -gnatE, pragma Suppress (Elaboration_Check) instead");
|
|
end if;
|
|
|
|
-- Quit if some file needs compiling
|
|
|
|
if No_Object_Specified then
|
|
raise Unrecoverable_Error;
|
|
end if;
|
|
|
|
-- Build source file table from the ALI files we have read in
|
|
|
|
Set_Source_Table;
|
|
|
|
-- Check that main library file is a suitable main program
|
|
|
|
if Bind_Main_Program
|
|
and then ALIs.Table (ALIs.First).Main_Program = None
|
|
and then not No_Main_Subprogram
|
|
then
|
|
Error_Msg_Name_1 := Main_Lib_File;
|
|
Error_Msg ("% does not contain a unit that can be a main program");
|
|
end if;
|
|
|
|
-- Perform consistency and correctness checks
|
|
|
|
Check_Duplicated_Subunits;
|
|
Check_Versions;
|
|
Check_Consistency;
|
|
Check_Configuration_Consistency;
|
|
|
|
-- List restrictions that could be applied to this partition
|
|
|
|
if List_Restrictions then
|
|
List_Applicable_Restrictions;
|
|
end if;
|
|
|
|
-- Complete bind if no errors
|
|
|
|
if Errors_Detected = 0 then
|
|
Find_Elab_Order;
|
|
|
|
if Errors_Detected = 0 then
|
|
if Elab_Order_Output then
|
|
Write_Eol;
|
|
Write_Str ("ELABORATION ORDER");
|
|
Write_Eol;
|
|
|
|
for J in Elab_Order.First .. Elab_Order.Last loop
|
|
if not Units.Table (Elab_Order.Table (J)).Interface then
|
|
Write_Str (" ");
|
|
Write_Unit_Name
|
|
(Units.Table (Elab_Order.Table (J)).Uname);
|
|
Write_Eol;
|
|
end if;
|
|
end loop;
|
|
|
|
Write_Eol;
|
|
end if;
|
|
|
|
if not Check_Only then
|
|
Gen_Output_File (Output_File_Name.all);
|
|
end if;
|
|
end if;
|
|
end if;
|
|
|
|
Total_Errors := Total_Errors + Errors_Detected;
|
|
Total_Warnings := Total_Warnings + Warnings_Detected;
|
|
|
|
exception
|
|
when Unrecoverable_Error =>
|
|
Total_Errors := Total_Errors + Errors_Detected;
|
|
Total_Warnings := Total_Warnings + Warnings_Detected;
|
|
end;
|
|
|
|
-- All done. Set proper exit status.
|
|
|
|
Finalize_Binderr;
|
|
Namet.Finalize;
|
|
|
|
if Total_Errors > 0 then
|
|
Exit_Program (E_Errors);
|
|
elsif Total_Warnings > 0 then
|
|
Exit_Program (E_Warnings);
|
|
else
|
|
Exit_Program (E_Success);
|
|
end if;
|
|
|
|
end Gnatbind;
|