blob: 96146a1957341ae08c2acfd93099bcd50f92d71e [file] [log] [blame]
Andrew Geisslerbffdb3e2020-08-21 16:13:29 -05001From 04d5f4805a86302a0e135a28d58a6c1ff6a68d52 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@gmail.com>
3Date: Thu, 30 Jul 2020 23:03:51 +0200
4Subject: [PATCH] Use compiler -fcf-protection only if compiler/arch supports
5 it
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10There have been some PRs they were either rejected or some general suggestion
11for more flags suggested. So
12
13Upstream-Status: Pending
14
15Signed-off-by: Andreas MΓΌller <schnitzeltony@gmail.com>
16---
17 cmake/compilerFlags.cmake | 7 ++++++-
18 1 file changed, 6 insertions(+), 1 deletion(-)
19
20diff --git a/cmake/compilerFlags.cmake b/cmake/compilerFlags.cmake
21index 12caf42..455525e 100644
22--- a/cmake/compilerFlags.cmake
23+++ b/cmake/compilerFlags.cmake
24@@ -26,7 +26,12 @@ if ( MINGW OR UNIX OR MSYS ) # MINGW, Linux, APPLE, CYGWIN
25 # This fails under Fedora, MinGW GCC 8.3.0 and CYGWIN/MSYS 9.3.0
26 if (NOT (MINGW OR CMAKE_HOST_SOLARIS OR CYGWIN OR MSYS) )
27 if (COMPILER_IS_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
28- add_compile_options(-fstack-clash-protection -fcf-protection)
29+ # Gcc does support -fcf-protection on few arches only
30+ CHECK_CXX_COMPILER_FLAG(-fcf-protection COMPILER_SUPPORTS_FCF_PROTECTION)
31+ if (COMPILER_SUPPORTS_FCF_PROTECTION)
32+ add_compile_options(-fcf-protection)
33+ endif()
34+ add_compile_options(-fstack-clash-protection)
35 endif()
36
37 if( (COMPILER_IS_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 5.0) # Not in GCC 4.8
38--
392.21.3
40