Commit 16cc65b6 by Hristian Kirtchev Committed by Pierre-Marie de Rodat

[Ada] Elaboration order v4.0 activation

This patch enables the elaboration order v4.0 as the default elaboration
order in GNATbind. The previous v3.0 elaboration order is now referred
to as the "legacy elaboration order mechanism" and is available using
binder switch -H.

2019-07-09  Hristian Kirtchev  <kirtchev@adacore.com>

gcc/ada/

	* bindo.adb: Remove with and use clauses for Debug.  Add with
	and use clauses for Opt.
	(Find_Elaboration_Order): Enable the v4.0 elaboration order. The
	v3.0 mechanism is now available under binder switch -H.
	* bindusg.adb (Display): Enable switch -H.
	* debug.adb: Free compiler switch -gnatd_G.  Free binder switch
	-d_N.
	* sem_elab.adb: Update the section on switches to remove
	-gnatd_G.
	(Invocation_Graph_Recording_OK): The invocation graph is now
	unconditionally recorded in ALI files.
	* switch-b.adb (Scan_Binder_Switches): Scan switch -H.
	* doc/gnat_ugn/building_executable_programs_with_gnat.rst:
	Update the documentation on compiler switches related to
	elaboration.  Update the documentation on binder switches to
	include switch -H.
	* doc/gnat_ugn/elaboration_order_handling_in_gnat.rst: Update
	the documentation on elaboration order handling in GNAT.
	* gnat_ugn.texi: Regenerate.

