Any C++ code I try to compile with GCC 10.2.0 (homebrew package AND build from source) aborts when exception is thrown even when the exception should caught. This minimal example aborts: ``` struct exception { }; int main() { try { throw exception{}; } catch (exception) { } catch (...) { } } ``` (Build with g++ exception.cpp && ./a.out) My GCC build is: ``` Using built-in specs. COLLECT_GCC=/usr/local/gcc-10.2/bin/g++-10.2 COLLECT_LTO_WRAPPER=/usr/local/gcc-10.2/libexec/gcc/x86_64-apple-darwin20.2.0/10.2.0/lto-wrapper Target: x86_64-apple-darwin20.2.0 Configured with: ../gcc-10.2.0/configure --prefix=/usr/local/gcc-10.2 --enable-checking=release --enable-languages=c,c++ --disable-multilib --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk --program-suffix=-10.2 Thread model: posix Supported LTO compression algorithms: zlib gcc version 10.2.0 (GCC) ``` Backtrace of the binary when crashes is: ``` * frame #0: 0x00007fff20347462 libsystem_kernel.dylib`__pthread_kill + 10 frame #1: 0x00007fff20375610 libsystem_pthread.dylib`pthread_kill + 263 frame #2: 0x00007fff202c8720 libsystem_c.dylib`abort + 120 frame #3: 0x000000010048b00a libgcc_s.1.dylib`uw_init_context_1.cold + 5 frame #4: 0x0000000100488475 libgcc_s.1.dylib`_Unwind_RaiseException(exc=0x0000000100505760) at unwind.inc:93:3 frame #5: 0x00000001001382f7 libstdc++.6.dylib`__cxa_throw + 55 frame #6: 0x0000000100003f13 a.out`main at exception.cpp:5:19 frame #7: 0x00007fff20390621 libdyld.dylib`start + 1 ```
I found out that build done on Catalina generates correct binary, which is able to run on Big Sur without any problem.
Hi Hana .. There are some changes needed on the 10.x branch to cater for macOS 11. Trying to ensure that we get them in before 10.3 is released. In the meantime, I'll discuss with the home-brew folks about other strategies. Failing that I can push my work in progress for the branch somewhere and you can build that. Iain
On macOS Big Sur Intel, Homebrew builds gcc-10 from the 10.2 release sources (https://ftp.gnu.org/gnu/gcc/gcc-10.2.0/gcc-10.2.0.tar.xz) with one extra patch at https://raw.githubusercontent.com/Homebrew/formula-patches/7baf6e2f/gcc/bigsur.diff (which is basically Iain's commit at https://github.com/iains/gcc-darwin-arm64/commit/556ab512) The compiler is build with: ``` ../configure --build=x86_64-apple-darwin20 --prefix=/usr/local/Cellar/gcc/10.2.0_2 --libdir=/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10 --disable-nls --enable-checking=release --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-10 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --with-pkgversion='Homebrew GCC 10.2.0_2' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk SED=/usr/bin/sed ``` We've always done it that way, the only recent change to that is pretty much that we use the unversioned symlink /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk instead of the versioned directory (/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk) because since Big Sur, Apple is labelling their SDK with minor version numbers and that breaks for people who don't have the same exact version of the command-line developer tools.
And I can confirm the crash on my own system, with the same stack backtrace.
Here is what g++-10 -v gives during compilation: rmeur /tmp $ g++-10 a.cpp -v Using built-in specs. COLLECT_GCC=g++-10 COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/10.2.0_2/libexec/gcc/x86_64-apple-darwin20/10.2.0/lto-wrapper Target: x86_64-apple-darwin20 Configured with: ../configure --build=x86_64-apple-darwin20 --prefix=/usr/local/Cellar/gcc/10.2.0_2 --libdir=/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10 --disable-nls --enable-checking=release --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-10 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --with-pkgversion='Homebrew GCC 10.2.0_2' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk SED=/usr/bin/sed Thread model: posix Supported LTO compression algorithms: zlib gcc version 10.2.0 (Homebrew GCC 10.2.0_2) COLLECT_GCC_OPTIONS='-v' '-mmacosx-version-min=11.0.0' '-asm_macosx_version_min=11.0' '-shared-libgcc' '-mtune=core2' /usr/local/Cellar/gcc/10.2.0_2/libexec/gcc/x86_64-apple-darwin20/10.2.0/cc1plus -quiet -v -D__DYNAMIC__ a.cpp -fPIC -quiet -dumpbase a.cpp -mmacosx-version-min=11.0.0 -mtune=core2 -auxbase a -version -o /var/folders/h8/9hx_fyj91053ksgdzb2w03vw0000gp/T//ccf7qnt5.s GNU C++14 (Homebrew GCC 10.2.0_2) version 10.2.0 (x86_64-apple-darwin20) compiled by GNU C version 10.2.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.23-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include" ignoring nonexistent directory "/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin20/10.2.0/../../../../../../x86_64-apple-darwin20/include" ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks" #include "..." search starts here: #include <...> search starts here: /usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin20/10.2.0/../../../../../../include/c++/10.2.0 /usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin20/10.2.0/../../../../../../include/c++/10.2.0/x86_64-apple-darwin20 /usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin20/10.2.0/../../../../../../include/c++/10.2.0/backward /usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin20/10.2.0/include /usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin20/10.2.0/include-fixed /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks End of search list. GNU C++14 (Homebrew GCC 10.2.0_2) version 10.2.0 (x86_64-apple-darwin20) compiled by GNU C version 10.2.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.23-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 226b82c9217faee57636048830034c6a COLLECT_GCC_OPTIONS='-v' '-mmacosx-version-min=11.0.0' '-shared-libgcc' '-mtune=core2' as -arch x86_64 -v -force_cpusubtype_ALL -mmacosx-version-min=11.0 -o /var/folders/h8/9hx_fyj91053ksgdzb2w03vw0000gp/T//cclYOyAu.o /var/folders/h8/9hx_fyj91053ksgdzb2w03vw0000gp/T//ccf7qnt5.s Apple clang version 12.0.0 (clang-1200.0.32.28) Target: x86_64-apple-darwin20.2.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1as -triple x86_64-apple-macosx11.0.0 -filetype obj -main-file-name ccf7qnt5.s -target-cpu penryn -fdebug-compilation-dir /tmp -dwarf-debug-producer "Apple clang version 12.0.0 (clang-1200.0.32.28)" -dwarf-version=4 -mrelocation-model pic -o /var/folders/h8/9hx_fyj91053ksgdzb2w03vw0000gp/T//cclYOyAu.o /var/folders/h8/9hx_fyj91053ksgdzb2w03vw0000gp/T//ccf7qnt5.s COMPILER_PATH=/usr/local/Cellar/gcc/10.2.0_2/libexec/gcc/x86_64-apple-darwin20/10.2.0/:/usr/local/Cellar/gcc/10.2.0_2/libexec/gcc/x86_64-apple-darwin20/10.2.0/:/usr/local/Cellar/gcc/10.2.0_2/libexec/gcc/x86_64-apple-darwin20/:/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin20/10.2.0/:/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin20/ LIBRARY_PATH=/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin20/10.2.0/:/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin20/10.2.0/../../../ COLLECT_GCC_OPTIONS='-v' '-mmacosx-version-min=11.0.0' '-shared-libgcc' '-mtune=core2' /usr/local/Cellar/gcc/10.2.0_2/libexec/gcc/x86_64-apple-darwin20/10.2.0/collect2 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/ -dynamic -arch x86_64 -macosx_version_min 11.0.0 -weak_reference_mismatches non-weak -o a.out -L/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin20/10.2.0 -L/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin20/10.2.0/../../.. /var/folders/h8/9hx_fyj91053ksgdzb2w03vw0000gp/T//cclYOyAu.o -lstdc++ -lSystem -lgcc_ext.10.5 -lgcc -lSystem -no_compact_unwind -v collect2 version 10.2.0 /usr/bin/ld -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/ -dynamic -arch x86_64 -macosx_version_min 11.0.0 -weak_reference_mismatches non-weak -o a.out -L/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin20/10.2.0 -L/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin20/10.2.0/../../.. /var/folders/h8/9hx_fyj91053ksgdzb2w03vw0000gp/T//cclYOyAu.o -lstdc++ -lSystem -lgcc_ext.10.5 -lgcc -lSystem -no_compact_unwind -v @(#)PROGRAM:ld PROJECT:ld64-609.8 BUILD 20:09:52 Nov 4 2020 configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em Library search paths: /usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin20/10.2.0 /usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10 /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib Framework search paths: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/
thanks FX.. That single patch is definitely "necessary, but not sufficient". .. AFAIK, the critical patches have been already applied to the 10.x branch (there were several) - but I'll run a check on macOS 11 with the current branch - and then short-list what you need to fix it...
*** Bug 98812 has been marked as a duplicate of this bug. ***
(In reply to Iain Sandoe from comment #6) > thanks FX.. > > That single patch is definitely "necessary, but not sufficient". > > .. AFAIK, the critical patches have been already applied to the 10.x branch > (there were several) - but I'll run a check on macOS 11 with the current > branch - and then short-list what you need to fix it... current 10.x branch "works for me" ... homebrew might want to consider these: c85bc938ccf Darwin : Update libtool and dependencies for Darwin20 [PR97865] 7b19b6b1536 Darwin, libsanitizer : Support libsanitizer for x86_64-darwin20. 82abd13fb66 Darwin : Adjust handling of MACOSX_DEPLOYMENT_TARGET for macOS 11. f5ee16a0d8e Darwin : Update the kernel version to macOS version mapping. 24957662c67 Darwin: Darwin 20 is to be macOS 11 (Big Sur). d0bae0b218d Darwin: Adjust the PCH area to allow for 16384byte page size. (optional) e731714eb2b libobjc, Darwin : Fix powerpc encoding regression. (optional) c1d7709ec68 Darwin, libgfortran : Do not use environ directly from the library. This is fixed for the next release (we discussed making a special, but I'd say the effort of a darwin-specific release now probably doesn't warrant it - 10.3 is probably a month or so away). Better just to update the band-aid (and note that it's also needed for any other 10.x back ports).