From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 130482 invoked by alias); 9 Jun 2017 13:57:13 -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 130460 invoked by uid 89); 9 Jun 2017 13:57:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1627, H*MI:80DE, H*m:80DE, H*c:HpplH 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; Fri, 09 Jun 2017 13:57:08 +0000 Received: from [62.64.204.68] (helo=[192.168.1.2]) by smtp.hosts.co.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89) (envelope-from ) id 1dJKPX-0006th-7s for gcc-patches@gcc.gnu.org; Fri, 09 Jun 2017 14:57:11 +0100 From: Simon Wright Content-Type: multipart/mixed; boundary="Apple-Mail=_20313AA5-3730-4026-B803-85EA267028BB" Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [PATCH] PR target/80556 Message-Id: <9BD5550D-1CBC-4A8C-80DE-61BE01001EE6@pushface.org> Date: Fri, 09 Jun 2017 13:57:00 -0000 To: gcc-patches@gcc.gnu.org X-IsSubscribed: yes X-SW-Source: 2017-06/txt/msg00651.txt.bz2 --Apple-Mail=_20313AA5-3730-4026-B803-85EA267028BB Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Content-length: 1657 This PR was raised because of a bootstrap failure on Darwin. The cause was a mishandled exception raised by Rtsfind.Load_Fail while processing g-exptty.adb. g-exptty.adb had been updated on 2017-04-25 (but so had a lot of other parts of GNAT). Since a lot of other compilations had been performed successfully by this point in the build, one may assume that this was the first that actually caused an exception. The exception was mishandled because the default ldflags call up -static-libgcc, and (on Darwin; not, it seems, on Debian [jessie]), the notes on -static-libgcc/-shared-libgcc at https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html which say However, if a library or main executable is supposed to throw or catch exceptions, you must link it using the G++ driver, as appropriate for the languages used in the program, or using the option -shared-libgcc, such that it is linked with the shared libgcc. do actually apply (this affects all the Ada executables, in this case specifically gnat1). The result of the mishandling of the exception is that gnat1 crashes with SIGILL. The change proposed here is to include -lSystem in such a way that it's called in before the (static) libgcc, and thus supplies the required exception unwinders. Bootstrapped on Darwin 16.6.0 and on Debian Jessie. A question: I've checked for x86_64-apple-darwin*, is this OK or should it be more restrictive? Changelog: 2017-06-09 Simon Wright PR target/80556 * configure.ac (stage1_ldflags): For Darwin, include -lSystem. (poststage1_ldflags): likewise. * configure: regenerated. --Apple-Mail=_20313AA5-3730-4026-B803-85EA267028BB Content-Disposition: attachment; filename=80556-3.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="80556-3.diff" Content-Transfer-Encoding: 7bit Content-length: 2598 --- configure.ac-orig 2017-06-05 10:58:51.000000000 +0100 +++ configure.ac 2017-06-08 17:42:08.000000000 +0100 @@ -1650,7 +1650,12 @@ # if supported. But if the user explicitly specified the libraries to use, # trust that they are doing what they want. if test "$stage1_libs" = "" -a "$have_static_libs" = yes; then - stage1_ldflags="-static-libstdc++ -static-libgcc" + # .. but on Darwin, for exception handling, we include -lSystem + # (which is included before -lgcc, and uses the correct unwinder) + case $host in + x86_64-apple-darwin*) stage1_ldflags="-lSystem -static-libstdc++ -static-libgcc";; + *) stage1_ldflags="-static-libstdc++ -static-libgcc";; + esac fi]) AC_SUBST(stage1_ldflags) @@ -1679,7 +1684,12 @@ # statically. But if the user explicitly specified the libraries to # use, trust that they are doing what they want. if test "$poststage1_libs" = ""; then - poststage1_ldflags="-static-libstdc++ -static-libgcc" + # .. but on Darwin, for exception handling, we include -lSystem + # (which is included before -lgcc, and uses the correct unwinder) + case $host in + x86_64-apple-darwin*) poststage1_ldflags="-lSystem -static-libstdc++ -static-libgcc";; + *) poststage1_ldflags="-static-libstdc++ -static-libgcc";; + esac fi]) AC_SUBST(poststage1_ldflags) --- configure-orig 2017-06-05 10:59:09.000000000 +0100 +++ configure 2017-06-08 17:42:25.000000000 +0100 @@ -5819,7 +5819,12 @@ # if supported. But if the user explicitly specified the libraries to use, # trust that they are doing what they want. if test "$stage1_libs" = "" -a "$have_static_libs" = yes; then - stage1_ldflags="-static-libstdc++ -static-libgcc" + # .. but on Darwin, for exception handling, we include -lSystem + # (which is included before -lgcc, and uses the correct unwinder) + case $host in + x86_64-apple-darwin*) stage1_ldflags="-lSystem -static-libstdc++ -static-libgcc";; + *) stage1_ldflags="-static-libstdc++ -static-libgcc";; + esac fi fi @@ -5855,7 +5860,12 @@ # statically. But if the user explicitly specified the libraries to # use, trust that they are doing what they want. if test "$poststage1_libs" = ""; then - poststage1_ldflags="-static-libstdc++ -static-libgcc" + # .. but on Darwin, for exception handling, we include -lSystem + # (which is included before -lgcc, and uses the correct unwinder) + case $host in + x86_64-apple-darwin*) poststage1_ldflags="-lSystem -static-libstdc++ -static-libgcc";; + *) poststage1_ldflags="-static-libstdc++ -static-libgcc";; + esac fi fi --Apple-Mail=_20313AA5-3730-4026-B803-85EA267028BB--