Build system: Allow user to enable Intel CET

MSVC:
https://docs.microsoft.com/en-us/cpp/build/reference/guard-enable-eh-continuation-metadata?view=msvc-170
https://docs.microsoft.com/en-us/cpp/build/reference/cetcompat?view=msvc-170

GCC:
https://gcc.gnu.org/onlinedocs/gcc-11.2.0/gcc/Instrumentation-Options.html

Clang:
Don't know where's the documentation but should use
the same parameter with GCC.

Change-Id: I654618e45743a5ad1394c930932b9d0044572725
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Yuhang Zhao 2021-11-19 10:29:27 +08:00
parent dbae10487e
commit 42287255d3
4 changed files with 19 additions and 1 deletions

View File

@ -278,6 +278,21 @@ if (GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "9.2")
target_compile_options(PlatformCommonInternal INTERFACE $<$<COMPILE_LANGUAGE:CXX>:-Wsuggest-override>)
endif()
if(QT_FEATURE_intelcet)
if(MSVC)
target_compile_options(PlatformCommonInternal INTERFACE
-guard:ehcont
)
target_link_options(PlatformCommonInternal INTERFACE
-guard:ehcont -CETCOMPAT
)
else()
target_compile_options(PlatformCommonInternal INTERFACE
-fcf-protection
)
endif()
endif()
if(QT_FEATURE_force_asserts)
target_compile_definitions(PlatformCommonInternal INTERFACE QT_FORCE_ASSERTS)
endif()

View File

@ -137,6 +137,7 @@ Build options:
-pch ................. Use precompiled headers [auto]
-ltcg ................ Use Link Time Code Generation [no]
-intelcet ............ Use Intel Control-flow Enforcement Technology [no]
-linker [bfd,gold,lld,mold]
Force use of the GNU ld, GNU gold, LLVM/LLD or mold
linker instead of default one (GCC and clang only)

View File

@ -1034,7 +1034,7 @@ qt_feature("relocatable" PRIVATE
)
qt_feature("intelcet" PRIVATE
LABEL "Using Intel CET"
CONDITION TEST_intelcet
CONDITION ( INPUT_intelcet STREQUAL yes ) OR TEST_intelcet
)
qt_configure_add_summary_build_type_and_config()
qt_configure_add_summary_section(NAME "Build options")
@ -1085,6 +1085,7 @@ qt_configure_add_summary_entry(
qt_configure_add_summary_entry(ARGS "relocatable")
qt_configure_add_summary_entry(ARGS "precompile_header")
qt_configure_add_summary_entry(ARGS "ltcg")
qt_configure_add_summary_entry(ARGS "intelcet")
qt_configure_add_summary_section(NAME "Target compiler supports")
qt_configure_add_summary_entry(
TYPE "featureList"

View File

@ -67,6 +67,7 @@ qt_commandline_option(incredibuild-xge TYPE boolean NAME incredibuild_xge)
qt_commandline_option(libudev TYPE boolean)
qt_commandline_option(linker TYPE optionalString VALUES bfd gold lld mold)
qt_commandline_option(ltcg TYPE boolean)
qt_commandline_option(intelcet TYPE boolean)
# special case begin
qt_commandline_option(make TYPE addString VALUES examples libs tests tools
benchmarks manual-tests minimal-static-tests)