Commit 370438943e

Andrew Kelley <andrew@ziglang.org>
2024-02-02 01:40:36
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.
1 parent 105db13
Changed files (4)
lib/std/Build/Step/Run.zig
@@ -747,7 +747,7 @@ fn runCommand(
                 exe.is_linking_libc;
             const other_target = exe.root_module.resolved_target.?.result;
             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,
             })) {
                 .native, .rosetta => {
@@ -755,7 +755,7 @@ fn runCommand(
                     break :interpret;
                 },
                 .wine => |bin_name| {
-                    if (b.graph.enable_wine) {
+                    if (b.enable_wine) {
                         try interp_argv.append(bin_name);
                         try interp_argv.appendSlice(argv);
                     } else {
@@ -763,9 +763,9 @@ fn runCommand(
                     }
                 },
                 .qemu => |bin_name| {
-                    if (b.graph.enable_qemu) {
+                    if (b.enable_qemu) {
                         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)
                         else
                             null;
@@ -798,7 +798,7 @@ fn runCommand(
                     }
                 },
                 .darling => |bin_name| {
-                    if (b.graph.enable_darling) {
+                    if (b.enable_darling) {
                         try interp_argv.append(bin_name);
                         try interp_argv.appendSlice(argv);
                     } else {
@@ -806,7 +806,7 @@ fn runCommand(
                     }
                 },
                 .wasmtime => |bin_name| {
-                    if (b.graph.enable_wasmtime) {
+                    if (b.enable_wasmtime) {
                         try interp_argv.append(bin_name);
                         try interp_argv.append("--dir=.");
                         try interp_argv.append(argv[0]);
lib/std/Build.zig
@@ -66,6 +66,22 @@ debug_pkg_config: bool = false,
 /// Set to 0 to disable stack collection.
 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.
 host: ResolvedTarget,
 
@@ -91,22 +107,6 @@ pub const Graph = struct {
     env_map: EnvMap,
     global_cache_root: Cache.Directory,
     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 };
@@ -374,6 +374,12 @@ fn createChildOnly(
         .debug_log_scopes = parent.debug_log_scopes,
         .debug_compile_errors = parent.debug_compile_errors,
         .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,
         .dep_prefix = parent.fmt("{s}{s}.", .{ parent.dep_prefix, dep_name }),
         .modules = std.StringArrayHashMap(*Module).init(allocator),
lib/build_runner.zig
@@ -194,7 +194,7 @@ pub fn main() !void {
             } else if (mem.eql(u8, arg, "--debug-compile-errors")) {
                 builder.debug_compile_errors = true;
             } 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")) {
                 builder.verbose_link = true;
             } 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")) {
                 prominent_compile_errors = true;
             } else if (mem.eql(u8, arg, "-fwine")) {
-                graph.enable_wine = true;
+                builder.enable_wine = true;
             } else if (mem.eql(u8, arg, "-fno-wine")) {
-                graph.enable_wine = false;
+                builder.enable_wine = false;
             } else if (mem.eql(u8, arg, "-fqemu")) {
-                graph.enable_qemu = true;
+                builder.enable_qemu = true;
             } else if (mem.eql(u8, arg, "-fno-qemu")) {
-                graph.enable_qemu = false;
+                builder.enable_qemu = false;
             } else if (mem.eql(u8, arg, "-fwasmtime")) {
-                graph.enable_wasmtime = true;
+                builder.enable_wasmtime = true;
             } else if (mem.eql(u8, arg, "-fno-wasmtime")) {
-                graph.enable_wasmtime = false;
+                builder.enable_wasmtime = false;
             } else if (mem.eql(u8, arg, "-frosetta")) {
-                graph.enable_rosetta = true;
+                builder.enable_rosetta = true;
             } else if (mem.eql(u8, arg, "-fno-rosetta")) {
-                graph.enable_rosetta = false;
+                builder.enable_rosetta = false;
             } else if (mem.eql(u8, arg, "-fdarling")) {
-                graph.enable_darling = true;
+                builder.enable_darling = true;
             } else if (mem.eql(u8, arg, "-fno-darling")) {
-                graph.enable_darling = false;
+                builder.enable_darling = false;
             } else if (mem.eql(u8, arg, "-freference-trace")) {
                 builder.reference_trace = 256;
             } else if (mem.startsWith(u8, arg, "-freference-trace=")) {
build.zig
@@ -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_core_functionality", true);
     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_wine", b.graph.enable_wine);
-    test_cases_options.addOption(bool, "enable_wasmtime", b.graph.enable_wasmtime);
-    test_cases_options.addOption(bool, "enable_rosetta", b.graph.enable_rosetta);
-    test_cases_options.addOption(bool, "enable_darling", b.graph.enable_darling);
+    test_cases_options.addOption(bool, "enable_qemu", b.enable_qemu);
+    test_cases_options.addOption(bool, "enable_wine", b.enable_wine);
+    test_cases_options.addOption(bool, "enable_wasmtime", b.enable_wasmtime);
+    test_cases_options.addOption(bool, "enable_rosetta", b.enable_rosetta);
+    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(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(std.SemanticVersion, "semver", semver);
     test_cases_options.addOption(?[]const u8, "test_filter", test_filter);