std.Build: revert moving some fields to Graph

On second thought, let's keep a bunch of these flags how they already
were.

Partial revert of the previous commit.
This commit is contained in:
Andrew Kelley 2024-02-01 17:40:36 -07:00
parent 105db13536
commit 370438943e
4 changed files with 45 additions and 39 deletions

View file

@ -410,14 +410,14 @@ pub fn build(b: *std.Build) !void {
test_cases_options.addOption(bool, "only_c", only_c); test_cases_options.addOption(bool, "only_c", only_c);
test_cases_options.addOption(bool, "only_core_functionality", true); test_cases_options.addOption(bool, "only_core_functionality", true);
test_cases_options.addOption(bool, "only_reduce", false); test_cases_options.addOption(bool, "only_reduce", false);
test_cases_options.addOption(bool, "enable_qemu", b.graph.enable_qemu); test_cases_options.addOption(bool, "enable_qemu", b.enable_qemu);
test_cases_options.addOption(bool, "enable_wine", b.graph.enable_wine); test_cases_options.addOption(bool, "enable_wine", b.enable_wine);
test_cases_options.addOption(bool, "enable_wasmtime", b.graph.enable_wasmtime); test_cases_options.addOption(bool, "enable_wasmtime", b.enable_wasmtime);
test_cases_options.addOption(bool, "enable_rosetta", b.graph.enable_rosetta); test_cases_options.addOption(bool, "enable_rosetta", b.enable_rosetta);
test_cases_options.addOption(bool, "enable_darling", b.graph.enable_darling); test_cases_options.addOption(bool, "enable_darling", b.enable_darling);
test_cases_options.addOption(u32, "mem_leak_frames", mem_leak_frames * 2); test_cases_options.addOption(u32, "mem_leak_frames", mem_leak_frames * 2);
test_cases_options.addOption(bool, "value_tracing", value_tracing); test_cases_options.addOption(bool, "value_tracing", value_tracing);
test_cases_options.addOption(?[]const u8, "glibc_runtimes_dir", b.graph.glibc_runtimes_dir); test_cases_options.addOption(?[]const u8, "glibc_runtimes_dir", b.glibc_runtimes_dir);
test_cases_options.addOption([:0]const u8, "version", version); test_cases_options.addOption([:0]const u8, "version", version);
test_cases_options.addOption(std.SemanticVersion, "semver", semver); test_cases_options.addOption(std.SemanticVersion, "semver", semver);
test_cases_options.addOption(?[]const u8, "test_filter", test_filter); test_cases_options.addOption(?[]const u8, "test_filter", test_filter);

View file

@ -194,7 +194,7 @@ pub fn main() !void {
} else if (mem.eql(u8, arg, "--debug-compile-errors")) { } else if (mem.eql(u8, arg, "--debug-compile-errors")) {
builder.debug_compile_errors = true; builder.debug_compile_errors = true;
} else if (mem.eql(u8, arg, "--glibc-runtimes")) { } else if (mem.eql(u8, arg, "--glibc-runtimes")) {
graph.glibc_runtimes_dir = nextArgOrFatal(args, &arg_idx); builder.glibc_runtimes_dir = nextArgOrFatal(args, &arg_idx);
} else if (mem.eql(u8, arg, "--verbose-link")) { } else if (mem.eql(u8, arg, "--verbose-link")) {
builder.verbose_link = true; builder.verbose_link = true;
} else if (mem.eql(u8, arg, "--verbose-air")) { } else if (mem.eql(u8, arg, "--verbose-air")) {
@ -214,25 +214,25 @@ pub fn main() !void {
} else if (mem.eql(u8, arg, "--prominent-compile-errors")) { } else if (mem.eql(u8, arg, "--prominent-compile-errors")) {
prominent_compile_errors = true; prominent_compile_errors = true;
} else if (mem.eql(u8, arg, "-fwine")) { } else if (mem.eql(u8, arg, "-fwine")) {
graph.enable_wine = true; builder.enable_wine = true;
} else if (mem.eql(u8, arg, "-fno-wine")) { } else if (mem.eql(u8, arg, "-fno-wine")) {
graph.enable_wine = false; builder.enable_wine = false;
} else if (mem.eql(u8, arg, "-fqemu")) { } else if (mem.eql(u8, arg, "-fqemu")) {
graph.enable_qemu = true; builder.enable_qemu = true;
} else if (mem.eql(u8, arg, "-fno-qemu")) { } else if (mem.eql(u8, arg, "-fno-qemu")) {
graph.enable_qemu = false; builder.enable_qemu = false;
} else if (mem.eql(u8, arg, "-fwasmtime")) { } else if (mem.eql(u8, arg, "-fwasmtime")) {
graph.enable_wasmtime = true; builder.enable_wasmtime = true;
} else if (mem.eql(u8, arg, "-fno-wasmtime")) { } else if (mem.eql(u8, arg, "-fno-wasmtime")) {
graph.enable_wasmtime = false; builder.enable_wasmtime = false;
} else if (mem.eql(u8, arg, "-frosetta")) { } else if (mem.eql(u8, arg, "-frosetta")) {
graph.enable_rosetta = true; builder.enable_rosetta = true;
} else if (mem.eql(u8, arg, "-fno-rosetta")) { } else if (mem.eql(u8, arg, "-fno-rosetta")) {
graph.enable_rosetta = false; builder.enable_rosetta = false;
} else if (mem.eql(u8, arg, "-fdarling")) { } else if (mem.eql(u8, arg, "-fdarling")) {
graph.enable_darling = true; builder.enable_darling = true;
} else if (mem.eql(u8, arg, "-fno-darling")) { } else if (mem.eql(u8, arg, "-fno-darling")) {
graph.enable_darling = false; builder.enable_darling = false;
} else if (mem.eql(u8, arg, "-freference-trace")) { } else if (mem.eql(u8, arg, "-freference-trace")) {
builder.reference_trace = 256; builder.reference_trace = 256;
} else if (mem.startsWith(u8, arg, "-freference-trace=")) { } else if (mem.startsWith(u8, arg, "-freference-trace=")) {

View file

@ -66,6 +66,22 @@ debug_pkg_config: bool = false,
/// Set to 0 to disable stack collection. /// Set to 0 to disable stack collection.
debug_stack_frames_count: u8 = 8, debug_stack_frames_count: u8 = 8,
/// Experimental. Use system Darling installation to run cross compiled macOS build artifacts.
enable_darling: bool = false,
/// Use system QEMU installation to run cross compiled foreign architecture build artifacts.
enable_qemu: bool = false,
/// Darwin. Use Rosetta to run x86_64 macOS build artifacts on arm64 macOS.
enable_rosetta: bool = false,
/// Use system Wasmtime installation to run cross compiled wasm/wasi build artifacts.
enable_wasmtime: bool = false,
/// Use system Wine installation to run cross compiled Windows build artifacts.
enable_wine: bool = false,
/// After following the steps in https://github.com/ziglang/zig/wiki/Updating-libc#glibc,
/// this will be the directory $glibc-build-dir/install/glibcs
/// Given the example of the aarch64 target, this is the directory
/// that contains the path `aarch64-linux-gnu/lib/ld-linux-aarch64.so.1`.
glibc_runtimes_dir: ?[]const u8 = null,
/// Information about the native target. Computed before build() is invoked. /// Information about the native target. Computed before build() is invoked.
host: ResolvedTarget, host: ResolvedTarget,
@ -91,22 +107,6 @@ pub const Graph = struct {
env_map: EnvMap, env_map: EnvMap,
global_cache_root: Cache.Directory, global_cache_root: Cache.Directory,
host_query_options: std.Target.Query.ParseOptions = .{}, host_query_options: std.Target.Query.ParseOptions = .{},
/// Experimental. Use system Darling installation to run cross compiled macOS build artifacts.
enable_darling: bool = false,
/// Use system QEMU installation to run cross compiled foreign architecture build artifacts.
enable_qemu: bool = false,
/// Darwin. Use Rosetta to run x86_64 macOS build artifacts on arm64 macOS.
enable_rosetta: bool = false,
/// Use system Wasmtime installation to run cross compiled wasm/wasi build artifacts.
enable_wasmtime: bool = false,
/// Use system Wine installation to run cross compiled Windows build artifacts.
enable_wine: bool = false,
/// After following the steps in https://github.com/ziglang/zig/wiki/Updating-libc#glibc,
/// this will be the directory $glibc-build-dir/install/glibcs
/// Given the example of the aarch64 target, this is the directory
/// that contains the path `aarch64-linux-gnu/lib/ld-linux-aarch64.so.1`.
glibc_runtimes_dir: ?[]const u8 = null,
}; };
const AvailableDeps = []const struct { []const u8, []const u8 }; const AvailableDeps = []const struct { []const u8, []const u8 };
@ -374,6 +374,12 @@ fn createChildOnly(
.debug_log_scopes = parent.debug_log_scopes, .debug_log_scopes = parent.debug_log_scopes,
.debug_compile_errors = parent.debug_compile_errors, .debug_compile_errors = parent.debug_compile_errors,
.debug_pkg_config = parent.debug_pkg_config, .debug_pkg_config = parent.debug_pkg_config,
.enable_darling = parent.enable_darling,
.enable_qemu = parent.enable_qemu,
.enable_rosetta = parent.enable_rosetta,
.enable_wasmtime = parent.enable_wasmtime,
.enable_wine = parent.enable_wine,
.glibc_runtimes_dir = parent.glibc_runtimes_dir,
.host = parent.host, .host = parent.host,
.dep_prefix = parent.fmt("{s}{s}.", .{ parent.dep_prefix, dep_name }), .dep_prefix = parent.fmt("{s}{s}.", .{ parent.dep_prefix, dep_name }),
.modules = std.StringArrayHashMap(*Module).init(allocator), .modules = std.StringArrayHashMap(*Module).init(allocator),

View file

@ -747,7 +747,7 @@ fn runCommand(
exe.is_linking_libc; exe.is_linking_libc;
const other_target = exe.root_module.resolved_target.?.result; const other_target = exe.root_module.resolved_target.?.result;
switch (std.zig.system.getExternalExecutor(b.host.result, &other_target, .{ switch (std.zig.system.getExternalExecutor(b.host.result, &other_target, .{
.qemu_fixes_dl = need_cross_glibc and b.graph.glibc_runtimes_dir != null, .qemu_fixes_dl = need_cross_glibc and b.glibc_runtimes_dir != null,
.link_libc = exe.is_linking_libc, .link_libc = exe.is_linking_libc,
})) { })) {
.native, .rosetta => { .native, .rosetta => {
@ -755,7 +755,7 @@ fn runCommand(
break :interpret; break :interpret;
}, },
.wine => |bin_name| { .wine => |bin_name| {
if (b.graph.enable_wine) { if (b.enable_wine) {
try interp_argv.append(bin_name); try interp_argv.append(bin_name);
try interp_argv.appendSlice(argv); try interp_argv.appendSlice(argv);
} else { } else {
@ -763,9 +763,9 @@ fn runCommand(
} }
}, },
.qemu => |bin_name| { .qemu => |bin_name| {
if (b.graph.enable_qemu) { if (b.enable_qemu) {
const glibc_dir_arg = if (need_cross_glibc) const glibc_dir_arg = if (need_cross_glibc)
b.graph.glibc_runtimes_dir orelse b.glibc_runtimes_dir orelse
return failForeign(self, "--glibc-runtimes", argv[0], exe) return failForeign(self, "--glibc-runtimes", argv[0], exe)
else else
null; null;
@ -798,7 +798,7 @@ fn runCommand(
} }
}, },
.darling => |bin_name| { .darling => |bin_name| {
if (b.graph.enable_darling) { if (b.enable_darling) {
try interp_argv.append(bin_name); try interp_argv.append(bin_name);
try interp_argv.appendSlice(argv); try interp_argv.appendSlice(argv);
} else { } else {
@ -806,7 +806,7 @@ fn runCommand(
} }
}, },
.wasmtime => |bin_name| { .wasmtime => |bin_name| {
if (b.graph.enable_wasmtime) { if (b.enable_wasmtime) {
try interp_argv.append(bin_name); try interp_argv.append(bin_name);
try interp_argv.append("--dir=."); try interp_argv.append("--dir=.");
try interp_argv.append(argv[0]); try interp_argv.append(argv[0]);