mirror of
https://github.com/ziglang/zig.git
synced 2025-12-15 18:53:07 +00:00
pass explicit frame pointer args when compiling C code
This commit is contained in:
parent
a17bf219c6
commit
1b801bdbae
@ -8474,8 +8474,11 @@ static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) {
|
|||||||
} else {
|
} else {
|
||||||
args.append("-fno-stack-protector");
|
args.append("-fno-stack-protector");
|
||||||
}
|
}
|
||||||
|
args.append("-fno-omit-frame-pointer");
|
||||||
break;
|
break;
|
||||||
case BuildModeSafeRelease:
|
case BuildModeSafeRelease:
|
||||||
|
// See the comment in the BuildModeFastRelease case for why we pass -O2 rather
|
||||||
|
// than -O3 here.
|
||||||
args.append("-O2");
|
args.append("-O2");
|
||||||
if (g->libc_link_lib != nullptr) {
|
if (g->libc_link_lib != nullptr) {
|
||||||
args.append("-D_FORTIFY_SOURCE=2");
|
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 {
|
} else {
|
||||||
args.append("-fno-stack-protector");
|
args.append("-fno-stack-protector");
|
||||||
}
|
}
|
||||||
|
args.append("-fomit-frame-pointer");
|
||||||
break;
|
break;
|
||||||
case BuildModeFastRelease:
|
case BuildModeFastRelease:
|
||||||
args.append("-DNDEBUG");
|
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("-O2");
|
||||||
args.append("-fno-stack-protector");
|
args.append("-fno-stack-protector");
|
||||||
|
args.append("-fomit-frame-pointer");
|
||||||
break;
|
break;
|
||||||
case BuildModeSmallRelease:
|
case BuildModeSmallRelease:
|
||||||
args.append("-DNDEBUG");
|
args.append("-DNDEBUG");
|
||||||
args.append("-Os");
|
args.append("-Os");
|
||||||
args.append("-fno-stack-protector");
|
args.append("-fno-stack-protector");
|
||||||
|
args.append("-fomit-frame-pointer");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user