summaryrefslogtreecommitdiffstats
path: root/mkspecs
diff options
context:
space:
mode:
authorYuhang Zhao <2546789017@qq.com>2020-11-03 12:02:01 +0800
committerYuhang Zhao <2546789017@qq.com>2020-12-07 22:25:43 +0800
commit886db3a2f3600d15ceb2447c9502f20ce9b3f000 (patch)
treef81e6f88a67b0fabb1f43a5660daa2823dd1ea1a /mkspecs
parent509c25752112583e6bc997e8c9442f6b69136816 (diff)
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>
Diffstat (limited to 'mkspecs')
-rw-r--r--mkspecs/features/qt_module.prf9
1 files changed, 9 insertions, 0 deletions
diff --git a/mkspecs/features/qt_module.prf b/mkspecs/features/qt_module.prf
index 3cacc8dfde..62d225b14d 100644
--- a/mkspecs/features/qt_module.prf
+++ b/mkspecs/features/qt_module.prf
@@ -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