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

2019-05-14 Thread simon at pushface dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86215

--- Comment #5 from simon at pushface dot org ---
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/gcc-9.1.0/bin/../libexec/gcc/x86_64-apple-darwin15/9.1.0/lto-wrapper
Target: x86_64-apple-darwin15
Configured with: /Volumes/Miscellaneous/tmp/gcc-9.1.0/configure
--prefix=/Volumes/Miscellaneous/tmp/opt/gcc-9.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'
Thread model: posix
gcc version 9.1.0 (GCC) 


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


$ otool -L a.out
a.out:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 1252.250.1)


$ DYLD_PRINT_LIBRARIES=1 ./a.out
dyld: loaded: /Users/simon/tmp/bugs/86215/./a.out
dyld: loaded: /usr/lib/libSystem.B.dylib
dyld: loaded: /usr/lib/system/libcache.dylib
dyld: loaded: /usr/lib/system/libcommonCrypto.dylib
dyld: loaded: /usr/lib/system/libcompiler_rt.dylib
dyld: loaded: /usr/lib/system/libcopyfile.dylib
dyld: loaded: /usr/lib/system/libcorecrypto.dylib
dyld: loaded: /usr/lib/system/libdispatch.dylib
dyld: loaded: /usr/lib/system/libdyld.dylib
dyld: loaded: /usr/lib/system/libkeymgr.dylib
dyld: loaded: /usr/lib/system/liblaunch.dylib
dyld: loaded: /usr/lib/system/libmacho.dylib
dyld: loaded: /usr/lib/system/libquarantine.dylib
dyld: loaded: /usr/lib/system/libremovefile.dylib
dyld: loaded: /usr/lib/system/libsystem_asl.dylib
dyld: loaded: /usr/lib/system/libsystem_blocks.dylib
dyld: loaded: /usr/lib/system/libsystem_c.dylib
dyld: loaded: /usr/lib/system/libsystem_configuration.dylib
dyld: loaded: /usr/lib/system/libsystem_coreservices.dylib
dyld: loaded: /usr/lib/system/libsystem_darwin.dylib
dyld: loaded: /usr/lib/system/libsystem_dnssd.dylib
dyld: loaded: /usr/lib/system/libsystem_info.dylib
dyld: loaded: /usr/lib/system/libsystem_m.dylib
dyld: loaded: /usr/lib/system/libsystem_malloc.dylib
dyld: loaded: /usr/lib/system/libsystem_networkextension.dylib
dyld: loaded: /usr/lib/system/libsystem_notify.dylib
dyld: loaded: /usr/lib/system/libsystem_sandbox.dylib
dyld: loaded: /usr/lib/system/libsystem_secinit.dylib
dyld: loaded: /usr/lib/system/libsystem_kernel.dylib
dyld: loaded: /usr/lib/system/libsystem_platform.dylib
dyld: loaded: /usr/lib/system/libsystem_pthread.dylib
dyld: loaded: /usr/lib/system/libsystem_symptoms.dylib
dyld: loaded: /usr/lib/system/libsystem_trace.dylib
dyld: loaded: /usr/lib/system/libunwind.dylib
dyld: loaded: /usr/lib/system/libxpc.dylib
dyld: loaded: /usr/lib/libobjc.A.dylib
dyld: loaded: /usr/lib/libc++abi.dylib
dyld: loaded: /usr/lib/libc++.1.dylib
abc123


NB, this GCC was built for darwin15, run on darwin18.

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

2019-05-14 Thread iains at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86215

Iain Sandoe  changed:

   What|Removed |Added

   Target Milestone|--- |7.5

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

2019-05-14 Thread iains at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86215

Iain Sandoe  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-05-14
 Ever confirmed|0   |1

--- Comment #4 from Iain Sandoe  ---
I repeated this on gcc-7.4.1 (271140)

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

2019-05-13 Thread iains at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86215

--- Comment #3 from Iain Sandoe  ---
please could you print the output of:

DYLD_PRINT_LIBRARIES=1 ./a.out

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

2019-03-02 Thread simon at pushface dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86215

--- Comment #2 from simon at pushface dot org ---
(In reply to simon from comment #1)

Same results with gcc version 9.0.1 20190219 (experimental) (GCC)
on Darwin 18.2.0.

$ otool -L a.out
a.out:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 1252.200.5)

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

2018-09-01 Thread simon at pushface dot org
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.