public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR target/80556
@ 2017-06-09 13:57 Simon Wright
  2017-06-28 17:40 ` Jeff Law
  2017-06-28 21:36 ` Mike Stump
  0 siblings, 2 replies; 9+ messages in thread
From: Simon Wright @ 2017-06-09 13:57 UTC (permalink / raw)
  To: gcc-patches

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

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 <simon@pushface.org>

        PR target/80556
        * configure.ac (stage1_ldflags): For Darwin, include -lSystem.
          (poststage1_ldflags): likewise.
        * configure: regenerated.


[-- Attachment #2: 80556-3.diff --]
[-- Type: application/octet-stream, Size: 2598 bytes --]

--- 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
 

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-09-24 16:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-09 13:57 [PATCH] PR target/80556 Simon Wright
2017-06-28 17:40 ` Jeff Law
2017-06-29 20:41   ` Simon Wright
2017-09-01 13:03     ` Simon Wright
2017-09-18 20:10     ` Iain Sandoe
2017-09-18 21:08       ` Simon Wright
2017-09-22  9:55         ` Iain Sandoe
2017-09-24 16:06           ` Mike Stump
2017-06-28 21:36 ` Mike Stump

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).