authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-12-05 16:09:07-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-01 17:51:18-07:00
logb92e30ff0bd2b77a486451b21d17666a311407f3
treecd2504c6815b27486e554c2541d4496d7e8f91ab
parentf5613a0e3589fcca51411ce379f3c90eace99fa6

std.Build.ResolvedTarget: rename target field to result

This change is seemingly insignificant but I actually agonized over this for three days. Some other things I considered: * (status quo in master branch) make Compile step creation functions accept a Target.Query and delete the ResolvedTarget struct. - downside: redundantly resolve target queries many times * same as before but additionally add a hash map to cache target query resolutions. - downside: now there is a hash map that doesn't actually need to exist, just to make the API more ergonomic. * add is_native_os and is_native_abi fields to std.Target and use it directly as the result of resolving a target query. - downside: they really don't belong there. They would be available as comptime booleans via `@import("builtin")` but they should not be exposed that way. With this change the downsides are: * the option name of addExecutable and friends is `target` instead of `resolved_target` matching the type name. - upside: this does not break compatibility with existing build scripts * you likely end up seeing `target.result.cpu.arch` rather than `target.cpu.arch`. - upside: this is an improvement over `target.target.cpu.arch` which it was before this commit. - downside: `b.host.target` is now `b.host.result`.

16 files changed, 43 insertions(+), 41 deletions(-)

