Skip to content

Commit

Permalink
Build system: Allow user to enable Intel CET
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Thiago Macieira <[email protected]>
  • Loading branch information
wangwenx190 committed Apr 6, 2022
1 parent dbae104 commit 4228725
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
15 changes: 15 additions & 0 deletions cmake/QtInternalTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions config_help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions qt_cmdline.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4228725

Please sign in to comment.