Added Memory Sanitizer.

This commit is contained in:
Roman Telezhynskyi 2023-07-25 14:03:39 +03:00
parent d1cbb61238
commit 809186b8f5

View File

@ -6,6 +6,7 @@ Module {
property bool frameworksBuild: qbs.targetOS.contains("macos") && !staticBuild property bool frameworksBuild: qbs.targetOS.contains("macos") && !staticBuild
property bool enableAddressSanitizer: false property bool enableAddressSanitizer: false
property bool enableMemorySanitizer: false
property bool enableUbSanitizer: false property bool enableUbSanitizer: false
property bool enableThreadSanitizer: false property bool enableThreadSanitizer: false
@ -799,9 +800,13 @@ Module {
cpp.cxxFlags: { cpp.cxxFlags: {
var flags = debugFlags; 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"); 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")) if (qbs.toolchain.contains("msvc"))
flags.push("/utf-8"); flags.push("/utf-8");
return flags; return flags;
@ -848,11 +853,13 @@ Module {
} }
Properties { Properties {
condition: qbs.toolchain.contains("gcc") condition: qbs.toolchain.contains("gcc") || qbs.toolchain.contains("clang")
cpp.driverFlags: { cpp.driverFlags: {
var flags = []; var flags = [];
if (enableAddressSanitizer) if (enableAddressSanitizer)
flags.push("-fsanitize=address"); flags.push("-fsanitize=address");
if (enableMemorySanitizer)
flags.push("-fsanitize=memory");
if (enableUbSanitizer) if (enableUbSanitizer)
flags.push("-fsanitize=undefined"); flags.push("-fsanitize=undefined");
if (enableThreadSanitizer) if (enableThreadSanitizer)