diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-10-31 17:24:22 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-12-16 13:06:02 -0500 |
| commit | f8cd981c04e60530b99c9f360c3e79041d75ca96 (patch) | |
| tree | b5d355aa94f0d64e0cd9b8f237f056b3dce75030 /src/codegen.cpp | |
| parent | cb5a5ebb200c6e7f87178e26dac453e8c91948d7 (diff) | |
| download | zig-f8cd981c04e60530b99c9f360c3e79041d75ca96.tar.gz zig-f8cd981c04e60530b99c9f360c3e79041d75ca96.zip | |
use -fsanitize=undefined for C code in safe build modes
closes #3569
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index 1b77f0752a..b828410181 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -8973,6 +8973,9 @@ void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_pa switch (g->build_mode) { case BuildModeDebug: + args.append("-fsanitize=undefined"); + args.append("-fsanitize-trap=undefined"); + // windows c runtime requires -D_DEBUG if using debug libraries args.append("-D_DEBUG"); @@ -8985,6 +8988,9 @@ void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_pa } break; case BuildModeSafeRelease: + args.append("-fsanitize=undefined"); + args.append("-fsanitize-trap=undefined"); + // See the comment in the BuildModeFastRelease case for why we pass -O2 rather // than -O3 here. args.append("-O2"); |
