Problem with -static-libstdc++ on Mac OS X

Iain Sandoe iain@codesourcery.com
Thu Jun 18 13:12:00 GMT 2015


Hi Simon.

On 18 Jun 2015, at 13:50, Simon Wright wrote:

> On 18 Jun 2015, at 10:26, Simon Wright <simon@pushface.org> wrote:
> 
>> Just building 4.9.3 (as patched by AdaCore) now.
I have the patch for 4.8 - 9 - 5.1 and trunk if it's relevant.

> Worked OK - I think.

> 
> default: both libgcc and libstdc++ are shared.

right
> 
> -static-libstdc++: libgcc is shared, libstdc++ is static.

This is ok.
> 
> -static-libgcc: both libgcc and libstdc++ are static. 

This is intentional since [for at least some darwin variants] there's an unwinder in libgcc_s, or via it, - thus if you linked exe-gcc statically, and libstdc++ shared, the latter would be looking in /usr/lib/libgcc_s for the unwinder, while the exe would already have linked libgcc_eh statically.  At that point all bets are off - any exception that tries to unwind through the lib will break.

---

It's on my (somewhat lengthly) Darwin TODO to try and rationalise the libgcc/eh stuff for Darwins where the system "libgcc_s" doesn't actually contain the active unwinder.

---

Summary:
 -static-libstdc++ on Darwin OK & useful (esp. to deploy modern g++ based code to boxen without gcc installed).
 -static-libgcc    on Darwin is only workable in a very small sub-set of cases (and should probably be avoided by anyone who doesn't understand the implications in detail).  It is handy for the GCC testsuite, but outside that I'd not use it.

> -shared-libstdc++: g++: error: unrecognized command line option '-shared-libstdc++'
> 
>> For some reason the patch didn’t apply, though the line number was right — perhaps some mail-mangling. Did it by hand.
> 
> One of your lines got wrapped, and copy/paste retained the extra linefeed.

Yeah, C & P has a lot to answer for ;)

Iain

P.S. I posted the patch for review, so maybe it'll make it into trunk in due course.


More information about the Gcc-help mailing list