aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-01-11 22:01:16 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-01-11 22:07:21 -0700
commit5b2a79848ced20db80f3f4ce46b3ef7f4a051d53 (patch)
treedfdd8caf259e2d03ba89d4c0211d9cafb45c6064 /src/main.zig
parent8932c2d7456fc86b9e92c7976cedcce798caef1a (diff)
downloadzig-5b2a79848ced20db80f3f4ce46b3ef7f4a051d53.tar.gz
zig-5b2a79848ced20db80f3f4ce46b3ef7f4a051d53.zip
stage2: cleanups regarding red zone CLI flags
* CLI: change to -mred-zone and -mno-red-zone to match gcc/clang. * build.zig: remove the double negative and make it an optional bool. This follows precedent from other flags, allowing the compiler CLI to be the decider of what is default instead of duplicating the default value into the build system code. * Compilation: make it an optional `want_red_zone` instead of a `no_red_zone` bool. The default is decided by a call to `target_util.hasRedZone`. * When creating a Clang command line, put -mred-zone on the command line if we are forcing it to be enabled. * Update update_clang_options.zig with respect to the recent {s}/{} format changes. * `zig cc` integration with red zone preference.
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/main.zig b/src/main.zig
index a7a23c2b2d..867aa348b1 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -267,6 +267,8 @@ const usage_build_generic =
\\ -mcmodel=[default|tiny| Limit range of code and data virtual addresses
\\ small|kernel|
\\ medium|large]
+ \\ -mred-zone Force-enable the "red-zone"
+ \\ -mno-red-zone Force-disable the "red-zone"
\\ --name [name] Override root name (not a file path)
\\ -O [mode] Choose what to optimize for
\\ Debug (default) Optimizations off, safety on
@@ -282,8 +284,6 @@ const usage_build_generic =
\\ -fno-PIE Force-disable Position Independent Executable
\\ -fstack-check Enable stack probing in unsafe builds
\\ -fno-stack-check Disable stack probing in safe builds
- \\ -fred-zone Enable the "red-zone"
- \\ -fno-red-zone Disable the "red-zone"
\\ -fsanitize-c Enable C undefined behavior detection in unsafe builds
\\ -fno-sanitize-c Disable C undefined behavior detection in safe builds
\\ -fvalgrind Include valgrind client requests in release builds
@@ -507,7 +507,7 @@ fn buildOutputType(
var want_pie: ?bool = null;
var want_sanitize_c: ?bool = null;
var want_stack_check: ?bool = null;
- var no_red_zone: bool = false;
+ var want_red_zone: ?bool = null;
var want_valgrind: ?bool = null;
var want_tsan: ?bool = null;
var want_compiler_rt: ?bool = null;
@@ -846,10 +846,10 @@ fn buildOutputType(
want_stack_check = true;
} else if (mem.eql(u8, arg, "-fno-stack-check")) {
want_stack_check = false;
- } else if (mem.eql(u8, arg, "-fred-zone")) {
- no_red_zone = false;
- } else if (mem.eql(u8, arg, "-fno-red-zone")) {
- no_red_zone = true;
+ } else if (mem.eql(u8, arg, "-mred-zone")) {
+ want_red_zone = true;
+ } else if (mem.eql(u8, arg, "-mno-red-zone")) {
+ want_red_zone = false;
} else if (mem.eql(u8, arg, "-fsanitize-c")) {
want_sanitize_c = true;
} else if (mem.eql(u8, arg, "-fno-sanitize-c")) {
@@ -1075,6 +1075,8 @@ fn buildOutputType(
.no_pic => want_pic = false,
.pie => want_pie = true,
.no_pie => want_pie = false,
+ .red_zone => want_red_zone = true,
+ .no_red_zone => want_red_zone = false,
.nostdlib => ensure_libc_on_non_freestanding = false,
.nostdlib_cpp => ensure_libcpp_on_non_freestanding = false,
.shared => {
@@ -1767,7 +1769,7 @@ fn buildOutputType(
.want_pie = want_pie,
.want_sanitize_c = want_sanitize_c,
.want_stack_check = want_stack_check,
- .no_red_zone = no_red_zone,
+ .want_red_zone = want_red_zone,
.want_valgrind = want_valgrind,
.want_tsan = want_tsan,
.want_compiler_rt = want_compiler_rt,
@@ -2977,6 +2979,8 @@ pub const ClangArgIterator = struct {
framework_dir,
framework,
nostdlibinc,
+ red_zone,
+ no_red_zone,
};
const Args = struct {