From 6347e3195c6934c0f3aa4668a55a285336dd407a Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Wed, 13 Sep 2017 11:09:20 +0200 Subject: Move webengine sanitizer option to new configure system Use new configure system to enable sanitizer. Change-Id: I633bc96973b9b9bcd56c4ef03a589e147215dc86 Reviewed-by: Allan Sandfeld Jensen --- configure.json | 10 ++++ configure.pri | 89 ++++++++++++++++++++++++++++++++++++ mkspecs/features/configure.prf | 5 ++ mkspecs/features/functions.prf | 101 ----------------------------------------- 4 files changed, 104 insertions(+), 101 deletions(-) diff --git a/configure.json b/configure.json index 900fbf854..76327d9c1 100644 --- a/configure.json +++ b/configure.json @@ -240,6 +240,10 @@ "icuuc": { "label" : "libxml2 configured with icuuc", "type": "detectIcuuc" + }, + "sanitizer": { + "label" : "sanitizer support", + "type": "isSanitizerSupported" } }, @@ -498,6 +502,12 @@ "label": "libxml2 and libxslt", "condition": "config.unix && libs.libxml2 && tests.icuuc", "output": [ "privateFeature" ] + }, + "webengine-sanitizer" : { + "label": "Sanitizer ", + "autoDetect": "config.sanitizer && tests.sanitizer", + "condition": "config.sanitizer", + "output": [ "privateFeature" ] } }, diff --git a/configure.pri b/configure.pri index 549b1efd0..c88d4964b 100644 --- a/configure.pri +++ b/configure.pri @@ -156,3 +156,92 @@ defineTest(qtConfTest_detectIcuuc) { } return(false) } + +defineTest(qtConfTest_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 + qtLog("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 + qtLog("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 + qtLog("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 + qtLog("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) + + qtLog("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) + + qtLog("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) + + qtLog("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) +} diff --git a/mkspecs/features/configure.prf b/mkspecs/features/configure.prf index 79b54daba..e21767565 100644 --- a/mkspecs/features/configure.prf +++ b/mkspecs/features/configure.prf @@ -53,6 +53,11 @@ defineTest(runConfigure) { qtConfig(embedded): WEBENGINE_CONFIG += reduce_binary_size } + sanitizer: !qtConfig(webengine-sanitizer) { + skipBuild("Chosen sanitizer configuration is not supported. Use --feature-webengine-sanitizer=yes to force build with the chosen sanitizer configuration.") + return(false); + } + linux { !qtConfig(system-glibc) { skipBuild("A suitable version of libc could not be found. See: https://sourceware.org/bugzilla/show_bug.cgi?id=14898") diff --git a/mkspecs/features/functions.prf b/mkspecs/features/functions.prf index 7ee471956..ed527d4f2 100644 --- a/mkspecs/features/functions.prf +++ b/mkspecs/features/functions.prf @@ -74,7 +74,6 @@ defineTest(isPlatformSupported) { return(false) } !isArchSupported(): return(false) - isSanitizerEnabled():!isSanitizerSupported():!forceSanitizerBuild(): return(false) return(true) } @@ -88,106 +87,6 @@ defineTest(isArchSupported) { 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) -- cgit v1.2.3