diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-02-01 15:44:44 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-02-02 20:43:01 -0700 |
| commit | 105db13536b4dc2affe130cb8d2eee6c97c89bcd (patch) | |
| tree | 07d5a285d7ff1ea5262118e94ea61a018f1d775a /lib/std/Build/Step/Run.zig | |
| parent | bd1d2b0ae25ead6cd27c0bfeb65490ee92f06bad (diff) | |
| download | zig-105db13536b4dc2affe130cb8d2eee6c97c89bcd.tar.gz zig-105db13536b4dc2affe130cb8d2eee6c97c89bcd.zip | |
std.Build: implement --host-target, --host-cpu, --host-dynamic-linker
This also makes a long-overdue change of extracting common state from
Build into a shared Graph object.
Getting the semantics right for these flags turned out to be quite
tricky. In the end it works like this:
* The override only happens when the target is fully native, with no
additional query parameters, such as versions or CPU features added.
* The override affects the resolved Target but leaves the original Query
unmodified.
* The "is native?" detection logic operates on the original, unmodified
query. This makes it possible to provide invalid host target
information, causing confusing errors to occur. Don't do that.
There are some minor breaking changes to std.Build API such as the fact
that `b.zig_exe` is now moved to `b.graph.zig_exe`, as well as a handful
of other similar flags.
Diffstat (limited to 'lib/std/Build/Step/Run.zig')
| -rw-r--r-- | lib/std/Build/Step/Run.zig | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/std/Build/Step/Run.zig b/lib/std/Build/Step/Run.zig index de8f9816ab..2d49c48401 100644 --- a/lib/std/Build/Step/Run.zig +++ b/lib/std/Build/Step/Run.zig @@ -463,7 +463,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { var argv_list = ArrayList([]const u8).init(arena); var output_placeholders = ArrayList(IndexedOutput).init(arena); - var man = b.cache.obtain(); + var man = b.graph.cache.obtain(); defer man.deinit(); for (self.argv.items) |arg| { @@ -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.glibc_runtimes_dir != null, + .qemu_fixes_dl = need_cross_glibc and b.graph.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.enable_wine) { + if (b.graph.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.enable_qemu) { + if (b.graph.enable_qemu) { const glibc_dir_arg = if (need_cross_glibc) - b.glibc_runtimes_dir orelse + b.graph.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.enable_darling) { + if (b.graph.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.enable_wasmtime) { + if (b.graph.enable_wasmtime) { try interp_argv.append(bin_name); try interp_argv.append("--dir=."); try interp_argv.append(argv[0]); @@ -1036,7 +1036,7 @@ fn spawnChildAndCollect( child.cwd = b.build_root.path; child.cwd_dir = b.build_root.handle; } - child.env_map = self.env_map orelse b.env_map; + child.env_map = self.env_map orelse &b.graph.env_map; child.request_resource_usage_statistics = true; child.stdin_behavior = switch (self.stdio) { |
