From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 41066 invoked by alias); 5 Dec 2017 17:16:52 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 41050 invoked by uid 89); 5 Dec 2017 17:16:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=H*Ad:U*simon, 10.2, H*r:ip*192.168.1.2, H*c:MHil X-HELO: smtp.hosts.co.uk Received: from smtp.hosts.co.uk (HELO smtp.hosts.co.uk) (85.233.160.19) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 05 Dec 2017 17:16:48 +0000 Received: from [92.3.189.71] (helo=[192.168.1.2]) by smtp.hosts.co.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim) (envelope-from ) id 1eMGpq-0001jS-6h; Tue, 05 Dec 2017 17:16:46 +0000 From: Simon Wright Message-Id: Content-Type: multipart/mixed; boundary="Apple-Mail=_979D4203-0167-4828-93B9-E9EE3352D08E" Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) 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 In-Reply-To: <146E92A8-A4E2-420F-A83D-92A585E32A2A@pushface.org> Cc: gcc-patches@gcc.gnu.org, Arnaud Charlet To: Simon Wright References: <7942AA17-3258-4B36-8B93-35C0574583AA@pushface.org> <666D196C-C248-45B3-A20F-138CE6B00457@pushface.org> <20151112100205.GA9491@adacore.com> <146E92A8-A4E2-420F-A83D-92A585E32A2A@pushface.org> X-SW-Source: 2017-12/txt/msg00238.txt.bz2 --Apple-Mail=_979D4203-0167-4828-93B9-E9EE3352D08E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Content-length: 2378 On 7 Mar 2017, at 16:20, Simon Wright wrote: >=20 > On 19 Dec 2015, at 22:05, Simon Wright wrote: >>=20 >> On 12 Nov 2015, at 10:02, Arnaud Charlet wrote: >>>=20 >>>>> This situation arises, for example, with an embedded RTS that >>>>> incorporates the >>>>> Ada 2012 generalized container iterators. >>>>=20 >>>> I should add, this PR is the ???other half??? of PR ada/66242, which i= s fixed >>>> in GCC 6; so please can it be reviewed? >>>=20 >>> The proper patch for PR ada/66242 hasn't been committed yet (it's pendi= ng), >>> so I'd rather review the situation once PR ada/66242 is dealt with. >>>=20 >>> 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. >>=20 >> Looks as though PR ada/66242 has been sorted out. >>=20 >> 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 201= 51213 with minor offsets (8). >=20 > 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 c= hange to the affected file (bindgen.adb) since then. I've come up with a considerably simpler patch, which merely causes the pro= cedure adafinal to be generated with a null body if the restriction No_Task= _Termination is set (note, this restriction is part of the Ravenscar profil= e; if tasks can't terminate, program level finalization can't happen [ARM 1= 0.2(25), "When the environment task completes (normally or abnormally), it = waits for the termination of all such tasks, and then finalizes any remaini= ng 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 oc= cur in both, in gnat.sum). For the arm-eabi compiler, I successfully make a= nd run builds for an STM32F4 target without exception propagation but with = and without finalization. gcc/ada/Changelog: 2017-12-05 Simon Wright PR ada/66205 * bindgen.adb (Gen_AdaFinal): If the restriction No_Task_Termination is present, generate a null body. --Apple-Mail=_979D4203-0167-4828-93B9-E9EE3352D08E Content-Disposition: attachment; filename=bindgen.adb.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="bindgen.adb.diff" Content-Transfer-Encoding: 7bit Content-length: 1003 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, --Apple-Mail=_979D4203-0167-4828-93B9-E9EE3352D08E--