aboutsummaryrefslogtreecommitdiff
path: root/src/target.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/target.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/target.zig')
-rw-r--r--src/target.zig18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/target.zig b/src/target.zig
index daac577c7b..c3df682ce0 100644
--- a/src/target.zig
+++ b/src/target.zig
@@ -349,3 +349,21 @@ pub fn defaultCompilerRtOptimizeMode(target: std.Target) std.builtin.Mode {
return .ReleaseFast;
}
}
+
+pub fn hasRedZone(target: std.Target) bool {
+ return switch (target.cpu.arch) {
+ .x86_64,
+ .i386,
+ .wasm32,
+ .wasm64,
+ .powerpc,
+ .powerpc64,
+ .powerpc64le,
+ .aarch64,
+ .aarch64_be,
+ .aarch64_32,
+ => true,
+
+ else => false,
+ };
+}