authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-03-18 16:45:37-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-03-18 16:59:48-04:00
log1b801bdbae2928d6b0ab5897d2e604fb3f87b3c4
treec419fcbc3d7b9482bd28ce79b5a96b57c2616ca8
parenta17bf219c6f67d31f52e2ae7b379784b36c07bd5
signaturelock-open Commit is signed but in an unrecognized format.

pass explicit frame pointer args when compiling C code


1 files changed, 11 insertions(+), 0 deletions(-)

src/codegen.cpp+11
......@@ -8474,8 +8474,11 @@ static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) {
84748474 } else {
84758475 args.append("-fno-stack-protector");
84768476 }
8477 args.append("-fno-omit-frame-pointer");
84778478 break;
84788479 case BuildModeSafeRelease:
8480 // See the comment in the BuildModeFastRelease case for why we pass -O2 rather
8481 // than -O3 here.
84798482 args.append("-O2");
84808483 if (g->libc_link_lib != nullptr) {
84818484 args.append("-D_FORTIFY_SOURCE=2");
......@@ -8485,16 +8488,24 @@ static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) {
84858488 } else {
84868489 args.append("-fno-stack-protector");
84878490 }
8491 args.append("-fomit-frame-pointer");
84888492 break;
84898493 case BuildModeFastRelease:
84908494 args.append("-DNDEBUG");
8495 // Here we pass -O2 rather than -O3 because, although we do the equivalent of
8496 // -O3 in Zig code, the justification for the difference here is that Zig
8497 // has better detection and prevention of undefined behavior, so -O3 is safer for
8498 // Zig code than it is for C code. Also, C programmers are used to their code
8499 // running in -O2 and thus the -O3 path has been tested less.
84918500 args.append("-O2");
84928501 args.append("-fno-stack-protector");
8502 args.append("-fomit-frame-pointer");
84938503 break;
84948504 case BuildModeSmallRelease:
84958505 args.append("-DNDEBUG");
84968506 args.append("-Os");
84978507 args.append("-fno-stack-protector");
8508 args.append("-fomit-frame-pointer");
84988509 break;
84998510 }
85008511