CMake: Allow opting out of Intel CET hardening
Some Qt internal targets might not work correctly when built with Intel CET hardening. Add a per-target opt out to skip adding the Intel CET flags. Task-number: QTBUG-127464 Change-Id: I1a28b228a82b3505d987649eec6db08281c15482 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit c5e42a9d2faef611e3a6d124d5b093670346fb87) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
873bacc549
commit
551e01c124
@ -235,6 +235,7 @@ function(qt_internal_apply_gc_binaries target visibility)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Only applied to Bootstrap and BundledPCRE2.
|
||||
function(qt_internal_apply_intel_cet target visibility)
|
||||
if(NOT QT_FEATURE_intelcet)
|
||||
return()
|
||||
@ -254,10 +255,36 @@ function(qt_internal_apply_intel_cet target visibility)
|
||||
">:-mshstk>")
|
||||
endif()
|
||||
if(flags)
|
||||
set(opt_out_condition "$<NOT:$<BOOL:$<TARGET_PROPERTY:_qt_no_intel_cet_harderning>>>")
|
||||
set(flags "$<${opt_out_condition}:${flags}>")
|
||||
target_compile_options("${target}" ${visibility} "${flags}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Meant to be applied to PlatformCommonInternal.
|
||||
function(qt_internal_apply_intel_cet_harderning target)
|
||||
if(NOT QT_FEATURE_intelcet)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(opt_out_condition "$<NOT:$<BOOL:$<TARGET_PROPERTY:_qt_no_intel_cet_harderning>>>")
|
||||
|
||||
if(MSVC)
|
||||
set(intel_cet_flag "-CETCOMPAT")
|
||||
set(condition "$<${opt_out_condition}:${intel_cet_flag}>")
|
||||
qt_internal_platform_link_options("${target}" INTERFACE "${condition}")
|
||||
else()
|
||||
set(intel_cet_flag "-fcf-protection=full")
|
||||
set(condition "$<${opt_out_condition}:${intel_cet_flag}>")
|
||||
target_compile_options("${target}" INTERFACE "${condition}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Allow opting out of the Intel CET hardening on a per-target basis.
|
||||
function(qt_internal_skip_intel_cet_hardening target)
|
||||
set_target_properties("${target}" PROPERTIES _qt_no_intel_cet_harderning TRUE)
|
||||
endfunction()
|
||||
|
||||
# Sets the exceptions flags for the given target according to exceptions_on
|
||||
function(qt_internal_set_exceptions_flags target exceptions_on)
|
||||
set(_defs "")
|
||||
|
@ -311,13 +311,8 @@ if (GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "9.2")
|
||||
endif()
|
||||
|
||||
# Hardening options
|
||||
if(QT_FEATURE_intelcet)
|
||||
if(MSVC)
|
||||
qt_internal_platform_link_options(PlatformCommonInternal INTERFACE -CETCOMPAT)
|
||||
else()
|
||||
target_compile_options(PlatformCommonInternal INTERFACE -fcf-protection=full)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
qt_internal_apply_intel_cet_harderning(PlatformCommonInternal)
|
||||
|
||||
if(QT_FEATURE_glibc_fortify_source)
|
||||
set(is_optimized_build "$<OR:$<NOT:$<CONFIG:Debug>>,$<BOOL:${QT_FEATURE_optimize_debug}>>")
|
||||
|
Loading…
x
Reference in New Issue
Block a user