From 72c5ce77a028e57048c8666a7b782e3b921ee28c Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Mon, 18 Jul 2022 07:43:54 +0000 Subject: [Ada] New gnatbind switch -k This switch can be used to disable the effect of -F when using -n explicitly or implicitly. gcc/ada/ * bindgen.adb (Gen_Elab_Calls): Check for Check_Elaboration_Flags. * bindusg.adb (Display): Add -k. * opt.ads (Check_Elaboration_Flags): New. * switch-b.adb (Scan_Binder_Switches): Add processing of -k. * doc/gnat_ugn/building_executable_programs_with_gnat.rst: Add documentation for -k and -K. * gnat_ugn.texi: Regenerate. --- gcc/ada/bindgen.adb | 1 + gcc/ada/bindusg.adb | 5 +++++ .../building_executable_programs_with_gnat.rst | 16 ++++++++++++++++ gcc/ada/gnat_ugn.texi | 18 +++++++++++++++++- gcc/ada/opt.ads | 4 ++++ gcc/ada/switch-b.adb | 6 ++++++ 6 files changed, 49 insertions(+), 1 deletion(-) diff --git a/gcc/ada/bindgen.adb b/gcc/ada/bindgen.adb index c70268d..d5877c6 100644 --- a/gcc/ada/bindgen.adb +++ b/gcc/ada/bindgen.adb @@ -1544,6 +1544,7 @@ package body Bindgen is Check_Elab_Flag := Units.Table (Unum_Spec).Set_Elab_Entity + and then Check_Elaboration_Flags and then not CodePeer_Mode and then (Force_Checking_Of_Elaboration_Flags or Interface_Library_Unit diff --git a/gcc/ada/bindusg.adb b/gcc/ada/bindusg.adb index bfab985..3f99bae 100644 --- a/gcc/ada/bindusg.adb +++ b/gcc/ada/bindusg.adb @@ -156,6 +156,11 @@ package body Bindusg is (" -I- Don't look for sources & library files in default " & "directory"); + -- Line for -k switch + + Write_Line + (" -k Disable checking of elaboration flags"); + -- Line for -K switch Write_Line diff --git a/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst b/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst index 5442d55..37b6e95 100644 --- a/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst +++ b/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst @@ -6534,6 +6534,22 @@ be presented in subsequent sections. ALI file named in the ``gnatbind`` command line. + .. index:: -k (gnatbind) + +:switch:`-k` + Disable checking of elaboration flags. When using :switch:`-n` + either explicitly or implicitly, :switch:`-F` is also implied, + unless :switch:`-k` is used. This switch should be used with care + and you should ensure manually that elaboration routines are not called + twice unintentionally. + + + .. index:: -K (gnatbind) + +:switch:`-K` + Give list of linker options specified for link. + + .. index:: -l (gnatbind) :switch:`-l` diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index c6ce68a..e1a4192a 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -15724,6 +15724,22 @@ Do not look for sources in the current directory where @code{gnatbind} was invoked, and do not look for ALI files in the directory containing the ALI file named in the @code{gnatbind} command line. +@geindex -k (gnatbind) + +@item @code{-k} + +Disable checking of elaboration flags. When using @code{-n} +either explicitly or implicitly, @code{-F} is also implied, +unless @code{-k} is used. This switch should be used with care +and you should ensure manually that elaboration routines are not called +twice unintentionally. + +@geindex -K (gnatbind) + +@item @code{-K} + +Give list of linker options specified for link. + @geindex -l (gnatbind) @item @code{-l} @@ -29292,8 +29308,8 @@ to permit their use in free software. @printindex ge -@anchor{cf}@w{ } @anchor{gnat_ugn/gnat_utility_programs switches-related-to-project-files}@w{ } +@anchor{cf}@w{ } @c %**end of body @bye diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads index 0490895..19a8b41 100644 --- a/gcc/ada/opt.ads +++ b/gcc/ada/opt.ads @@ -267,6 +267,10 @@ package Opt is -- Set to True to detect whether subprogram parameters and function results -- alias the same object(s). + Check_Elaboration_Flags : Boolean := True; + -- GNATBIND + -- Set to False if switch -k is set. + Check_Float_Overflow : Boolean := False; -- GNAT -- Set to True to check that operations on predefined unconstrained float diff --git a/gcc/ada/switch-b.adb b/gcc/ada/switch-b.adb index 10feb23..a543ad9 100644 --- a/gcc/ada/switch-b.adb +++ b/gcc/ada/switch-b.adb @@ -379,6 +379,12 @@ package body Switch.B is Bad_Switch (Switch_Chars); end if; + -- Processing for k switch + + when 'k' => + Ptr := Ptr + 1; + Check_Elaboration_Flags := False; + -- Processing for K switch when 'K' => -- cgit v1.1