This does not currently work properly, and will cause GCC to terminate while compiling for Windows. This affects x86_64-w64-mingw32-g++
8 through 10. Related upstream issue: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90458.
I’ve PR’d this separate to #18921, as this doesn’t have to wait for us to decide if we want to opt-in to using those flags on other platforms, and is causing build failures.
While doing more testing for #18921, I (and the bot) saw build issues that would terminate GCC:
0 CXX bitcoind-bitcoind.o
1during RTL pass: final
2In file included from ./logging.h:10,
3 from ./util/system.h:21,
4 from ./init.h:11,
5 from bitcoind.cpp:13:
6./tinyformat.h: In static member function 'static int tinyformat::detail::FormatArg::toIntImpl(const void*) [with T = std::__cxx11::basic_string<char>]':
7./tinyformat.h:550:9: internal compiler error: in seh_emit_stackalloc, at config/i386/winnt.c:1043
8 }
9 ^
100x7fa20389609a __libc_start_main
11 ../csu/libc-start.c:308
12Please submit a full bug report,
13with preprocessed source if appropriate.
14Please include the complete backtrace with any bug report.
15See <https://gcc.gnu.org/bugs/> for instructions.
16{standard input}: Assembler messages:
17{standard input}: Error: open SEH entry at end of file (missing .seh_endproc)
Here’s a fairly minimal test case, that will cause the issue using -fstack-clash-protection -O1
:
0#include <stdexcept>
1
2// tested with
3// x86_64-w64-mingw32-g++ (GCC) 8.3-posix 20190406 (Debian)
4// x86_64-w64-mingw32-g++ (GCC) 9.3.0 (macOS)
5// x86_64-w64-mingw32-g++ (GCC) 10-posix 20200525 (Debian)
6
7class _error: public std::runtime_error {
8public:
9 _error(const std::string &what): std::runtime_error(what) {}
10};
11
12void crash() {
13 throw _error("Some crash!");
14}
15
16int main() {
17 crash();
18 return 0;
19}
0x86_64-w64-mingw32-g++ test.cpp -fstack-clash-protection -O1
1
2Using built-in specs.
3COLLECT_GCC=x86_64-w64-mingw32-g++
4COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-w64-mingw32/10-posix/lto-wrapper
5Target: x86_64-w64-mingw32
6Configured with: ../../src/configure --build=x86_64-linux-gnu --prefix=/usr --includedir='/usr/include' --mandir='/usr/share/man' --infodir='/usr/share/info' --sysconfdir=/etc --localstatedir=/var --disable-option-checking --disable-silent-rules --libdir='/usr/lib/x86_64-linux-gnu' --libexecdir='/usr/lib/x86_64-linux-gnu' --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --enable-shared --enable-static --disable-multilib --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --libdir=/usr/lib --enable-libstdcxx-time=yes --with-tune=generic --with-headers=/usr/x86_64-w64-mingw32/include --enable-version-specific-runtime-libs --enable-fully-dynamic-string --enable-libgomp --enable-languages=c,c++,fortran,objc,obj-c++,ada --enable-lto --enable-threads=posix --program-suffix=-posix --program-prefix=x86_64-w64-mingw32- --target=x86_64-w64-mingw32 --with-as=/usr/bin/x86_64-w64-mingw32-as --with-ld=/usr/bin/x86_64-w64-mingw32-ld --enable-libatomic --enable-libstdcxx-filesystem-ts=yes --enable-dependency-tracking
7Thread model: posix
8Supported LTO compression algorithms: zlib
9gcc version 10-posix 20200525 (GCC)
10COLLECT_GCC_OPTIONS='-fstack-clash-protection' '-O1' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
11 /usr/lib/gcc/x86_64-w64-mingw32/10-posix/cc1plus -quiet -v -D_REENTRANT test.cpp -quiet -dumpbase test.cpp -mtune=generic -march=x86-64 -auxbase test -O1 -version -fstack-clash-protection -o /tmp/ccer6MYu.s
12GNU C++14 (GCC) version 10-posix 20200525 (x86_64-w64-mingw32)
13 compiled by GNU C version 10.1.0, GMP version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.22.1-GMP
14
15GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
16ignoring nonexistent directory "/usr/lib/gcc/x86_64-w64-mingw32/10-posix/../../../../x86_64-w64-mingw32/sys-include"
17#include "..." search starts here:
18#include <...> search starts here:
19 /usr/lib/gcc/x86_64-w64-mingw32/10-posix/include/c++
20 /usr/lib/gcc/x86_64-w64-mingw32/10-posix/include/c++/x86_64-w64-mingw32
21 /usr/lib/gcc/x86_64-w64-mingw32/10-posix/include/c++/backward
22 /usr/lib/gcc/x86_64-w64-mingw32/10-posix/include
23 /usr/lib/gcc/x86_64-w64-mingw32/10-posix/include-fixed
24 /usr/lib/gcc/x86_64-w64-mingw32/10-posix/../../../../x86_64-w64-mingw32/include
25End of search list.
26GNU C++14 (GCC) version 10-posix 20200525 (x86_64-w64-mingw32)
27 compiled by GNU C version 10.1.0, GMP version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.22.1-GMP
28
29GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
30Compiler executable checksum: c42c71f75c7bf48c403bd1b5d143d4a1
31during RTL pass: final
32test.cpp: In function 'int main()':
33test.cpp:17:1: internal compiler error: in seh_emit_stackalloc, at config/i386/winnt.c:1043
34 17 | }
35 | ^
36Please submit a full bug report,
37with preprocessed source if appropriate.
38See <https://gcc.gnu.org/bugs/> for instructions.