build.zig+4-4
...@@ -221,7 +221,7 @@ pub fn build(b: *std.Build) !void {...@@ -221,7 +221,7 @@ pub fn build(b: *std.Build) !void {
221221
222 test_step.dependOn(&exe.step);222 test_step.dependOn(&exe.step);
223223
224 if (target.target.os.tag == .windows and target.target.abi == .gnu) {224 if (target.result.os.tag == .windows and target.result.abi == .gnu) {
225 // LTO is currently broken on mingw, this can be removed when it's fixed.225 // LTO is currently broken on mingw, this can be removed when it's fixed.
226 exe.want_lto = false;226 exe.want_lto = false;
227 check_case_exe.want_lto = false;227 check_case_exe.want_lto = false;
...@@ -347,7 +347,7 @@ pub fn build(b: *std.Build) !void {...@@ -347,7 +347,7 @@ pub fn build(b: *std.Build) !void {
347 try addStaticLlvmOptionsToExe(exe);347 try addStaticLlvmOptionsToExe(exe);
348 try addStaticLlvmOptionsToExe(check_case_exe);348 try addStaticLlvmOptionsToExe(check_case_exe);
349 }349 }
350 if (target.target.os.tag == .windows) {350 if (target.result.os.tag == .windows) {
351 inline for (.{ exe, check_case_exe }) |artifact| {351 inline for (.{ exe, check_case_exe }) |artifact| {
352 artifact.linkSystemLibrary("version");352 artifact.linkSystemLibrary("version");
353 artifact.linkSystemLibrary("uuid");353 artifact.linkSystemLibrary("uuid");
...@@ -371,7 +371,7 @@ pub fn build(b: *std.Build) !void {...@@ -371,7 +371,7 @@ pub fn build(b: *std.Build) !void {
371 );371 );
372372
373 // On mingw, we need to opt into windows 7+ to get some features required by tracy.373 // On mingw, we need to opt into windows 7+ to get some features required by tracy.
374 const tracy_c_flags: []const []const u8 = if (target.target.os.tag == .windows and target.target.abi == .gnu)374 const tracy_c_flags: []const []const u8 = if (target.result.os.tag == .windows and target.result.abi == .gnu)
375 &[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined", "-D_WIN32_WINNT=0x601" }375 &[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined", "-D_WIN32_WINNT=0x601" }
376 else376 else
377 &[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined" };377 &[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined" };
...@@ -383,7 +383,7 @@ pub fn build(b: *std.Build) !void {...@@ -383,7 +383,7 @@ pub fn build(b: *std.Build) !void {
383 }383 }
384 exe.linkLibC();384 exe.linkLibC();
385385
386 if (target.target.os.tag == .windows) {386 if (target.result.os.tag == .windows) {
387 exe.linkSystemLibrary("dbghelp");387 exe.linkSystemLibrary("dbghelp");
388 exe.linkSystemLibrary("ws2_32");388 exe.linkSystemLibrary("ws2_32");
389 }389 }
lib/build_runner.zig+1-1
...@@ -48,7 +48,7 @@ pub fn main() !void {...@@ -48,7 +48,7 @@ pub fn main() !void {
4848
49 const host: std.Build.ResolvedTarget = .{49 const host: std.Build.ResolvedTarget = .{
50 .query = .{},50 .query = .{},
51 .target = try std.zig.system.resolveTargetQuery(.{}),51 .result = try std.zig.system.resolveTargetQuery(.{}),
52 };52 };
5353
54 const build_root_directory: std.Build.Cache.Directory = .{54 const build_root_directory: std.Build.Cache.Directory = .{
lib/std/Build.zig+2-2
...@@ -2044,7 +2044,7 @@ pub fn hex64(x: u64) [16]u8 {...@@ -2044,7 +2044,7 @@ pub fn hex64(x: u64) [16]u8 {
2044/// of the target are "native". This can apply to the CPU, the OS, or even the ABI.2044/// of the target are "native". This can apply to the CPU, the OS, or even the ABI.
2045pub const ResolvedTarget = struct {2045pub const ResolvedTarget = struct {
2046 query: Target.Query,2046 query: Target.Query,
2047 target: Target,2047 result: Target,
2048};2048};
20492049
2050/// Converts a target query into a fully resolved target that can be passed to2050/// Converts a target query into a fully resolved target that can be passed to
...@@ -2056,7 +2056,7 @@ pub fn resolveTargetQuery(b: *Build, query: Target.Query) ResolvedTarget {...@@ -2056,7 +2056,7 @@ pub fn resolveTargetQuery(b: *Build, query: Target.Query) ResolvedTarget {
20562056
2057 return .{2057 return .{
2058 .query = query,2058 .query = query,
2059 .target = std.zig.system.resolveTargetQuery(query) catch2059 .result = std.zig.system.resolveTargetQuery(query) catch
2060 @panic("unable to resolve target query"),2060 @panic("unable to resolve target query"),
2061 };2061 };
2062}2062}
lib/std/Build/Module.zig+5-5
...@@ -10,7 +10,7 @@ root_source_file: ?LazyPath,...@@ -10,7 +10,7 @@ root_source_file: ?LazyPath,
10/// maintain step dependency edges.10/// maintain step dependency edges.
11import_table: std.StringArrayHashMapUnmanaged(*Module),11import_table: std.StringArrayHashMapUnmanaged(*Module),
1212
13target: ?std.Build.ResolvedTarget = null,13resolved_target: ?std.Build.ResolvedTarget = null,
14optimize: ?std.builtin.OptimizeMode = null,14optimize: ?std.builtin.OptimizeMode = null,
15dwarf_format: ?std.dwarf.Format,15dwarf_format: ?std.dwarf.Format,
1616
...@@ -192,7 +192,7 @@ pub fn init(m: *Module, owner: *std.Build, options: CreateOptions, compile: ?*St...@@ -192,7 +192,7 @@ pub fn init(m: *Module, owner: *std.Build, options: CreateOptions, compile: ?*St
192 .depending_steps = .{},192 .depending_steps = .{},
193 .root_source_file = if (options.root_source_file) |lp| lp.dupe(owner) else null,193 .root_source_file = if (options.root_source_file) |lp| lp.dupe(owner) else null,
194 .import_table = .{},194 .import_table = .{},
195 .target = options.target,195 .resolved_target = options.target,
196 .optimize = options.optimize,196 .optimize = options.optimize,
197 .link_libc = options.link_libc,197 .link_libc = options.link_libc,
198 .link_libcpp = options.link_libcpp,198 .link_libcpp = options.link_libcpp,
...@@ -627,7 +627,7 @@ pub fn appendZigProcessFlags(...@@ -627,7 +627,7 @@ pub fn appendZigProcessFlags(
627 try zig_args.append(@tagName(m.code_model));627 try zig_args.append(@tagName(m.code_model));
628 }628 }
629629
630 if (m.target) |*target| {630 if (m.resolved_target) |*target| {
631 // Communicate the query via CLI since it's more compact.631 // Communicate the query via CLI since it's more compact.
632 if (!target.query.isNative()) {632 if (!target.query.isNative()) {
633 try zig_args.appendSlice(&.{633 try zig_args.appendSlice(&.{
...@@ -737,9 +737,9 @@ fn linkLibraryOrObject(m: *Module, other: *Step.Compile) void {...@@ -737,9 +737,9 @@ fn linkLibraryOrObject(m: *Module, other: *Step.Compile) void {
737}737}
738738
739fn requireKnownTarget(m: *Module) std.Target {739fn requireKnownTarget(m: *Module) std.Target {
740 const resolved_target = m.target orelse740 const resolved_target = m.resolved_target orelse
741 @panic("this API requires the Module to be created with a known 'target' field");741 @panic("this API requires the Module to be created with a known 'target' field");
742 return resolved_target.target;742 return resolved_target.result;
743}743}
744744
745const Module = @This();745const Module = @This();
lib/std/Build/Step/Compile.zig+3-3
...@@ -251,7 +251,7 @@ pub fn create(owner: *std.Build, options: Options) *Compile {...@@ -251,7 +251,7 @@ pub fn create(owner: *std.Build, options: Options) *Compile {
251 else251 else
252 owner.fmt("{s} ", .{name});252 owner.fmt("{s} ", .{name});
253253
254 const target = options.root_module.target.?.target;254 const target = options.root_module.target.?.result;
255255
256 const step_name = owner.fmt("{s} {s}{s} {s}", .{256 const step_name = owner.fmt("{s} {s}{s} {s}", .{
257 switch (options.kind) {257 switch (options.kind) {
...@@ -954,7 +954,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -954,7 +954,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
954 try addFlag(&zig_args, "llvm", self.use_llvm);954 try addFlag(&zig_args, "llvm", self.use_llvm);
955 try addFlag(&zig_args, "lld", self.use_lld);955 try addFlag(&zig_args, "lld", self.use_lld);
956956
957 if (self.root_module.target.?.query.ofmt) |ofmt| {957 if (self.root_module.resolved_target.?.query.ofmt) |ofmt| {
958 try zig_args.append(try std.fmt.allocPrint(b.allocator, "-ofmt={s}", .{@tagName(ofmt)}));958 try zig_args.append(try std.fmt.allocPrint(b.allocator, "-ofmt={s}", .{@tagName(ofmt)}));
959 }959 }
960960
...@@ -1845,5 +1845,5 @@ fn matchCompileError(actual: []const u8, expected: []const u8) bool {...@@ -1845,5 +1845,5 @@ fn matchCompileError(actual: []const u8, expected: []const u8) bool {
18451845
1846pub fn rootModuleTarget(c: *Compile) std.Target {1846pub fn rootModuleTarget(c: *Compile) std.Target {
1847 // The root module is always given a target, so we know this to be non-null.1847 // The root module is always given a target, so we know this to be non-null.
1848 return c.root_module.target.?.target;1848 return c.root_module.resolved_target.?.result;
1849}1849}
lib/std/Build/Step/Run.zig+8-6
...@@ -678,8 +678,8 @@ fn runCommand(...@@ -678,8 +678,8 @@ fn runCommand(
678678
679 const need_cross_glibc = exe.rootModuleTarget().isGnuLibC() and679 const need_cross_glibc = exe.rootModuleTarget().isGnuLibC() and
680 exe.is_linking_libc;680 exe.is_linking_libc;
681 const other_target = exe.root_module.target.?.target;681 const other_target = exe.root_module.resolved_target.?.result;
682 switch (std.zig.system.getExternalExecutor(b.host.target, &other_target, .{682 switch (std.zig.system.getExternalExecutor(b.host.result, &other_target, .{
683 .qemu_fixes_dl = need_cross_glibc and b.glibc_runtimes_dir != null,683 .qemu_fixes_dl = need_cross_glibc and b.glibc_runtimes_dir != null,
684 .link_libc = exe.is_linking_libc,684 .link_libc = exe.is_linking_libc,
685 })) {685 })) {
...@@ -752,7 +752,7 @@ fn runCommand(...@@ -752,7 +752,7 @@ fn runCommand(
752 .bad_dl => |foreign_dl| {752 .bad_dl => |foreign_dl| {
753 if (allow_skip) return error.MakeSkipped;753 if (allow_skip) return error.MakeSkipped;
754754
755 const host_dl = b.host.target.dynamic_linker.get() orelse "(none)";755 const host_dl = b.host.result.dynamic_linker.get() orelse "(none)";
756756
757 return step.fail(757 return step.fail(
758 \\the host system is unable to execute binaries from the target758 \\the host system is unable to execute binaries from the target
...@@ -764,7 +764,7 @@ fn runCommand(...@@ -764,7 +764,7 @@ fn runCommand(
764 .bad_os_or_cpu => {764 .bad_os_or_cpu => {
765 if (allow_skip) return error.MakeSkipped;765 if (allow_skip) return error.MakeSkipped;
766766
767 const host_name = try b.host.target.zigTriple(b.allocator);767 const host_name = try b.host.result.zigTriple(b.allocator);
768 const foreign_name = try exe.rootModuleTarget().zigTriple(b.allocator);768 const foreign_name = try exe.rootModuleTarget().zigTriple(b.allocator);
769769
770 return step.fail("the host system ({s}) is unable to execute binaries from the target ({s})", .{770 return step.fail("the host system ({s}) is unable to execute binaries from the target ({s})", .{
...@@ -1295,7 +1295,9 @@ fn addPathForDynLibs(self: *Run, artifact: *Step.Compile) void {...@@ -1295,7 +1295,9 @@ fn addPathForDynLibs(self: *Run, artifact: *Step.Compile) void {
1295 while (it.next()) |item| {1295 while (it.next()) |item| {
1296 const other = item.compile.?;1296 const other = item.compile.?;
1297 if (item.module == &other.root_module) {1297 if (item.module == &other.root_module) {
1298 if (item.module.target.?.target.os.tag == .windows and other.isDynamicLibrary()) {1298 if (item.module.resolved_target.?.result.os.tag == .windows and
1299 other.isDynamicLibrary())
1300 {
1299 addPathDir(self, fs.path.dirname(other.getEmittedBin().getPath(b)).?);1301 addPathDir(self, fs.path.dirname(other.getEmittedBin().getPath(b)).?);
1300 }1302 }
1301 }1303 }
...@@ -1314,7 +1316,7 @@ fn failForeign(...@@ -1314,7 +1316,7 @@ fn failForeign(
1314 return error.MakeSkipped;1316 return error.MakeSkipped;
13151317
1316 const b = self.step.owner;1318 const b = self.step.owner;
1317 const host_name = try b.host.target.zigTriple(b.allocator);1319 const host_name = try b.host.result.zigTriple(b.allocator);
1318 const foreign_name = try exe.rootModuleTarget().zigTriple(b.allocator);1320 const foreign_name = try exe.rootModuleTarget().zigTriple(b.allocator);
13191321
1320 return self.step.fail(1322 return self.step.fail(
test/link/elf.zig+1-1
...@@ -1763,7 +1763,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {...@@ -1763,7 +1763,7 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {
1763 exe.addObject(g_o);1763 exe.addObject(g_o);
1764 exe.addObject(h_o);1764 exe.addObject(h_o);
17651765
1766 if (opts.target.target.isGnuLibC()) {1766 if (opts.target.result.isGnuLibC()) {
1767 // TODO I think we need to clarify our use of `-fPIC -fPIE` flags for different targets1767 // TODO I think we need to clarify our use of `-fPIC -fPIE` flags for different targets
1768 exe.pie = true;1768 exe.pie = true;
1769 }1769 }
test/link/link.zig+1-1
...@@ -14,7 +14,7 @@ pub const Options = struct {...@@ -14,7 +14,7 @@ pub const Options = struct {
14};14};
1515
16pub fn addTestStep(b: *Build, prefix: []const u8, opts: Options) *Step {16pub fn addTestStep(b: *Build, prefix: []const u8, opts: Options) *Step {
17 const target = opts.target.target.zigTriple(b.allocator) catch @panic("OOM");17 const target = opts.target.result.zigTriple(b.allocator) catch @panic("OOM");
18 const optimize = @tagName(opts.optimize);18 const optimize = @tagName(opts.optimize);
19 const use_llvm = if (opts.use_llvm) "llvm" else "no-llvm";19 const use_llvm = if (opts.use_llvm) "llvm" else "no-llvm";
20 const name = std.fmt.allocPrint(b.allocator, "test-{s}-{s}-{s}-{s}", .{20 const name = std.fmt.allocPrint(b.allocator, "test-{s}-{s}-{s}-{s}", .{
test/link/macho/bugs/13056/build.zig+1-1
...@@ -15,7 +15,7 @@ pub fn build(b: *std.Build) void {...@@ -15,7 +15,7 @@ pub fn build(b: *std.Build) void {
1515
16fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {16fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
17 const target = b.resolveTargetQuery(.{ .os_tag = .macos });17 const target = b.resolveTargetQuery(.{ .os_tag = .macos });
18 const sdk = std.zig.system.darwin.getSdk(b.allocator, target.target) orelse18 const sdk = std.zig.system.darwin.getSdk(b.allocator, target.result) orelse
19 @panic("macOS SDK is required to run the test");19 @panic("macOS SDK is required to run the test");
2020
21 const exe = b.addExecutable(.{21 const exe = b.addExecutable(.{
test/src/Cases.zig+5-5
...@@ -467,7 +467,7 @@ fn addFromDirInner(...@@ -467,7 +467,7 @@ fn addFromDirInner(
467 // Cross-product to get all possible test combinations467 // Cross-product to get all possible test combinations
468 for (targets) |target_query| {468 for (targets) |target_query| {
469 const resolved_target = b.resolveTargetQuery(target_query);469 const resolved_target = b.resolveTargetQuery(target_query);
470 const target = resolved_target.target;470 const target = resolved_target.result;
471 for (backends) |backend| {471 for (backends) |backend| {
472 if (backend == .stage2 and472 if (backend == .stage2 and
473 target.cpu.arch != .wasm32 and target.cpu.arch != .x86_64)473 target.cpu.arch != .wasm32 and target.cpu.arch != .x86_64)
...@@ -647,8 +647,8 @@ pub fn lowerToBuildSteps(...@@ -647,8 +647,8 @@ pub fn lowerToBuildSteps(
647 parent_step.dependOn(&artifact.step);647 parent_step.dependOn(&artifact.step);
648 },648 },
649 .Execution => |expected_stdout| no_exec: {649 .Execution => |expected_stdout| no_exec: {
650 const run = if (case.target.target.ofmt == .c) run_step: {650 const run = if (case.target.result.ofmt == .c) run_step: {
651 if (getExternalExecutor(host, &case.target.target, .{ .link_libc = true }) != .native) {651 if (getExternalExecutor(host, &case.target.result, .{ .link_libc = true }) != .native) {
652 // We wouldn't be able to run the compiled C code.652 // We wouldn't be able to run the compiled C code.
653 break :no_exec;653 break :no_exec;
654 }654 }
...@@ -667,7 +667,7 @@ pub fn lowerToBuildSteps(...@@ -667,7 +667,7 @@ pub fn lowerToBuildSteps(
667 "--",667 "--",
668 "-lc",668 "-lc",
669 "-target",669 "-target",
670 case.target.target.zigTriple(b.allocator) catch @panic("OOM"),670 case.target.result.zigTriple(b.allocator) catch @panic("OOM"),
671 });671 });
672 run_c.addArtifactArg(artifact);672 run_c.addArtifactArg(artifact);
673 break :run_step run_c;673 break :run_step run_c;
...@@ -693,7 +693,7 @@ pub fn lowerToBuildSteps(...@@ -693,7 +693,7 @@ pub fn lowerToBuildSteps(
693 continue; // Pass test.693 continue; // Pass test.
694 }694 }
695695
696 if (getExternalExecutor(host, &case.target.target, .{ .link_libc = true }) != .native) {696 if (getExternalExecutor(host, &case.target.result, .{ .link_libc = true }) != .native) {
697 // We wouldn't be able to run the compiled C code.697 // We wouldn't be able to run the compiled C code.
698 continue; // Pass test.698 continue; // Pass test.
699 }699 }
test/standalone/c_compiler/build.zig+1-1
...@@ -42,7 +42,7 @@ fn add(...@@ -42,7 +42,7 @@ fn add(
42 exe_cpp.addCSourceFile(.{ .file = .{ .path = "test.cpp" }, .flags = &[0][]const u8{} });42 exe_cpp.addCSourceFile(.{ .file = .{ .path = "test.cpp" }, .flags = &[0][]const u8{} });
43 exe_cpp.linkLibCpp();43 exe_cpp.linkLibCpp();
4444
45 switch (target.target.os.tag) {45 switch (target.result.os.tag) {
46 .windows => {46 .windows => {
47 // https://github.com/ziglang/zig/issues/853147 // https://github.com/ziglang/zig/issues/8531
48 exe_cpp.want_lto = false;48 exe_cpp.want_lto = false;
test/standalone/compiler_rt_panic/build.zig+4-4
...@@ -4,16 +4,16 @@ pub fn build(b: *std.Build) void {...@@ -4,16 +4,16 @@ pub fn build(b: *std.Build) void {
4 const test_step = b.step("test", "Test it");4 const test_step = b.step("test", "Test it");
5 b.default_step = test_step;5 b.default_step = test_step;
66
7 const resolved_target = b.standardTargetOptions(.{});7 const target = b.standardTargetOptions(.{});
8 const target = resolved_target.target;
9 const optimize = b.standardOptimizeOption(.{});8 const optimize = b.standardOptimizeOption(.{});
109
11 if (target.ofmt != .elf or !(target.abi.isMusl() or target.abi.isGnu())) return;10 if (target.result.ofmt != .elf or !(target.result.abi.isMusl() or target.result.abi.isGnu()))
11 return;
1212
13 const exe = b.addExecutable(.{13 const exe = b.addExecutable(.{
14 .name = "main",14 .name = "main",
15 .optimize = optimize,15 .optimize = optimize,
16 .target = resolved_target,16 .target = target,
17 });17 });
18 exe.linkLibC();18 exe.linkLibC();
19 exe.addCSourceFile(.{19 exe.addCSourceFile(.{
test/standalone/ios/build.zig+1-1
...@@ -12,7 +12,7 @@ pub fn build(b: *std.Build) void {...@@ -12,7 +12,7 @@ pub fn build(b: *std.Build) void {
12 .cpu_arch = .aarch64,12 .cpu_arch = .aarch64,
13 .os_tag = .ios,13 .os_tag = .ios,
14 });14 });
15 const sdk = std.zig.system.darwin.getSdk(b.allocator, target.target) orelse15 const sdk = std.zig.system.darwin.getSdk(b.allocator, target.result) orelse
16 @panic("no iOS SDK found");16 @panic("no iOS SDK found");
17 b.sysroot = sdk;17 b.sysroot = sdk;
1818
test/standalone/self_exe_symlink/build.zig+1-1
...@@ -11,7 +11,7 @@ pub fn build(b: *std.Build) void {...@@ -11,7 +11,7 @@ pub fn build(b: *std.Build) void {
1111
12 // The test requires getFdPath in order to to get the path of the12 // The test requires getFdPath in order to to get the path of the
13 // File returned by openSelfExe13 // File returned by openSelfExe
14 if (!std.os.isGetFdPathSupportedOnTarget(target.target.os)) return;14 if (!std.os.isGetFdPathSupportedOnTarget(target.result.os)) return;
1515
16 const main = b.addExecutable(.{16 const main = b.addExecutable(.{
17 .name = "main",17 .name = "main",
test/standalone/stack_iterator/build.zig+3-3
...@@ -22,7 +22,7 @@ pub fn build(b: *std.Build) void {...@@ -22,7 +22,7 @@ pub fn build(b: *std.Build) void {
22 .root_source_file = .{ .path = "unwind.zig" },22 .root_source_file = .{ .path = "unwind.zig" },
23 .target = target,23 .target = target,
24 .optimize = optimize,24 .optimize = optimize,
25 .unwind_tables = target.target.isDarwin(),25 .unwind_tables = target.result.isDarwin(),
26 .omit_frame_pointer = false,26 .omit_frame_pointer = false,
27 });27 });
2828
...@@ -70,7 +70,7 @@ pub fn build(b: *std.Build) void {...@@ -70,7 +70,7 @@ pub fn build(b: *std.Build) void {
70 .strip = false,70 .strip = false,
71 });71 });
7272
73 if (target.target.os.tag == .windows)73 if (target.result.os.tag == .windows)
74 c_shared_lib.defineCMacro("LIB_API", "__declspec(dllexport)");74 c_shared_lib.defineCMacro("LIB_API", "__declspec(dllexport)");
7575
76 c_shared_lib.addCSourceFile(.{76 c_shared_lib.addCSourceFile(.{
...@@ -84,7 +84,7 @@ pub fn build(b: *std.Build) void {...@@ -84,7 +84,7 @@ pub fn build(b: *std.Build) void {
84 .root_source_file = .{ .path = "shared_lib_unwind.zig" },84 .root_source_file = .{ .path = "shared_lib_unwind.zig" },
85 .target = target,85 .target = target,
86 .optimize = optimize,86 .optimize = optimize,
87 .unwind_tables = target.target.isDarwin(),87 .unwind_tables = target.result.isDarwin(),
88 .omit_frame_pointer = true,88 .omit_frame_pointer = true,
89 });89 });
9090
test/tests.zig+2-2
...@@ -1043,7 +1043,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {...@@ -1043,7 +1043,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
1043 continue;1043 continue;
10441044
1045 const resolved_target = b.resolveTargetQuery(test_target.target);1045 const resolved_target = b.resolveTargetQuery(test_target.target);
1046 const target = resolved_target.target;1046 const target = resolved_target.result;
10471047
1048 if (options.skip_cross_glibc and !test_target.target.isNative() and1048 if (options.skip_cross_glibc and !test_target.target.isNative() and
1049 target.isGnuLibC() and test_target.link_libc == true)1049 target.isGnuLibC() and test_target.link_libc == true)
...@@ -1229,7 +1229,7 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S...@@ -1229,7 +1229,7 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S
1229 if (skip_non_native and !c_abi_target.target.isNative()) continue;1229 if (skip_non_native and !c_abi_target.target.isNative()) continue;
12301230
1231 const resolved_target = b.resolveTargetQuery(c_abi_target.target);1231 const resolved_target = b.resolveTargetQuery(c_abi_target.target);
1232 const target = resolved_target.target;1232 const target = resolved_target.result;
12331233
1234 if (target.os.tag == .windows and target.cpu.arch == .aarch64) {1234 if (target.os.tag == .windows and target.cpu.arch == .aarch64) {
1235 // https://github.com/ziglang/zig/issues/149081235 // https://github.com/ziglang/zig/issues/14908