aboutsummaryrefslogtreecommitdiff
path: root/src/CmakeModule.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-07-04 20:07:20 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-06 07:39:58 +0200
commit444b5725b125e5154a571a1542cbb5a7ca58e29b (patch)
tree235669d9a7eac7da9055f5121efc7ac3abdb2dd2 /src/CmakeModule.cpp
parent804a30bffb5b66b3ee58c30fe5641d27b083b6fb (diff)
Fix sanitizers (and tests) by allowing to specify which sanitizer to use. Its not possible to use all of them at the same time
Diffstat (limited to 'src/CmakeModule.cpp')
-rw-r--r--src/CmakeModule.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/CmakeModule.cpp b/src/CmakeModule.cpp
index a690948..f57a8cf 100644
--- a/src/CmakeModule.cpp
+++ b/src/CmakeModule.cpp
@@ -74,6 +74,23 @@ namespace sibs
string allLinkerFlags = "";
#endif
+ if(config.getCompiler() == Compiler::GCC || config.getCompiler() == Compiler::MINGW_W64)
+ {
+ switch(config.getSanitize()) {
+ case Sanitize::NONE:
+ break;
+ case Sanitize::ADDRESS:
+ allLinkerFlags += " -lasan";
+ break;
+ case Sanitize::UNDEFINED:
+ allLinkerFlags += TINYDIR_STRING(" -lubsan");
+ break;
+ case Sanitize::LEAK:
+ allLinkerFlags += TINYDIR_STRING(" -llsan");
+ break;
+ }
+ }
+
#if 0
// TODO: Somehow check loading order, because it has to be correct to work.. Or does it for dynamic libraries?
// Anyways it's required for static libraries (especially on Windows)
@@ -180,9 +197,22 @@ namespace sibs
FileString cflags = TINYDIR_STRING("-fPIC");
FileString cxxflags;
- if(config.getCompiler() == Compiler::GCC && config.getSanitize())
+ if(config.getCompiler() == Compiler::GCC || config.getCompiler() == Compiler::MINGW_W64)
{
- cflags += TINYDIR_STRING(" -fno-omit-frame-pointer -fsanitize=address -fsanitize=undefined -fsanitize=leak -lasan -lubsan -llsan");
+ cflags += TINYDIR_STRING(" -fno-omit-frame-pointer");
+ switch(config.getSanitize()) {
+ case Sanitize::NONE:
+ break;
+ case Sanitize::ADDRESS:
+ cflags += TINYDIR_STRING(" -fsanitize=address");
+ break;
+ case Sanitize::UNDEFINED:
+ cflags += TINYDIR_STRING(" -fsanitize=undefined");
+ break;
+ case Sanitize::LEAK:
+ cflags += TINYDIR_STRING(" -fsanitize=leak");
+ break;
+ }
}
#if OS_FAMILY == OS_FAMILY_POSIX