Commit 9410151a by Thomas Quinot Committed by Arnaud Charlet

binde.adb (Elab_All_Links): Remove unnecessary call to Generic_Separately_Compiled (if...

2007-08-14  Thomas Quinot  <quinot@adacore.com>
	    Vincent Celier  <celier@adacore.com>

	* binde.adb (Elab_All_Links): Remove unnecessary call to
	Generic_Separately_Compiled (if a unit satisfies this predicate, there
	won't be an associated Afile).
	(Elab_All_Links): Fail if a referenced unit cannot be found

	* bindgen.adb: 
	Fix comments in bindgen regarding consistency checks done in Bcheck:
	the checks are made across units within a partition, not across several
	partitions.
	Fix generation of C binder file for VxWorks.

	* lib.adb (Generic_Separately_Compiled): Rename to
	Generic_May_Lack_ALI, more descriptive of the current use of the
	predicate, and update documentation.

	* lib-writ.ads, lib-writ.adb (Write_With_Lines): Minor code
	reorganization and documentation update for the case of predefined
	library generics (for which we do not reference an Afile).

From-SVN: r127439
parent 5e1527bd
...@@ -28,12 +28,14 @@ with Binderr; use Binderr; ...@@ -28,12 +28,14 @@ with Binderr; use Binderr;
with Butil; use Butil; with Butil; use Butil;
with Debug; use Debug; with Debug; use Debug;
with Fname; use Fname; with Fname; use Fname;
with Lib; use Lib;
with Namet; use Namet; with Namet; use Namet;
with Opt; use Opt; with Opt; use Opt;
with Osint;
with Output; use Output; with Output; use Output;
with Targparm; use Targparm; with Targparm; use Targparm;
with System.Case_Util; use System.Case_Util;
package body Binde is package body Binde is
-- The following data structures are used to represent the graph that is -- The following data structures are used to represent the graph that is
...@@ -864,18 +866,69 @@ package body Binde is ...@@ -864,18 +866,69 @@ package body Binde is
Units.Table (Before).First_With .. Units.Table (Before).Last_With Units.Table (Before).First_With .. Units.Table (Before).Last_With
loop loop
-- Skip if this with is an interface to a stand-alone library. -- Skip if this with is an interface to a stand-alone library.
-- Skip also if no ALI file for this with, happens with certain -- Skip also if no ALI file for this WITH, happens for language
-- specialized generic files that do not get compiled. -- defined generics while bootstrapping the compiler (see body of
-- Lib.Writ.Write_With_Lines).
if not Withs.Table (W).SAL_Interface if not Withs.Table (W).SAL_Interface
and then Withs.Table (W).Afile /= No_File and then Withs.Table (W).Afile /= No_File
and then Generic_Separately_Compiled (Withs.Table (W).Sfile)
then then
declare
Info : constant Int :=
Get_Name_Table_Info
(Withs.Table (W).Uname);
begin
-- If the unit is unknown, for some unknown reason, fail
-- graciously explaining that the unit is unknown. Without
-- this check, gnatbind will crash in Unit_Id_Of.
if Info = 0 or else Unit_Id (Info) = No_Unit_Id then
declare
Withed : String :=
Get_Name_String (Withs.Table (W).Uname);
Last_Withed : Natural := Withed'Last;
Withing : String :=
Get_Name_String
(Units.Table (Before).Uname);
Last_Withing : Natural := Withing'Last;
Spec_Body : String := " (Spec)";
begin
To_Mixed (Withed);
To_Mixed (Withing);
if Last_Withed > 2 and then
Withed (Last_Withed - 1) = '%'
then
Last_Withed := Last_Withed - 2;
end if;
if Last_Withing > 2 and then
Withing (Last_Withing - 1) = '%'
then
Last_Withing := Last_Withing - 2;
end if;
if Units.Table (Before).Utype = Is_Body or else
Units.Table (Before).Utype = Is_Body_Only
then
Spec_Body := " (Body)";
end if;
Osint.Fail
("could not find unit ",
Withed (Withed'First .. Last_Withed) & " needed by " &
Withing (Withing'First .. Last_Withing) & Spec_Body);
end;
end if;
Elab_All_Links Elab_All_Links
(Unit_Id_Of (Withs.Table (W).Uname), (Unit_Id_Of (Withs.Table (W).Uname),
After, After,
Reason, Reason,
Make_Elab_Entry (Withs.Table (W).Uname, Link)); Make_Elab_Entry (Withs.Table (W).Uname, Link));
end;
end if; end if;
end loop; end loop;
......
...@@ -77,7 +77,7 @@ package body Bindgen is ...@@ -77,7 +77,7 @@ package body Bindgen is
-- This table assembles the interface state pragma information from -- This table assembles the interface state pragma information from
-- all the units in the partition. Note that Bcheck has already checked -- all the units in the partition. Note that Bcheck has already checked
-- that the information is consistent across partitions. The entries -- that the information is consistent across units. The entries
-- in this table are n/u/r/s for not set/user/runtime/system. -- in this table are n/u/r/s for not set/user/runtime/system.
package IS_Pragma_Settings is new Table.Table ( package IS_Pragma_Settings is new Table.Table (
...@@ -90,7 +90,7 @@ package body Bindgen is ...@@ -90,7 +90,7 @@ package body Bindgen is
-- This table assembles the Priority_Specific_Dispatching pragma -- This table assembles the Priority_Specific_Dispatching pragma
-- information from all the units in the partition. Note that Bcheck has -- information from all the units in the partition. Note that Bcheck has
-- already checked that the information is consistent across partitions. -- already checked that the information is consistent across units.
-- The entries in this table are the upper case first character of the -- The entries in this table are the upper case first character of the
-- policy name, e.g. 'F' for FIFO_Within_Priorities. -- policy name, e.g. 'F' for FIFO_Within_Priorities.
...@@ -1590,7 +1590,6 @@ package body Bindgen is ...@@ -1590,7 +1590,6 @@ package body Bindgen is
-- if no command line arguments on target, set dummy values -- if no command line arguments on target, set dummy values
else else
WBI (" int result;");
WBI (" gnat_argc = 0;"); WBI (" gnat_argc = 0;");
WBI (" gnat_argv = 0;"); WBI (" gnat_argv = 0;");
WBI (" gnat_envp = 0;"); WBI (" gnat_envp = 0;");
......
...@@ -376,11 +376,8 @@ package body Lib.Writ is ...@@ -376,11 +376,8 @@ package body Lib.Writ is
Write_Info_Str (" DE"); Write_Info_Str (" DE");
end if; end if;
-- We set the Elaborate_Body indication if either an explicit pragma -- Set the Elaborate_Body indication if either an explicit pragma
-- was present, or if this is an instantiation. RM 12.3(20) requires -- was present, or if this is an instantiation.
-- that the body be immediately elaborated after the spec. We would
-- normally do that anyway, but the EB we generate here ensures that
-- this gets done even when we use the -p gnatbind switch.
if Has_Pragma_Elaborate_Body (Uent) if Has_Pragma_Elaborate_Body (Uent)
or else (Ukind = N_Package_Declaration or else (Ukind = N_Package_Declaration
...@@ -391,8 +388,8 @@ package body Lib.Writ is ...@@ -391,8 +388,8 @@ package body Lib.Writ is
end if; end if;
-- Now see if we should tell the binder that an elaboration entity -- Now see if we should tell the binder that an elaboration entity
-- is present, which must be reset to true during elaboration. We -- is present, which must be set to true during elaboration.
-- generate the indication if the following condition is met: -- We generate the indication if the following condition is met:
-- If this is a spec ... -- If this is a spec ...
...@@ -630,7 +627,6 @@ package body Lib.Writ is ...@@ -630,7 +627,6 @@ package body Lib.Writ is
Num_Withs : Int := 0; Num_Withs : Int := 0;
Unum : Unit_Number_Type; Unum : Unit_Number_Type;
Cunit : Node_Id; Cunit : Node_Id;
Cunite : Entity_Id;
Uname : Unit_Name_Type; Uname : Unit_Name_Type;
Fname : File_Name_Type; Fname : File_Name_Type;
Pname : constant Unit_Name_Type := Pname : constant Unit_Name_Type :=
...@@ -696,7 +692,6 @@ package body Lib.Writ is ...@@ -696,7 +692,6 @@ package body Lib.Writ is
for J in 1 .. Num_Withs loop for J in 1 .. Num_Withs loop
Unum := With_Table (J); Unum := With_Table (J);
Cunit := Units.Table (Unum).Cunit; Cunit := Units.Table (Unum).Cunit;
Cunite := Units.Table (Unum).Cunit_Entity;
Uname := Units.Table (Unum).Unit_Name; Uname := Units.Table (Unum).Unit_Name;
Fname := Units.Table (Unum).Unit_File_Name; Fname := Units.Table (Unum).Unit_File_Name;
...@@ -706,12 +701,19 @@ package body Lib.Writ is ...@@ -706,12 +701,19 @@ package body Lib.Writ is
-- Now we need to figure out the names of the files that contain -- Now we need to figure out the names of the files that contain
-- the with'ed unit. These will usually be the files for the body, -- the with'ed unit. These will usually be the files for the body,
-- except in the case of a package that has no body. -- except in the case of a package that has no body. Note that we
-- have a specific exemption here for predefined library generics
if (Nkind (Unit (Cunit)) not in N_Generic_Declaration -- (see comments for Generic_May_Lack_ALI). We do not generate
and then -- dependency upon the ALI file for such units. Older compilers
Nkind (Unit (Cunit)) not in N_Generic_Renaming_Declaration) -- used to not support generating code (and ALI) for generics, and
or else Generic_Separately_Compiled (Cunite) -- we want to avoid having different processing (namely, different
-- lists of files to be compiled) for different stages of the
-- bootstrap.
if not ((Nkind (Unit (Cunit)) in N_Generic_Declaration
or else
Nkind (Unit (Cunit)) in N_Generic_Renaming_Declaration)
and then Generic_May_Lack_ALI (Fname))
then then
Write_Info_Tab (25); Write_Info_Tab (25);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1992-2006, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2007, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -435,7 +435,13 @@ package Lib.Writ is ...@@ -435,7 +435,13 @@ package Lib.Writ is
-- dynamic elaboration model, as set by either the -gnatE -- dynamic elaboration model, as set by either the -gnatE
-- switch or pragma Elaboration_Checks (Dynamic). -- switch or pragma Elaboration_Checks (Dynamic).
-- --
-- EB Unit has pragma Elaborate_Body -- EB Unit has pragma Elaborate_Body, or is a generic instance
-- that has a body. Set for instances because RM 12.3(20)
-- requires that the body be immediately elaborated after the
-- spec (we would normally do that anyway, because elaborate
-- spec and body together whenever possible, and for an instance
-- it is always possible; however setting EB ensures that this
-- is done even when using the -p gnatbind switch).
-- --
-- EE Elaboration entity is present which must be set true when -- EE Elaboration entity is present which must be set true when
-- the unit is elaborated. The name of the elaboration entity -- the unit is elaborated. The name of the elaboration entity
......
...@@ -447,49 +447,23 @@ package body Lib is ...@@ -447,49 +447,23 @@ package body Lib is
return False; return False;
end Entity_Is_In_Main_Unit; end Entity_Is_In_Main_Unit;
--------------------------------- --------------------------
-- Generic_Separately_Compiled -- -- Generic_May_Lack_ALI --
--------------------------------- --------------------------
function Generic_Separately_Compiled (E : Entity_Id) return Boolean is function Generic_May_Lack_ALI (Sfile : File_Name_Type) return Boolean is
begin begin
-- We do not generate object files for internal generics, because -- We allow internal generic units to be used without having a
-- the only thing they would contain is the elaboration boolean, and -- corresponding ALI files to help bootstrapping with older compilers
-- we are careful to elaborate all predefined units first anyway, so -- that did not support generating ALIs for such generics. It is safe
-- this boolean is not needed. -- to do so because the only thing the generated code would contain
-- is the elaboration boolean, and we are careful to elaborate all
-- predefined units first anyway.
if Is_Internal_File_Name return Is_Internal_File_Name
(Fname => Unit_File_Name (Get_Source_Unit (E)),
Renamings_Included => True)
then
return False;
-- All other generic units do generate object files
else
return True;
end if;
end Generic_Separately_Compiled;
function Generic_Separately_Compiled
(Sfile : File_Name_Type) return Boolean
is
begin
-- Exactly the same as previous function, but works directly on a file
-- name.
if Is_Internal_File_Name
(Fname => Sfile, (Fname => Sfile,
Renamings_Included => True) Renamings_Included => True);
then end Generic_May_Lack_ALI;
return False;
-- All other generic units do generate object files
else
return True;
end if;
end Generic_Separately_Compiled;
----------------------------- -----------------------------
-- Get_Code_Or_Source_Unit -- -- Get_Code_Or_Source_Unit --
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment