diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-05-24 03:23:50 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-06 07:39:32 +0200 |
commit | 25601fbac722b9af61ebaf69014e4b73517aaf94 (patch) | |
tree | a89ed3fe91e1aae153e832f1362c5765e064f533 /backend | |
parent | 2cee880ef4ba9f4369b7e464eec87c4fec55d7fc (diff) |
Add sanitize build/test option, currently ignored if gcc is not used
Diffstat (limited to 'backend')
-rw-r--r-- | backend/ninja/Ninja.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp index 35922ee..c72c99f 100644 --- a/backend/ninja/Ninja.cpp +++ b/backend/ninja/Ninja.cpp @@ -722,12 +722,17 @@ namespace backend switch (config.getOptimizationLevel()) { case OPT_LEV_DEBUG: - result += " -g3 -D_FORTIFY_SOURCE=2 -D_GLIBCXX_ASSERTIONS -fasynchronous-unwind-tables -fsanitize=address -fsanitize=undefined "; + result += " -g3 -D_FORTIFY_SOURCE=2 -D_GLIBCXX_ASSERTIONS -fasynchronous-unwind-tables"; break; case OPT_LEV_RELEASE: result += " -g0"; break; } + + if(config.getSanitize()) + { + result += " -fno-omit-frame-pointer -fsanitize=address -fsanitize=undefined"; + } break; } case Compiler::MSVC: @@ -782,7 +787,10 @@ namespace backend case Compiler::GCC: { // TODO: Add flag to disable -ldl and -lm (dlopen, dlclose, floor, max, ...) - result += " LINK_ARGS = '-Wl,--no-undefined,--as-needed' -ldl -lm "; + result += " LINK_ARGS = '-Wl,--no-undefined,--as-needed'"; + if(config.getSanitize()) + result += " -lasan -lubsan"; + result += " -ldl -lm "; break; } case Compiler::MSVC: @@ -848,7 +856,10 @@ namespace backend result += ".so: " + buildJob + " "; result += join(objectNames, " "); result += "\n"; - result += " LINK_ARGS = '-Wl,--no-undefined,--as-needed' -ldl -lm "; + result += " LINK_ARGS = '-Wl,--no-undefined,--as-needed'"; + if(config.getSanitize()) + result += " -lasan -lubsan"; + result += " -ldl -lm "; projectGeneratedBinary += "lib" + config.getPackageName() + ".so"; break; } @@ -946,6 +957,7 @@ namespace backend FileType projectConfFileType = getFileType(projectConfFilePath.c_str()); SibsTestConfig sibsTestConfig(config.getCompiler(), testSourceDirNative, config.getOptimizationLevel()); + sibsTestConfig.setSanitize(config.getSanitize()); if(projectConfFileType == FileType::REGULAR) { Result<bool> result = Config::readFromFile(projectConfFilePath.c_str(), sibsTestConfig); |