summaryrefslogtreecommitdiff
path: root/dev-cpp/tbb/files/tbb-2023.1.0-no-clobber-toolchain.patch
blob: a19b7e365f395632422f3b8fe577730ac6d7a1bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
Strip flags that are set by the Gentoo toolchain.

For -fcf-protection
https://bugs.gentoo.org/965340

For -D_FORTIFY_SOURCE
https://bugs.gentoo.org/922605

--- a/cmake/compilers/Clang.cmake
+++ b/cmake/compilers/Clang.cmake
@@ -74,40 +74,15 @@ endif()
 set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS}
     -Wformat -Wformat-security -Werror=format-security
     $<$<PLATFORM_ID:Windows>:-D_CRT_SECURE_NO_WARNINGS>
-    $<$<NOT:$<PLATFORM_ID:Windows>>:-fPIC>
-    $<$<NOT:$<PLATFORM_ID:Emscripten>>:-fstack-protector-strong>)
-
-if (NOT APPLE AND NOT ANDROID_PLATFORM AND CMAKE_SYSTEM_PROCESSOR MATCHES "(AMD64|amd64|i.86|x86)" AND NOT WIN32)
-    set(TBB_LIB_COMPILE_FLAGS ${TBB_LIB_COMPILE_FLAGS} -fstack-clash-protection)
-    if (NOT EMSCRIPTEN)
-        # Some versions of Clang implicitly set -march=i686 when compiling for x86 and some don't.
-        # -fcf-protection requires i686, so check -fcf-protection explicitly.
-        include(CheckCXXSourceCompiles)
-        set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
-        set(CMAKE_REQUIRED_FLAGS "-fcf-protection=full")
-        check_cxx_source_compiles("int main(int, char*[]) { return 0; }" CF_PROTECTION_FULL_SUPPORTED)
-        unset(CMAKE_TRY_COMPILE_TARGET_TYPE)
-        unset(CMAKE_REQUIRED_FLAGS)
-
-        if (CF_PROTECTION_FULL_SUPPORTED)
-            set(TBB_LIB_COMPILE_FLAGS ${TBB_LIB_COMPILE_FLAGS} -fcf-protection=full)
-        else()
-            message(WARNING "Compiler does not support -fcf-protection=full.")
-        endif()
-    endif()
-endif()
+    $<$<NOT:$<PLATFORM_ID:Windows>>:-fPIC>)
 
 # -z switch is not supported on MacOS and Windows
 if (NOT APPLE AND NOT WIN32)
-    set(TBB_LIB_LINK_FLAGS ${TBB_LIB_LINK_FLAGS} -Wl,-z,relro,-z,now,-z,noexecstack)
+    set(TBB_LIB_LINK_FLAGS ${TBB_LIB_LINK_FLAGS} -Wl,-z,noexecstack)
 endif()
 
 set(TBB_COMMON_LINK_LIBS ${CMAKE_DL_LIBS})
 
-if (NOT CMAKE_CXX_FLAGS MATCHES "_FORTIFY_SOURCE")
-  set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} $<$<NOT:$<CONFIG:Debug>>:-D_FORTIFY_SOURCE=2>)
-endif ()
-
 if (MINGW)
     list(APPEND TBB_COMMON_COMPILE_FLAGS -U__STRICT_ANSI__)
 endif()
--- a/cmake/compilers/GNU.cmake
+++ b/cmake/compilers/GNU.cmake
@@ -106,20 +106,12 @@ endif ()
 
 # Gnu flags to prevent compiler from optimizing out security checks
 set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv)
-set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -Wformat -Wformat-security -Werror=format-security
-    -fstack-protector-strong )
-if (CMAKE_SYSTEM_PROCESSOR MATCHES "(AMD64|amd64|i.86|x86)" AND NOT EMSCRIPTEN)
-    set(TBB_LIB_COMPILE_FLAGS ${TBB_LIB_COMPILE_FLAGS} $<$<NOT:$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},8.0>>:-fcf-protection=full>)
-endif ()
-set(TBB_LIB_COMPILE_FLAGS ${TBB_LIB_COMPILE_FLAGS} $<$<NOT:$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},8.0>>:-fstack-clash-protection>)
+set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -Wformat -Wformat-security -Werror=format-security)
 
 # -z switch is not supported on MacOS and MinGW
 if (NOT APPLE AND NOT MINGW)
-    set(TBB_LIB_LINK_FLAGS ${TBB_LIB_LINK_FLAGS} -Wl,-z,relro,-z,now,-z,noexecstack)
+    set(TBB_LIB_LINK_FLAGS ${TBB_LIB_LINK_FLAGS} -Wl,-z,noexecstack)
 endif()
-if (NOT CMAKE_CXX_FLAGS MATCHES "_FORTIFY_SOURCE")
-  set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} $<$<NOT:$<CONFIG:Debug>>:-D_FORTIFY_SOURCE=2> )
-endif ()
 
 if (TBB_FILE_TRIM AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8 AND NOT CMAKE_CXX_COMPILER_ID MATCHES "Intel")
     set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -ffile-prefix-map=${NATIVE_TBB_PROJECT_ROOT_DIR}/= -ffile-prefix-map=${NATIVE_TBB_RELATIVE_BIN_PATH}/=)