diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-12-16 16:17:52 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-16 16:17:52 -0500 |
| commit | 13cdc137e6389af83f225ab851bf8ef768ebcc69 (patch) | |
| tree | 34675041bfef45efd3c294f7df9fb244674c6dbf /src/main.cpp | |
| parent | de0d8885b4623dab14c379fc844ae0b18d9f8405 (diff) | |
| parent | 839b3a61ad51b385ac28a0123b6cc63d90ef83f8 (diff) | |
| download | zig-13cdc137e6389af83f225ab851bf8ef768ebcc69.tar.gz zig-13cdc137e6389af83f225ab851bf8ef768ebcc69.zip | |
Merge pull request #3570 from ziglang/c-sanitize-undef
use -fsanitize=undefined for C code in safe build modes
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index a6b26893b9..2cda18f7a0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -59,6 +59,8 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) { " --enable-valgrind include valgrind client requests release builds\n" " -fstack-check enable stack probing in unsafe builds\n" " -fno-stack-check disable stack probing in safe builds\n" + " -fsanitize-c enable C undefined behavior detection in unsafe builds\n" + " -fno-sanitize-c disable C undefined behavior detection in safe builds\n" " --emit [asm|bin|llvm-ir] emit a specific file format as compilation output\n" " -fPIC enable Position Independent Code\n" " -fno-PIC disable Position Independent Code\n" @@ -524,6 +526,7 @@ int main(int argc, char **argv) { ValgrindSupport valgrind_support = ValgrindSupportAuto; WantPIC want_pic = WantPICAuto; WantStackCheck want_stack_check = WantStackCheckAuto; + WantCSanitize want_sanitize_c = WantCSanitizeAuto; bool function_sections = false; ZigList<const char *> llvm_argv = {0}; @@ -722,6 +725,10 @@ int main(int argc, char **argv) { want_stack_check = WantStackCheckEnabled; } else if (strcmp(arg, "-fno-stack-check") == 0) { want_stack_check = WantStackCheckDisabled; + } else if (strcmp(arg, "-fsanitize-c") == 0) { + want_sanitize_c = WantCSanitizeEnabled; + } else if (strcmp(arg, "-fno-sanitize-c") == 0) { + want_sanitize_c = WantCSanitizeDisabled; } else if (strcmp(arg, "--system-linker-hack") == 0) { system_linker_hack = true; } else if (strcmp(arg, "--single-threaded") == 0) { @@ -1093,6 +1100,7 @@ int main(int argc, char **argv) { g->valgrind_support = valgrind_support; g->want_pic = want_pic; g->want_stack_check = want_stack_check; + g->want_sanitize_c = want_sanitize_c; g->want_single_threaded = want_single_threaded; Buf *builtin_source = codegen_generate_builtin_source(g); if (fwrite(buf_ptr(builtin_source), 1, buf_len(builtin_source), stdout) != buf_len(builtin_source)) { @@ -1192,6 +1200,7 @@ int main(int argc, char **argv) { g->valgrind_support = valgrind_support; g->want_pic = want_pic; g->want_stack_check = want_stack_check; + g->want_sanitize_c = want_sanitize_c; g->subsystem = subsystem; g->enable_time_report = timing_info; |
