public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR ada/66205 gnatbind generates invalid code when finalization is enabled in restricted runtime
@ 2015-06-15 16:31 Simon Wright
  2015-11-11 19:43 ` Simon Wright
  0 siblings, 1 reply; 9+ messages in thread
From: Simon Wright @ 2015-06-15 16:31 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1060 bytes --]

If the RTS in use is "configurable" (I believe this is the same in this context as "restricted") and includes finalization, gnatbind generates binder code that won't compile.

This situation arises, for example, with an embedded RTS that incorporates the Ada 2012 generalized container iterators.

The attached patch was bootstrapped/regression tested (make check-ada) against 5.1.0 on x86_64-apple-darwin13 (which confirms that the patch hasn't broken builds against the standard RTS).

arm-eabi-gnatbind was successful against both an RTS with finalization and one without.

The patch applies with no offset to the trunk.

gcc/ada/Changelog:

2015-6-15  Simon Wright <simon@pushface.org>

        PR ada/66205
        * bindgen.adb (Gen_Adafinal): if Configurable_Run_Time_On_Target is
        true, generate a null body.
        (Gen_Main): if Configurable_Run_Time_On_Target is true, then
        - don't import __gnat_initialize or __gnat_finalize (as Initialize,
        Finalize rsp).
        - don't call Initialize or Finalize.


[-- Attachment #2: pr66205.diff --]
[-- Type: application/octet-stream, Size: 1431 bytes --]

diff -r 241625079f4f gcc/ada/bindgen.adb
--- a/gcc/ada/bindgen.adb	Sat Apr 25 16:51:45 2015 +0100
+++ b/gcc/ada/bindgen.adb	Mon Jun 15 16:51:38 2015 +0100
@@ -380,6 +380,15 @@
    begin
       WBI ("   procedure " & Ada_Final_Name.all & " is");
 
+      if Configurable_Run_Time_On_Target then
+         --  Nothing to do
+         WBI ("   begin");
+         WBI ("      null;");
+         WBI ("   end " & Ada_Final_Name.all & ";");
+         WBI ("");
+         return;
+      end if;
+
       if VM_Target = No_VM
         and Bind_Main_Program
         and not CodePeer_Mode
@@ -1703,6 +1712,7 @@
 
       if not CodePeer_Mode
         and then not Cumulative_Restrictions.Set (No_Finalization)
+        and then not Configurable_Run_Time_On_Target
       then
          WBI ("      procedure Initialize (Addr : System.Address);");
          WBI ("      pragma Import (C, Initialize, ""__gnat_initialize"");");
@@ -1806,6 +1816,7 @@
       end if;
 
       if not Cumulative_Restrictions.Set (No_Finalization)
+        and then not Configurable_Run_Time_On_Target
         and then not CodePeer_Mode
       then
          if not No_Main_Subprogram
@@ -1851,6 +1862,7 @@
       --  Finalize is only called if we have a run time
 
       if not Cumulative_Restrictions.Set (No_Finalization)
+        and then not Configurable_Run_Time_On_Target
         and then not CodePeer_Mode
       then
          WBI ("      Finalize;");

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-12-19  8:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-15 16:31 [PATCH] PR ada/66205 gnatbind generates invalid code when finalization is enabled in restricted runtime Simon Wright
2015-11-11 19:43 ` Simon Wright
2015-11-12  8:56   ` Simon Wright
2015-11-12 10:02     ` Arnaud Charlet
2015-12-19 22:05       ` Simon Wright
2017-03-07 16:20         ` Simon Wright
2017-12-05 17:16           ` Simon Wright
2017-12-05 18:09             ` Arnaud Charlet
2017-12-19  8:41             ` Arnaud Charlet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).