From 5b2a79848ced20db80f3f4ce46b3ef7f4a051d53 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 11 Jan 2021 22:01:16 -0700 Subject: 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. --- lib/std/build.zig | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib/std') diff --git a/lib/std/build.zig b/lib/std/build.zig index 869671c785..381488d800 100644 --- a/lib/std/build.zig +++ b/lib/std/build.zig @@ -1262,7 +1262,6 @@ pub const LibExeObjStep = struct { disable_stack_probing: bool, disable_sanitize_c: bool, sanitize_thread: bool, - no_red_zone: bool = false, rdynamic: bool, c_std: Builder.CStd, override_lib_dir: ?[]const u8, @@ -1333,6 +1332,8 @@ pub const LibExeObjStep = struct { /// Position Independent Executable pie: ?bool = null, + red_zone: ?bool = null, + subsystem: ?builtin.SubSystem = null, /// Overrides the default stack size @@ -2261,8 +2262,12 @@ pub const LibExeObjStep = struct { if (self.disable_stack_probing) { try zig_args.append("-fno-stack-check"); } - if (self.no_red_zone) { - try zig_args.append("-fno-red-zone"); + if (self.red_zone) |red_zone| { + if (red_zone) { + try zig_args.append("-mred-zone"); + } else { + try zig_args.append("-mno-red-zone"); + } } if (self.disable_sanitize_c) { try zig_args.append("-fno-sanitize-c"); -- cgit v1.2.3