public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] PR ada/66205 gnatbind generates invalid code when finalization is enabled in restricted runtime
Date: Mon, 15 Jun 2015 16:31:00 -0000	[thread overview]
Message-ID: <7942AA17-3258-4B36-8B93-35C0574583AA@pushface.org> (raw)

[-- 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;");

             reply	other threads:[~2015-06-15 16:30 UTC|newest]

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

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=7942AA17-3258-4B36-8B93-35C0574583AA@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).