[Bug libgcc/86215] Exceptions are broken on OSX when linking with -static-libgcc

simon at pushface dot org gcc-bugzilla@gcc.gnu.org
Sat Sep 1 08:06:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86215

simon at pushface dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simon at pushface dot org

--- Comment #1 from simon at pushface dot org ---
Related to PR80556.

Building this with GCC 8.1.0 on Darwin 17.7.0 results in

lockheed:86215 simon$ g++ demo.cc -static-libgcc -static-libstdc++
ld: warning: direct access in function 'operator new(unsigned long,
std::nothrow_t
const&) [clone .cold.0]' from file
'/opt/gcc-8.1.0/bin/../lib/gcc/x86_64-apple-darwin15/8.1.0/../../../libstdc++.a(new_opnt.o)'
to global weak symbol 'operator new(unsigned long, std::nothrow_t const&)' 
from file
'/opt/gcc-8.1.0/bin/../lib/gcc/x86_64-apple-darwin15/8.1.0/../../../libstdc++.a(new_opnt.o)' 
means the weak symbol cannot be overridden at runtime. 
This was likely caused by different translation units being compiled with 
different visibility settings.

and running it works OK.

lockheed:86215 simon$ ./a.out
abc123

This GCC 8.1.0 was 
Configured with: ../gcc-8.1.0/configure 
--prefix=/Volumes/Miscellaneous/tmp/opt/gcc-8.1.0 
--without-libiconv-prefix 
--disable-libmudflap 
--disable-libstdcxx-pch 
--disable-libsanitizer 
--disable-libcc1 
--disable-libcilkrts 
--disable-multilib 
--disable-nls 
--enable-languages=c,c++,ada,fortran,objc,obj-c++ 
--host=x86_64-apple-darwin15 
--target=x86_64-apple-darwin15 
--build=x86_64-apple-darwin15 
--with-boot-ldflags='-static-libstdc++ -static-libgcc
-Wl,-headerpad_max_install_names'

The reason for explicitly setting the boot-ldflags was because of the need to
also specify the headerpad-max option.


More information about the Gcc-bugs mailing list