From-SVN: r273280
parent fb95bfcc
2019-07-09 Hristian Kirtchev <kirtchev@adacore.com>
* bindo.adb: Remove with and use clauses for Debug. Add with
and use clauses for Opt.
(Find_Elaboration_Order): Enable the v4.0 elaboration order. The
v3.0 mechanism is now available under binder switch -H.
* bindusg.adb (Display): Enable switch -H.
* debug.adb: Free compiler switch -gnatd_G. Free binder switch
-d_N.
* sem_elab.adb: Update the section on switches to remove
-gnatd_G.
(Invocation_Graph_Recording_OK): The invocation graph is now
unconditionally recorded in ALI files.
* switch-b.adb (Scan_Binder_Switches): Scan switch -H.
* doc/gnat_ugn/building_executable_programs_with_gnat.rst:
Update the documentation on compiler switches related to
elaboration. Update the documentation on binder switches to
include switch -H.
* doc/gnat_ugn/elaboration_order_handling_in_gnat.rst: Update
the documentation on elaboration order handling in GNAT.
* gnat_ugn.texi: Regenerate.
2019-07-09 Eric Botcazou <ebotcazou@adacore.com>
* repinfo.adb (List_Entities): Disregard formals altogether.
......
......@@ -24,7 +24,7 @@
------------------------------------------------------------------------------
with Binde;
with Debug; use Debug;
with Opt; use Opt;
with Bindo.Elaborators;
use Bindo.Elaborators;
......@@ -426,9 +426,7 @@ package body Bindo is
-- Units and routines of interest:
-- Bindo.Elaborators
-- Elaborate_Library_Graph
-- Elaborate_Units_Common
-- Elaborate_Units_Dynamic
-- Elaborate_Units_Static
-- Elaborate_Units
--
-- * Invalid invocation graph
--
......@@ -490,40 +488,19 @@ package body Bindo is
Main_Lib_File : File_Name_Type)
is
begin
-- ??? Enable the following code when switching from the old to the new
-- elaboration-order mechanism.
-- Use the library graph and heuristic-based elaboration order when
-- switch -H (legacy elaboration-order mode enabled).
-- if Legacy_Elaboration_Order then
-- Binde.Find_Elab_Order (Order, Main_Lib_File);
if Legacy_Elaboration_Order then
Binde.Find_Elab_Order (Order, Main_Lib_File);
-- Otherwise use the invocation and library-graph-based elaboration
-- order.
-- else
-- Invocation_And_Library_Graph_Elaborators.Elaborate_Units
-- (Order => Order,
-- Main_Lib_File => Main_Lib_File);
-- end if;
-- ??? Remove the following code when switching from the old to the new
-- elaboration-order mechanism.
-- Use the invocation and library-graph-based elaboration order when
-- switch -d_N (new bindo order) is in effect.
if Debug_Flag_Underscore_NN then
else
Invocation_And_Library_Graph_Elaborators.Elaborate_Units
(Order => Order,
Main_Lib_File => Main_Lib_File);
-- Otherwise use the library-graph and heuristic-based elaboration
-- order.
else
Binde.Find_Elab_Order (Order, Main_Lib_File);
end if;
end Find_Elaboration_Order;
......
......@@ -143,13 +143,10 @@ package body Bindusg is
Write_Line
(" -h Output this usage (help) information");
-- ??? Enable the following code when switching from the old to the new
-- elaboration-order mechanism.
-- Line for -H switch
-- Write_Line
-- (" -H Legacy elaboration-order model enabled");
Write_Line
(" -H Legacy elaboration order model enabled");
-- Lines for -I switch
......
......@@ -178,7 +178,7 @@ package body Debug is
-- d_D
-- d_E
-- d_F Encode full invocation paths in ALI files
-- d_G Encode invocation graph in ALI files
-- d_G
-- d_H
-- d_I
-- d_J
......@@ -388,7 +388,7 @@ package body Debug is
-- d_K
-- d_L Output library graph
-- d_M
-- d_N New bindo order
-- d_N
-- d_O
-- d_P Output cycle paths
-- d_Q
......@@ -1001,9 +1001,6 @@ package body Debug is
-- an external target, offering additional information to GNATBIND for
-- purposes of error diagnostics.
-- d_G The compiler encodes the invocation graph of a unit in its ALI
-- file.
-- d_L Output trace information on elaboration checking. This debug switch
-- causes output to be generated showing each call or instantiation as
-- it is checked, and the progress of the recursive trace through
......@@ -1164,8 +1161,6 @@ package body Debug is
-- d_L GNATBIND outputs the contents of the library graph in textual
-- format to standard output.
-- d_N GNATBIND utilizes the elaboration order provided by bindo
-- d_P GNATBIND outputs the cycle paths to standard output
-- d_T GNATBIND outputs trace information of elaboration order and cycle
......
......@@ -1836,7 +1836,8 @@ Alphabetical List of All Switches
.. index:: -gnatE (gcc)
:switch:`-gnatE`
Full dynamic elaboration checks.
Dynamic elaboration checking mode enabled. For further details see
:ref:`Elaboration_Order_Handling_in_GNAT`.
.. index:: -gnatf (gcc)
......@@ -1878,8 +1879,9 @@ Alphabetical List of All Switches
.. index:: -gnatH (gcc)
:switch:`-gnatH`
Legacy elaboration-checking mode enabled. When this switch is in effect, the
pre-18.x access-before-elaboration model becomes the de facto model.
Legacy elaboration-checking mode enabled. When this switch is in effect,
the pre-18.x access-before-elaboration model becomes the de facto model.
For further details see :ref:`Elaboration_Order_Handling_in_GNAT`.
.. index:: -gnati (gcc)
......@@ -1935,7 +1937,8 @@ Alphabetical List of All Switches
- Select statements
- Synchronous task suspension
and does not emit compile-time diagnostics or run-time checks.
and does not emit compile-time diagnostics or run-time checks. For further
details see :ref:`Elaboration_Order_Handling_in_GNAT`.
.. index:: -gnatk (gcc)
......@@ -6368,7 +6371,9 @@ be presented in subsequent sections.
.. index:: -f (gnatbind)
:switch:`-f{elab-order}`
Force elaboration order.
Force elaboration order. For further details see :ref:`Elaboration_Control`
and :ref:`Elaboration_Order_Handling_in_GNAT`.
.. index:: -F (gnatbind)
......@@ -6388,15 +6393,22 @@ be presented in subsequent sections.
Output usage (help) information.
.. index:: -H32 (gnatbind)
.. index:: -H (gnatbind)
:switch:`-H`
Legacy elaboration order model enabled. For further details see
:ref:`Elaboration_Order_Handling_in_GNAT`.
.. index:: -H32 (gnatbind)
:switch:`-H32`
Use 32-bit allocations for ``__gnat_malloc`` (and thus for access types).
For further details see :ref:`Dynamic_Allocation_Control`.
.. index:: -H64 (gnatbind)
.. index:: __gnat_malloc
.. index:: -H64 (gnatbind)
.. index:: __gnat_malloc
:switch:`-H64`
Use 64-bit allocations for ``__gnat_malloc`` (and thus for access types).
......@@ -6816,7 +6828,7 @@ Elaboration Control
^^^^^^^^^^^^^^^^^^^
The following switches provide additional control over the elaboration
order. For full details see :ref:`Elaboration_Order_Handling_in_GNAT`.
order. For further details see :ref:`Elaboration_Order_Handling_in_GNAT`.
.. index:: -f (gnatbind)
......@@ -6860,28 +6872,32 @@ order. For full details see :ref:`Elaboration_Order_Handling_in_GNAT`.
ignored.
.. index:: -p (gnatbind)
.. index:: -p (gnatbind)
:switch:`-p`
Normally the binder attempts to choose an elaboration order that is
likely to minimize the likelihood of an elaboration order error resulting
in raising a ``Program_Error`` exception. This switch reverses the
action of the binder, and requests that it deliberately choose an order
that is likely to maximize the likelihood of an elaboration error.
This is useful in ensuring portability and avoiding dependence on
accidental fortuitous elaboration ordering.
Normally it only makes sense to use the :switch:`-p`
switch if dynamic
Pessimistic elaboration order
This switch is only applicable to the pre-20.x legacy elaboration models.
The post-20.x elaboration model uses a more informed approach of ordering
the units.
Normally the binder attempts to choose an elaboration order that is likely to
minimize the likelihood of an elaboration order error resulting in raising a
``Program_Error`` exception. This switch reverses the action of the binder,
and requests that it deliberately choose an order that is likely to maximize
the likelihood of an elaboration error. This is useful in ensuring
portability and avoiding dependence on accidental fortuitous elaboration
ordering.
Normally it only makes sense to use the :switch:`-p` switch if dynamic
elaboration checking is used (:switch:`-gnatE` switch used for compilation).
This is because in the default static elaboration mode, all necessary
``Elaborate`` and ``Elaborate_All`` pragmas are implicitly inserted.
These implicit pragmas are still respected by the binder in
:switch:`-p` mode, so a
safe elaboration order is assured.
These implicit pragmas are still respected by the binder in :switch:`-p`
mode, so a safe elaboration order is assured.
Note that :switch:`-p` is not intended for
production use; it is more for debugging/experimental use.
Note that :switch:`-p` is not intended for production use; it is more for
debugging/experimental use.
.. _Output_Control:
......
......@@ -496,12 +496,6 @@ package body Sem_Elab is
-- actual subprograms through generic formal subprograms. As a
-- result, the calls are not recorded or processed.
--
-- -gnatd_G encode invocation graph in ALI files
--
-- The ABE mechanism encodes the invocation graph of the main
-- unit. This includes elaboration code, as well as invocation
-- constructs.
--
-- -gnatd_i ignore activations and calls to instances for elaboration
--
-- The ABE mechanism ignores calls and task activations when they
......@@ -12192,19 +12186,10 @@ package body Sem_Elab is
Main_Cunit : constant Node_Id := Cunit (Main_Unit);
begin
-- ??? Remove the following use of the debug flag when switching from
-- the old to the new elaboration-order mechanism.
-- Nothing to do when switch -gnatd_G (encode invocation graph in ALI
-- files) is not in effect.
if not Debug_Flag_Underscore_GG then
return False;
-- Nothing to do when compiling for GNATprove because the invocation
-- graph is not needed.
elsif GNATprove_Mode then
if GNATprove_Mode then
return False;
-- Nothing to do when the compilation will not produce an ALI file
......
......@@ -353,14 +353,11 @@ package body Switch.B is
Ptr := Ptr + 1;
Usage_Requested := True;
-- ??? Enable the following code when switching from the old to the
-- new elaboration-order mechanism.
-- Processing for H switch
-- when 'H' =>
-- Ptr := Ptr + 1;
-- Legacy_Elaboration_Order := True;
when 'H' =>
Ptr := Ptr + 1;
Legacy_Elaboration_Order := True;
-- Processing for i switch
......
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