From 809186b8f53d092a702799303b16edfa815b379e Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 25 Jul 2023 14:03:39 +0300 Subject: [PATCH] Added Memory Sanitizer. --- qbs/modules/buildconfig/buildconfig.qbs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/qbs/modules/buildconfig/buildconfig.qbs b/qbs/modules/buildconfig/buildconfig.qbs index 168634167..73108c58a 100644 --- a/qbs/modules/buildconfig/buildconfig.qbs +++ b/qbs/modules/buildconfig/buildconfig.qbs @@ -6,6 +6,7 @@ Module { property bool frameworksBuild: qbs.targetOS.contains("macos") && !staticBuild property bool enableAddressSanitizer: false + property bool enableMemorySanitizer: false property bool enableUbSanitizer: false property bool enableThreadSanitizer: false @@ -799,9 +800,13 @@ Module { cpp.cxxFlags: { var flags = debugFlags; - if (qbs.toolchain.contains("gcc") && enableAddressSanitizer) + if ((qbs.toolchain.contains("gcc") || qbs.toolchain.contains("clang")) && + (enableAddressSanitizer || enableMemorySanitizer)) flags.push("-fno-omit-frame-pointer"); + if ((qbs.toolchain.contains("gcc") || qbs.toolchain.contains("clang")) && enableMemorySanitizer) + flags.push("-fPIE", "-pie", "-fsanitize-memory-track-origins"); + if (qbs.toolchain.contains("msvc")) flags.push("/utf-8"); return flags; @@ -848,11 +853,13 @@ Module { } Properties { - condition: qbs.toolchain.contains("gcc") + condition: qbs.toolchain.contains("gcc") || qbs.toolchain.contains("clang") cpp.driverFlags: { var flags = []; if (enableAddressSanitizer) flags.push("-fsanitize=address"); + if (enableMemorySanitizer) + flags.push("-fsanitize=memory"); if (enableUbSanitizer) flags.push("-fsanitize=undefined"); if (enableThreadSanitizer)