public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
To: Simon Wright <simon@pushface.org>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] PR ada/66205 gnatbind generates invalid code when finalization is enabled in restricted runtime
Date: Wed, 11 Nov 2015 19:43:00 -0000	[thread overview]
Message-ID: <E8542217-EDC5-48AE-B087-F49528CF4AD1@pushface.org> (raw)
In-Reply-To: <7942AA17-3258-4B36-8B93-35C0574583AA@pushface.org>

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

I’ve updated the original patch, which was built against 5.1.0 on x64_64-apple-darwin13, this patch is against 6.0.0-20151101 on x86_64-apple-darwin15.

--------------

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.

I note that in the last 3 hunks of the attached patch there may be overkill; the original code checks whether the No_Finalization restriction doesn’t occur, and I’ve added a check that Configurable_Run_Time_On_Target isn’t set; I suspect, given other areas of the code, that the No_Finalization check is actually intended as a way of determining that this is a restricted runtime, and that the Configurable_Run_Time_On_Target check could replace it.

The attached patch was bootstrapped/regression tested (make check-ada) against 6.0.0 on x86_64-apple-darwin15 (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.

gcc/ada/Changelog:

2015-11-11  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: gcc-6.0.0-20151101-gcc-ada-bindgen.adb.diff --]
[-- Type: application/octet-stream, Size: 1758 bytes --]

diff --git a/gcc/ada/bindgen.adb b/gcc/ada/bindgen.adb
--- a/gcc/ada/bindgen.adb
+++ b/gcc/ada/bindgen.adb
@@ -415,6 +415,18 @@
    begin
       WBI ("   procedure " & Ada_Final_Name.all & " is");
 
+      --  For restricted run-time libraries (ZFP and Ravenscar) tasks
+      --  are non-terminating, so we do not want finalization.
+
+      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 Bind_Main_Program and not CodePeer_Mode then
          WBI ("      procedure s_stalib_adafinal;");
          Set_String ("      pragma Import (C, s_stalib_adafinal, ");
@@ -1643,6 +1655,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"");");
@@ -1746,6 +1759,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
@@ -1788,9 +1802,11 @@
          WBI ("      Output_Results;");
       end if;
 
-      --  Finalize is only called if we have a run time
+      --  Finalize is only called if we have a full (non-restricted)
+      --  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;");

  reply	other threads:[~2015-11-11 19:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-15 16:31 Simon Wright
2015-11-11 19:43 ` Simon Wright [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E8542217-EDC5-48AE-B087-F49528CF4AD1@pushface.org \
    --to=simon@pushface.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).