diff options
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); |