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