Skip to content

Commit 00076d9

Browse files
committed
don't pass -fstack-clash-protection to mingw when building onetbb
GCC 10.4 aborts compiling oneTBB's task_dispatcher.h with the flag on: internal compiler error: in seh_emit_stackalloc, at config/i386/winnt.c:1056 370 | do_throw_noexcept([] { throw; }); a known GCC defect on mingw's SEH targets. It is a hardening flag rather than a correctness one, so leave it off there. Also fold the earlier /dev/null fix into a single patches/mingw_gnu_cmake.diff, as both make oneTBB's GNU.cmake usable for a native mingw build.
1 parent 3925e0d commit 00076d9

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/src/tbb/cmake/compilers/GNU.cmake b/src/tbb/cmake/compilers/GNU.cmake
2-
index cf6d8bdb..4c5e43a9 100644
2+
index cf6d8bdb..bc86acc1 100644
33
--- a/src/tbb/cmake/compilers/GNU.cmake
44
+++ b/src/tbb/cmake/compilers/GNU.cmake
55
@@ -47,19 +47,42 @@ endif()
@@ -46,3 +46,19 @@ index cf6d8bdb..4c5e43a9 100644
4646
message(TRACE "Extracted GNU assembler version: major=${_tbb_gnu_asm_major_version} minor=${_tbb_gnu_asm_minor_version}")
4747

4848
math(EXPR _tbb_gnu_asm_version_number "${_tbb_gnu_asm_major_version} * 1000 + ${_tbb_gnu_asm_minor_version}")
49+
@@ -81,7 +104,14 @@ endif()
50+
if (NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL Intel)
51+
# gcc 6.0 and later have -flifetime-dse option that controls elimination of stores done outside the object lifetime
52+
set(TBB_DSE_FLAG $<$<NOT:$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},6.0>>:-flifetime-dse=1>)
53+
- set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} $<$<NOT:$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},8.0>>:-fstack-clash-protection>)
54+
+
55+
+ # -fstack-clash-protection is broken on mingw's SEH targets: compiling
56+
+ # task_dispatcher.h makes GCC 10 abort with "internal compiler error: in
57+
+ # seh_emit_stackalloc, at config/i386/winnt.c". It is a hardening flag
58+
+ # rather than a correctness one, so simply leave it off there.
59+
+ if (NOT MINGW)
60+
+ set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} $<$<NOT:$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},8.0>>:-fstack-clash-protection>)
61+
+ endif()
62+
63+
# Suppress GCC 12.x-13.x warning here that to_wait_node(n)->my_is_in_list might have size 0
64+
set(TBB_COMMON_LINK_FLAGS ${TBB_COMMON_LINK_FLAGS} $<$<AND:$<NOT:$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},12.0>>,$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},14.0>>:-Wno-stringop-overflow>)

src/tbb/cmake/compilers/GNU.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,14 @@ endif()
104104
if (NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL Intel)
105105
# gcc 6.0 and later have -flifetime-dse option that controls elimination of stores done outside the object lifetime
106106
set(TBB_DSE_FLAG $<$<NOT:$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},6.0>>:-flifetime-dse=1>)
107-
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} $<$<NOT:$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},8.0>>:-fstack-clash-protection>)
107+
108+
# -fstack-clash-protection is broken on mingw's SEH targets: compiling
109+
# task_dispatcher.h makes GCC 10 abort with "internal compiler error: in
110+
# seh_emit_stackalloc, at config/i386/winnt.c". It is a hardening flag
111+
# rather than a correctness one, so simply leave it off there.
112+
if (NOT MINGW)
113+
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} $<$<NOT:$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},8.0>>:-fstack-clash-protection>)
114+
endif()
108115

109116
# Suppress GCC 12.x-13.x warning here that to_wait_node(n)->my_is_in_list might have size 0
110117
set(TBB_COMMON_LINK_FLAGS ${TBB_COMMON_LINK_FLAGS} $<$<AND:$<NOT:$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},12.0>>,$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},14.0>>:-Wno-stringop-overflow>)

0 commit comments

Comments
 (0)