From 4215c944ffa598ef1121154b70e60affcbf0de8f Mon Sep 17 00:00:00 2001 From: Yuhang Zhao Date: Wed, 17 May 2023 18:03:16 +0800 Subject: [PATCH] update --- utils.cmake | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/utils.cmake b/utils.cmake index 4c9b1af..718a3ed 100644 --- a/utils.cmake +++ b/utils.cmake @@ -543,19 +543,13 @@ function(setup_compile_params) endif() endif() else() + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # Use pipes for communicating between sub-processes. Faster. Have no effect for Clang. + target_compile_options(${__target} PRIVATE -pipe) + endif() target_compile_options(${__target} PRIVATE - -pipe # Use pipes for communicating between sub-processes. Faster. Have no effect for Clang. $<$>:-ffp-contract=fast -fomit-frame-pointer -ffunction-sections -fdata-sections> ) - target_link_options(${__target} PRIVATE - $<$>:-Wl,--icf=all> # Is it supported by other linkers than LLD? - ) - #[[target_compile_options(${__target} PRIVATE - $<$>:-fsanitize=shadow-call-stack -fno-stack-protector> - ) - target_link_options(${__target} PRIVATE - $<$>:-fsanitize=shadow-call-stack -fno-stack-protector> - )]] if(APPLE) target_link_options(${__target} PRIVATE -Wl,-fatal_warnings @@ -574,7 +568,7 @@ function(setup_compile_params) endif() if(COM_ARGS_INTELCET) target_compile_options(${__target} PRIVATE - $<$>:-mshstk -fcf-protection=full> + $<$>:-mshstk> ) endif() if(COM_ARGS_CFGUARD) @@ -589,24 +583,19 @@ function(setup_compile_params) target_compile_options(${__target} PRIVATE $<$>:-fcf-protection=full> ) - else() - target_compile_options(${__target} PRIVATE - $<$>:-fsanitize=cfi -fsanitize-cfi-cross-dso> - ) endif() endif() if(COM_ARGS_SPECTRE) if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - target_compile_options(${__target} PRIVATE + #[[target_compile_options(${__target} PRIVATE $<$>: # These parameters are not compatible with -fcf-protection=full - #[[-mindirect-branch=thunk + -mindirect-branch=thunk -mfunction-return=thunk -mindirect-branch-register - -mindirect-branch-cs-prefix]] - -fcf-protection=full + -mindirect-branch-cs-prefix > - ) + )]] endif() endif() endif() @@ -634,6 +623,15 @@ function(setup_compile_params) ) endif() endif() + target_link_options(${__target} PRIVATE + $<$>:-Wl,--icf=all> + ) + #[[target_compile_options(${__target} PRIVATE + $<$>:-fsanitize=shadow-call-stack -fno-stack-protector> + ) + target_link_options(${__target} PRIVATE + $<$>:-fsanitize=shadow-call-stack -fno-stack-protector> + )]] target_compile_options(${__target} PRIVATE -fcolor-diagnostics # Enable -fmerge-all-constants. This used to be the default in clang @@ -706,6 +704,13 @@ function(setup_compile_params) ) endif() endif() + if(COM_ARGS_CFGUARD) + if(NOT APPLE) + target_compile_options(${__target} PRIVATE + $<$>:-fsanitize=cfi -fsanitize-cfi-cross-dso> + ) + endif() + endif() endif() endif() endforeach()