diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-03-18 16:45:37 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-03-18 16:59:48 -0400 |
| commit | 1b801bdbae2928d6b0ab5897d2e604fb3f87b3c4 (patch) | |
| tree | c419fcbc3d7b9482bd28ce79b5a96b57c2616ca8 /src/codegen.cpp | |
| parent | a17bf219c6f67d31f52e2ae7b379784b36c07bd5 (diff) | |
| download | zig-1b801bdbae2928d6b0ab5897d2e604fb3f87b3c4.tar.gz zig-1b801bdbae2928d6b0ab5897d2e604fb3f87b3c4.zip | |
pass explicit frame pointer args when compiling C code
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index 8492f7db87..84b9cb1d5b 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -8474,8 +8474,11 @@ static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) { } else { args.append("-fno-stack-protector"); } + args.append("-fno-omit-frame-pointer"); break; case BuildModeSafeRelease: + // See the comment in the BuildModeFastRelease case for why we pass -O2 rather + // than -O3 here. args.append("-O2"); if (g->libc_link_lib != nullptr) { args.append("-D_FORTIFY_SOURCE=2"); @@ -8485,16 +8488,24 @@ static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) { } else { args.append("-fno-stack-protector"); } + args.append("-fomit-frame-pointer"); break; case BuildModeFastRelease: args.append("-DNDEBUG"); + // Here we pass -O2 rather than -O3 because, although we do the equivalent of + // -O3 in Zig code, the justification for the difference here is that Zig + // has better detection and prevention of undefined behavior, so -O3 is safer for + // Zig code than it is for C code. Also, C programmers are used to their code + // running in -O2 and thus the -O3 path has been tested less. args.append("-O2"); args.append("-fno-stack-protector"); + args.append("-fomit-frame-pointer"); break; case BuildModeSmallRelease: args.append("-DNDEBUG"); args.append("-Os"); args.append("-fno-stack-protector"); + args.append("-fomit-frame-pointer"); break; } |
