summaryrefslogtreecommitdiffstats
path: root/tools/qmake/mkspecs/features/functions.prf
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2016-04-06 12:50:01 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2016-11-22 09:13:12 +0000
commit052dfd8eae73a495c93488af2829252f3a537a40 (patch)
tree6f48f16d85617bc1bf1c4bf312d735531ed88ffd /tools/qmake/mkspecs/features/functions.prf
parentda1d5274616d026e410f7e39c6b1ec8886bb7be5 (diff)
Add support for compiling WebEngine with Clang sanitizer options
This change pipes the already supported Qt sanitize options to Chromium, so the Chromium build system adds the correct compiler sanitizer flags. The change also checks whether the requirements to build a sanitizer enabled Chromium are met (currently works properly on macOS with an Apple clang >= 7.3.1, and on Linux with clang + libc++). Change-Id: Ibab2d5735935ddc92226575fc0e9f5912b807329 Task-number: QTBUG-52656 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tools/qmake/mkspecs/features/functions.prf')
-rw-r--r--tools/qmake/mkspecs/features/functions.prf101
1 files changed, 101 insertions, 0 deletions
diff --git a/tools/qmake/mkspecs/features/functions.prf b/tools/qmake/mkspecs/features/functions.prf
index 047f887d1..6ee9be57d 100644
--- a/tools/qmake/mkspecs/features/functions.prf
+++ b/tools/qmake/mkspecs/features/functions.prf
@@ -76,6 +76,7 @@ defineTest(isPlatformSupported) {
}
!isPythonVersionSupported(): return(false)
!isArchSupported(): return(false)
+ isSanitizerEnabled():!isSanitizerSupported():!forceSanitizerBuild(): return(false)
return(true)
}
@@ -107,6 +108,106 @@ defineTest(isPythonVersionSupported) {
return(false)
}
+defineTest(isSanitizerEnabled) {
+ sanitize_address|sanitize_memory|sanitize_undefined|sanitize_thread: return(true)
+ return(false)
+}
+
+defineTest(forceSanitizerBuild) {
+ contains(WEBENGINE_CONFIG, force_sanitizer_build): return(true)
+ skipBuild("Chosen sanitizer configuration is not supported. Use WEBENGINE_CONFIG+=force_sanitizer_build to force build with the chosen sanitizer configuration.")
+ return(false)
+}
+
+defineTest(isSanitizerSupported) {
+ sanitizer_combo_supported = true
+ sanitize_address {
+ asan_supported = false
+ linux-clang-libc++:isSanitizerSupportedOnLinux() {
+ asan_supported = true
+ } else:macos:isSanitizerSupportedOnMacOS() {
+ asan_supported = true
+ }
+ !$$asan_supported {
+ sanitizer_combo_supported = false
+ warning("An address sanitizer-enabled Qt WebEngine build can only be built on Linux or macOS using Clang and libc++.")
+ }
+ }
+
+ sanitize_memory {
+ sanitizer_combo_supported = false
+ warning("A memory sanitizer-enabled Qt WebEngine build is not supported.")
+ }
+
+ sanitize_undefined {
+ ubsan_supported = false
+ linux-clang-libc++:isSanitizerSupportedOnLinux():CONFIG(release, debug|release):!debug_and_release {
+ ubsan_supported = true
+ }
+ !$$ubsan_supported {
+ sanitizer_combo_supported = false
+ warning("An undefined behavior sanitizer-enabled Qt WebEngine build can only be built on Linux using Clang and libc++ in release mode.")
+ }
+ }
+
+ sanitize_thread {
+ tsan_supported = false
+ linux-clang-libc++:isSanitizerSupportedOnLinux() {
+ tsan_supported = true
+ }
+ !$$tsan_supported {
+ sanitizer_combo_supported = false
+ warning("A thread sanitizer-enabled Qt WebEngine build can only be built on Linux using Clang and libc++.")
+ }
+ }
+
+ $$sanitizer_combo_supported: return(true)
+ return(false)
+}
+
+defineTest(isSanitizerSupportedOnLinux) {
+ isSanitizerLinuxClangVersionSupported(): return(true)
+ return(false)
+}
+
+defineTest(isSanitizerSupportedOnMacOS) {
+ isEmpty(QT_APPLE_CLANG_MAJOR_VERSION) {
+ QTWEBENGINE_CLANG_IS_APPLE = false
+ } else {
+ QTWEBENGINE_CLANG_IS_APPLE = true
+ }
+ $$QTWEBENGINE_CLANG_IS_APPLE:isSanitizerMacOSAppleClangVersionSupported(): return(true)
+ else:isSanitizerMacOSClangVersionSupported(): return(true)
+ return(false)
+}
+
+defineTest(isSanitizerMacOSAppleClangVersionSupported) {
+ # Clang sanitizer suppression attributes work from Apple Clang version 7.3.0+.
+ greaterThan(QT_APPLE_CLANG_MAJOR_VERSION, 7): return(true)
+ greaterThan(QT_APPLE_CLANG_MINOR_VERSION, 2): return(true)
+
+ warning("Using Apple Clang version $${QT_APPLE_CLANG_MAJOR_VERSION}.$${QT_APPLE_CLANG_MINOR_VERSION}.$${QT_APPLE_CLANG_PATCH_VERSION}, but at least Apple Clang version 7.3.0 is required to build a sanitizer-enabled Qt WebEngine.")
+ return(false)
+}
+
+defineTest(isSanitizerMacOSClangVersionSupported) {
+ # Clang sanitizer suppression attributes work from non-apple Clang version 3.7+.
+ greaterThan(QT_CLANG_MAJOR_VERSION, 3): return(true)
+ greaterThan(QT_CLANG_MINOR_VERSION, 6): return(true)
+
+ warning("Using Clang version $${QT_CLANG_MAJOR_VERSION}.$${QT_CLANG_MINOR_VERSION}, but at least Clang version 3.7 is required to build a sanitizer-enabled Qt WebEngine.")
+ return(false)
+}
+
+defineTest(isSanitizerLinuxClangVersionSupported) {
+ # Clang sanitizer suppression attributes work from Clang version 3.7+.
+ greaterThan(QT_CLANG_MAJOR_VERSION, 3): return(true)
+ greaterThan(QT_CLANG_MINOR_VERSION, 6): return(true)
+
+ warning("Using Clang version $${QT_CLANG_MAJOR_VERSION}.$${QT_CLANG_MINOR_VERSION}, but at least Clang version 3.7 is required to build a sanitizer-enabled Qt WebEngine.")
+ return(false)
+}
+
defineTest(isGCCVersionSupported) {
# The below will work for gcc 4.7 and up and also match gcc 5
greaterThan(QT_GCC_MINOR_VERSION, 6):return(true)