From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28346 invoked by alias); 15 Jun 2015 16:30:30 -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 28332 invoked by uid 89); 15 Jun 2015 16:30:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,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; Mon, 15 Jun 2015 16:30:27 +0000 Received: from [81.159.217.236] (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 1Z4XHE-00075B-5F for gcc-patches@gcc.gnu.org; Mon, 15 Jun 2015 17:30:24 +0100 From: Simon Wright Content-Type: multipart/mixed; boundary="Apple-Mail=_CE1FF02E-82E9-4C95-B3B3-AE6803453C8C" Subject: [PATCH] PR ada/66205 gnatbind generates invalid code when finalization is enabled in restricted runtime Message-Id: <7942AA17-3258-4B36-8B93-35C0574583AA@pushface.org> Date: Mon, 15 Jun 2015 16:31:00 -0000 To: gcc-patches@gcc.gnu.org Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) X-IsSubscribed: yes X-SW-Source: 2015-06/txt/msg01023.txt.bz2 --Apple-Mail=_CE1FF02E-82E9-4C95-B3B3-AE6803453C8C Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Content-length: 1050 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. The attached patch was bootstrapped/regression tested (make check-ada) agai= nst 5.1.0 on x86_64-apple-darwin13 (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. The patch applies with no offset to the trunk. gcc/ada/Changelog: 2015-6-15 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=_CE1FF02E-82E9-4C95-B3B3-AE6803453C8C Content-Disposition: attachment; filename=pr66205.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="pr66205.diff" Content-Transfer-Encoding: 7bit Content-length: 1431 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;"); --Apple-Mail=_CE1FF02E-82E9-4C95-B3B3-AE6803453C8C--