public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
To: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] PR target/80556
Date: Fri, 01 Sep 2017 13:03:00 -0000	[thread overview]
Message-ID: <05E1B5C3-FE6B-4AF3-B987-FF77B17A2290@pushface.org> (raw)
In-Reply-To: <8DF8CB89-6147-4E03-9507-851BFAF0F105@pushface.org>

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

On 29 Jun 2017, at 21:41, Simon Wright <simon@pushface.org> wrote:
> 
> On 28 Jun 2017, at 18:40, Jeff Law <law@redhat.com> wrote:
>> 
>> On 06/09/2017 07:57 AM, Simon Wright wrote:
>>>       2017-06-09 Simon Wright <simon@pushface.org>
>>> 
>>>       PR target/80556
>>>       * configure.ac (stage1_ldflags): For Darwin, include -lSystem.
>>>         (poststage1_ldflags): likewise.
>>>       * configure: regenerated.
>> I'm a bit confused here.  Isn't -lSystem included in darwin's LIB_SPEC
>> in which case the right things ought to already be happening, shouldn't it?
> 
> The specs that involve -lSystem are
> 
> *link_gcc_c_sequence:
> %:version-compare(>= 10.6 mmacosx-version-min= -no_compact_unwind)    %{!static:%{!static-libgcc:       %:version-compare(>= 10.6 mmacosx-version-min= -lSystem) } }    %{fno-pic|fno-PIC|fno-pie|fno-PIE|fapple-kext|mkernel|static|mdynamic-no-pic:       %:version-compare(>= 10.7 mmacosx-version-min= -no_pie) } %G %L
> 
> *lib:
> %{!static:-lSystem}
> 
> but I also see
> 
> *libgcc:
> %{static-libgcc|static: -lgcc_eh -lgcc; ....
> 
> which might be the root of the problem?
> 
> Looking at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80556#c39, I report that
> 
>   $ gnatmake raiser -largs -static-libgcc -static-libstdc++
> 
> resulted in the link command
> 
>   /usr/bin/ld -dynamic -arch x86_64 -macosx_version_min 10.12.0
>   -weak_reference_mismatches non-weak -o raiser -L./
>   -L/opt/gcc-7.1.0/lib/gcc/x86_64-apple-darwin15/7.1.0/adalib/
>   -L/opt/gcc-7.1.0/lib/gcc/x86_64-apple-darwin15/7.1.0
>   -L/opt/gcc-7.1.0/lib/gcc/x86_64-apple-darwin15/7.1.0/../../.. b~raiser.o
>   ./raiser.o -v
>   /opt/gcc-7.1.0/lib/gcc/x86_64-apple-darwin15/7.1.0/adalib/libgnat.a
>   -no_compact_unwind -lgcc_eh -lgcc -lSystem
> 
> i.e. -lSystem is *after* -lgcc, so that its exception handling won't be invoked.
> 
> I don't know what -lgcc_eh does, but my patch would be pretty much equivalent to changing the libgcc spec above to
> 
> *libgcc:
> %{static-libgcc|static: -lSystem -lgcc_eh -lgcc; ....
> 
> and if that would be OK it would obviously be much better.
> 
> I've rebuilt gcc-8-20170528 with this change alone (i.e. not the patch currently posted here), successfully.

I've rebuilt and tested gcc-8-20170820 with this change, successfully.

gcc/Changelog:

       2017-09-01 Simon Wright <simon@pushface.org>

       PR target/80556
       * config/darwin.h (REAL_LIBGCC_SPEC): for static-libgcc|static, include -lSystem first.


[-- Attachment #2: 80556-darwin.h.diff --]
[-- Type: application/octet-stream, Size: 796 bytes --]

--- gcc/config/darwin.h.orig	2017-01-16 21:33:07.000000000 +0000
+++ gcc/config/darwin.h	2017-07-03 14:19:55.000000000 +0100
@@ -339,10 +339,12 @@
    libraries, you need to explicitly say -static-libgcc.
 
    If it is linked against, it has to be before -lgcc, because it may
-   need symbols from -lgcc.  */
+   need symbols from -lgcc.
+
+   For PR80556 and PR61027, link libSystem before a static libgcc.  */
 #undef REAL_LIBGCC_SPEC
 #define REAL_LIBGCC_SPEC						   \
-   "%{static-libgcc|static: -lgcc_eh -lgcc;				   \
+   "%{static-libgcc|static: -lSystem -lgcc_eh -lgcc;			   \
       shared-libgcc|fexceptions|fgnu-runtime:				   \
        %:version-compare(!> 10.5 mmacosx-version-min= -lgcc_s.10.4)	   \
        %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5)   \

[-- Attachment #3: Type: text/plain, Size: 2 bytes --]




  reply	other threads:[~2017-09-01 13:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-09 13:57 Simon Wright
2017-06-28 17:40 ` Jeff Law
2017-06-29 20:41   ` Simon Wright
2017-09-01 13:03     ` Simon Wright [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=05E1B5C3-FE6B-4AF3-B987-FF77B17A2290@pushface.org \
    --to=simon@pushface.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).