MSVC: Enable control flow guard for release builds
This makes the applications and libraries more safe and won't cause any binary incompatibility. It's not supported for MSVC 2015, but since we only support MSVC 2019 or later in Qt6, it's safe to use this parameter. The "-guard:cf" parameter is supported by clang-cl and intel-cl as well, MinGW doesn't support it. [1] https://docs.microsoft.com/en-us/cpp/build/reference/guard-enable-control-flow-guard?view=msvc-160 [2] https://docs.microsoft.com/en-us/cpp/build/reference/guard-enable-guard-checks?view=msvc-160 Change-Id: I7b035b4b0f22617a7f3c067cddde0bed2e13dd1c Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
509c257521
commit
886db3a2f3
@ -167,7 +167,7 @@ if (MSVC)
|
||||
-FS
|
||||
-Zc:rvalueCast
|
||||
-Zc:inline
|
||||
)
|
||||
)
|
||||
endif()
|
||||
if (MSVC_VERSION GREATER_EQUAL 1899)
|
||||
target_compile_options(PlatformCommonInternal INTERFACE
|
||||
@ -192,9 +192,13 @@ if (MSVC)
|
||||
|
||||
target_compile_options(PlatformCommonInternal INTERFACE -Zc:wchar_t)
|
||||
|
||||
target_compile_options(PlatformCommonInternal INTERFACE
|
||||
$<$<NOT:$<CONFIG:Debug>>:-guard:cf>
|
||||
)
|
||||
|
||||
target_link_options(PlatformCommonInternal INTERFACE
|
||||
-DYNAMICBASE -NXCOMPAT
|
||||
$<$<NOT:$<CONFIG:Debug>>:-OPT:REF -OPT:ICF>
|
||||
$<$<NOT:$<CONFIG:Debug>>:-OPT:REF -OPT:ICF -GUARD:CF>
|
||||
)
|
||||
endif()
|
||||
|
||||
|
@ -336,4 +336,13 @@ win32 {
|
||||
}
|
||||
DEFINES *= QT_DEPRECATED_WARNINGS_SINCE=0x060000
|
||||
|
||||
msvc {
|
||||
QMAKE_CFLAGS_RELEASE += -guard:cf
|
||||
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -guard:cf
|
||||
QMAKE_CXXFLAGS_RELEASE += -guard:cf
|
||||
QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO += -guard:cf
|
||||
QMAKE_LFLAGS_RELEASE += /GUARD:CF
|
||||
QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO += /GUARD:CF
|
||||
}
|
||||
|
||||
TARGET = $$qt5LibraryTarget($$TARGET$$QT_LIBINFIX) # Do this towards the end
|
||||
|
Loading…
Reference in New Issue
Block a user