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, Arnaud Charlet <charlet@adacore.com>
Subject: Re: [PATCH] PR ada/66205 gnatbind generates invalid code when finalization is enabled in restricted runtime
Date: Tue, 05 Dec 2017 17:16:00 -0000	[thread overview]
Message-ID: <B1D23A9E-1B6B-47AD-90D8-138B3A162507@pushface.org> (raw)
In-Reply-To: <146E92A8-A4E2-420F-A83D-92A585E32A2A@pushface.org>

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

On 7 Mar 2017, at 16:20, Simon Wright <simon@pushface.org> wrote:
> 
> On 19 Dec 2015, at 22:05, Simon Wright <simon@pushface.org> wrote:
>> 
>> On 12 Nov 2015, at 10:02, Arnaud Charlet <charlet@adacore.com> wrote:
>>> 
>>>>> This situation arises, for example, with an embedded RTS that
>>>>> incorporates the
>>>>> Ada 2012 generalized container iterators.
>>>> 
>>>> I should add, this PR is the ???other half??? of PR ada/66242, which is fixed
>>>> in GCC 6; so please can it be reviewed?
>>> 
>>> The proper patch for PR ada/66242 hasn't been committed yet (it's pending),
>>> so I'd rather review the situation once PR ada/66242 is dealt with.
>>> 
>>> I'm not convinced at all that your patch is the way to go, so I'd rather
>>> consider it only after PR ada/66242 is solved properly.
>> 
>> Looks as though PR ada/66242 has been sorted out.
>> 
>> Since we can now *compile* code that is built with finalization enabled in a restricted runtime, but we can't *bind* it, could we take another look at this? the patch I provided in this thread still applies at snapshot 20151213 with minor offsets (8).
> 
> Same problem exists in gcc version 7.0.1 20170302 (experimental) (GCC).

and with gcc 8.0.0 20171102 (experimental) (r254339); and there's been no change to the affected file (bindgen.adb) since then.

I've come up with a considerably simpler patch, which merely causes the procedure adafinal to be generated with a null body if the restriction No_Task_Termination is set (note, this restriction is part of the Ravenscar profile; if tasks can't terminate, program level finalization can't happen [ARM 10.2(25), "When the environment task completes (normally or abnormally), it waits for the termination of all such tasks, and then finalizes any remaining objects of the partition."]

I've bootstrapped the compiler (x86_64-apple-darwin15), and "make check-ada" produces the same results with and without the patch (the same 3 FAILs occur in both, in gnat.sum). For the arm-eabi compiler, I successfully make and run builds for an STM32F4 target without exception propagation but with and without finalization.

gcc/ada/Changelog:

2017-12-05  Simon Wright <simon@pushface.org>

     PR ada/66205
      * bindgen.adb (Gen_AdaFinal): If the restriction
         No_Task_Termination is present, generate a null body.


[-- Attachment #2: bindgen.adb.diff --]
[-- Type: application/octet-stream, Size: 1003 bytes --]

diff --git a/gcc/ada/bindgen.adb b/gcc/ada/bindgen.adb
index e3d875bc8cc..b02360087ef 100644
--- a/gcc/ada/bindgen.adb
+++ b/gcc/ada/bindgen.adb
@@ -450,6 +450,20 @@ package body Bindgen is
    begin
       WBI ("   procedure " & Ada_Final_Name.all & " is");
 
+      --  If task termination isn't allowed (as is the case in
+      --  restricted runtimes, such as Ravenscar or ZFP, but may not
+      --  be the case for all configurable runtimes), we don't need
+      --  program-level finalization.
+
+      if Cumulative_Restrictions.Set (No_Task_Termination) then
+         --  Nothing to do
+         WBI ("   begin");
+         WBI ("      null;");
+         WBI ("   end " & Ada_Final_Name.all & ";");
+         WBI ("");
+         return;
+      end if;
+
       --  Call s_stalib_adafinal to await termination of tasks and so on. We
       --  want to do this if there is a main program, either in Ada or in some
       --  other language. (Note that Bind_Main_Program is True for Ada mains,

  reply	other threads:[~2017-12-05 17:16 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
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 [this message]
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=B1D23A9E-1B6B-47AD-90D8-138B3A162507@pushface.org \
    --to=simon@pushface.org \
    --cc=charlet@adacore.com \
    --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).