From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11341 invoked by alias); 11 Nov 2015 19:43:19 -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 10475 invoked by uid 89); 11 Nov 2015 19:43:19 -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 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 11 Nov 2015 19:43:15 +0000 Received: from [86.175.76.144] (helo=[192.168.1.74]) by smtp.hosts.co.uk with esmtpsa (TLSv1:DHE-RSA-AES128-SHA:128) (Exim 4.80.1) (envelope-from ) id 1ZwbIV-0003KK-6I; Wed, 11 Nov 2015 19:43:11 +0000 Content-Type: multipart/mixed; boundary="Apple-Mail=_61C8538C-5551-4CC7-B220-F57D0AA0C651" Mime-Version: 1.0 (Mac OS X Mail 9.1 \(3096.5\)) Subject: Re: [PATCH] PR ada/66205 gnatbind generates invalid code when finalization is enabled in restricted runtime From: Simon Wright In-Reply-To: <7942AA17-3258-4B36-8B93-35C0574583AA@pushface.org> Date: Wed, 11 Nov 2015 19:43:00 -0000 Cc: gcc-patches@gcc.gnu.org Message-Id: References: <7942AA17-3258-4B36-8B93-35C0574583AA@pushface.org> To: Simon Wright X-SW-Source: 2015-11/txt/msg01417.txt.bz2 --Apple-Mail=_61C8538C-5551-4CC7-B220-F57D0AA0C651 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Content-length: 1664 I=E2=80=99ve updated the original patch, which was built against 5.1.0 on x= 64_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 con= text 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=E2= =80=99t occur, and I=E2=80=99ve added a check that Configurable_Run_Time_On= _Target isn=E2=80=99t set; I suspect, given other areas of the code, that t= he 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) agai= nst 6.0.0 on x86_64-apple-darwin15 (which confirms that the patch hasn't br= oken 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 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. --Apple-Mail=_61C8538C-5551-4CC7-B220-F57D0AA0C651 Content-Disposition: attachment; filename=gcc-6.0.0-20151101-gcc-ada-bindgen.adb.diff Content-Type: application/octet-stream; name="gcc-6.0.0-20151101-gcc-ada-bindgen.adb.diff" Content-Transfer-Encoding: 7bit Content-length: 1758 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;"); --Apple-Mail=_61C8538C-5551-4CC7-B220-F57D0AA0C651--