authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-01-24 03:45:38+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-02-17 19:18:19+01:00
log481b7bf3f095488a89e20d88ada092529bc6e6f8
tree9e4dde982be4327fb18d156d7b3540c8d03ce658
parente62352611faf3056b989cc1edaa4aedaa74f326e
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.Target: Remove functions that just wrap component functions.

Functions like isMinGW() and isGnuLibC() have a good reason to exist: They look at multiple components of the target. But functions like isWasm(), isDarwin(), isGnu(), etc only exist to save 4-8 characters. I don't think this is a good enough reason to keep them, especially given that: * It's not immediately obvious to a reader whether target.isDarwin() means the same thing as target.os.tag.isDarwin() precisely because isMinGW() and similar functions *do* look at multiple components. * It's not clear where we would draw the line. The logical conclusion before this commit would be to also wrap Arch.isX86(), Os.Tag.isSolarish(), Abi.isOpenHarmony(), etc... this obviously quickly gets out of hand. * It's nice to just have a single correct way of doing something.

48 files changed, 149 insertions(+), 178 deletions(-)

build.zig+1-1
......@@ -742,7 +742,7 @@ fn addCmakeCfgOptionsToExe(
742742 const mod = exe.root_module;
743743 const target = mod.resolved_target.?.result;
744744
745 if (target.isDarwin()) {
745 if (target.os.tag.isDarwin()) {
746746 // useful for package maintainers
747747 exe.headerpad_max_install_names = true;
748748 }
lib/compiler/aro/aro/Compilation.zig+2-2
......@@ -308,7 +308,7 @@ fn generateSystemDefines(comp: *Compilation, w: anytype) !void {
308308 ),
309309 else => {},
310310 }
311 if (comp.target.isAndroid()) {
311 if (comp.target.abi.isAndroid()) {
312312 try w.writeAll("#define __ANDROID__ 1\n");
313313 }
314314
......@@ -734,7 +734,7 @@ pub fn float80Type(comp: *const Compilation) ?Type {
734734
735735/// Smallest integer type with at least N bits
736736pub fn intLeastN(comp: *const Compilation, bits: usize, signedness: std.builtin.Signedness) Type {
737 if (bits == 64 and (comp.target.isDarwin() or comp.target.isWasm())) {
737 if (bits == 64 and (comp.target.os.tag.isDarwin() or comp.target.cpu.arch.isWasm())) {
738738 // WebAssembly and Darwin use `long long` for `int_least64_t` and `int_fast64_t`.
739739 return .{ .specifier = if (signedness == .signed) .long_long else .ulong_long };
740740 }
lib/compiler/aro/aro/Driver/GCCDetector.zig+1-1
......@@ -183,7 +183,7 @@ fn collectLibDirsAndTriples(
183183 // TODO
184184 return;
185185 }
186 if (target.isAndroid()) {
186 if (target.abi.isAndroid()) {
187187 const AArch64AndroidTriples: [1][]const u8 = .{"aarch64-linux-android"};
188188 const ARMAndroidTriples: [1][]const u8 = .{"arm-linux-androideabi"};
189189 const MIPSELAndroidTriples: [1][]const u8 = .{"mipsel-linux-android"};
lib/compiler/aro/aro/Toolchain.zig+7-7
......@@ -161,7 +161,7 @@ pub fn getLinkerPath(tc: *const Toolchain, buf: []u8) ![]const u8 {
161161 } else {
162162 var linker_name = try std.ArrayList(u8).initCapacity(tc.driver.comp.gpa, 5 + use_linker.len); // "ld64." ++ use_linker
163163 defer linker_name.deinit();
164 if (tc.getTarget().isDarwin()) {
164 if (tc.getTarget().os.tag.isDarwin()) {
165165 linker_name.appendSliceAssumeCapacity("ld64.");
166166 } else {
167167 linker_name.appendSliceAssumeCapacity("ld.");
......@@ -343,7 +343,7 @@ pub fn buildLinkerArgs(tc: *Toolchain, argv: *std.ArrayList([]const u8)) !void {
343343}
344344
345345fn getDefaultRuntimeLibKind(tc: *const Toolchain) RuntimeLibKind {
346 if (tc.getTarget().isAndroid()) {
346 if (tc.getTarget().abi.isAndroid()) {
347347 return .compiler_rt;
348348 }
349349 return .libgcc;
......@@ -369,7 +369,7 @@ pub fn getCompilerRt(tc: *const Toolchain, component: []const u8, file_kind: Fil
369369
370370fn getLibGCCKind(tc: *const Toolchain) LibGCCKind {
371371 const target = tc.getTarget();
372 if (tc.driver.static_libgcc or tc.driver.static or tc.driver.static_pie or target.isAndroid()) {
372 if (tc.driver.static_libgcc or tc.driver.static or tc.driver.static_pie or target.abi.isAndroid()) {
373373 return .static;
374374 }
375375 if (tc.driver.shared_libgcc) {
......@@ -384,7 +384,7 @@ fn getUnwindLibKind(tc: *const Toolchain) !UnwindLibKind {
384384 switch (tc.getRuntimeLibKind()) {
385385 .compiler_rt => {
386386 const target = tc.getTarget();
387 if (target.isAndroid() or target.os.tag == .aix) {
387 if (target.abi.isAndroid() or target.os.tag == .aix) {
388388 return .compiler_rt;
389389 } else {
390390 return .none;
......@@ -417,14 +417,14 @@ fn getAsNeededOption(is_solaris: bool, needed: bool) []const u8 {
417417fn addUnwindLibrary(tc: *const Toolchain, argv: *std.ArrayList([]const u8)) !void {
418418 const unw = try tc.getUnwindLibKind();
419419 const target = tc.getTarget();
420 if ((target.isAndroid() and unw == .libgcc) or
420 if ((target.abi.isAndroid() and unw == .libgcc) or
421421 target.os.tag == .elfiamcu or
422422 target.ofmt == .wasm or
423423 target_util.isWindowsMSVCEnvironment(target) or
424424 unw == .none) return;
425425
426426 const lgk = tc.getLibGCCKind();
427 const as_needed = lgk == .unspecified and !target.isAndroid() and !target_util.isCygwinMinGW(target) and target.os.tag != .aix;
427 const as_needed = lgk == .unspecified and !target.abi.isAndroid() and !target_util.isCygwinMinGW(target) and target.os.tag != .aix;
428428 if (as_needed) {
429429 try argv.append(getAsNeededOption(target.os.tag == .solaris, true));
430430 }
......@@ -483,7 +483,7 @@ pub fn addRuntimeLibs(tc: *const Toolchain, argv: *std.ArrayList([]const u8)) !v
483483 },
484484 }
485485
486 if (target.isAndroid() and !tc.driver.static and !tc.driver.static_pie) {
486 if (target.abi.isAndroid() and !tc.driver.static and !tc.driver.static_pie) {
487487 try argv.append("-ldl");
488488 }
489489}
lib/compiler/aro/aro/Type.zig+1-1
......@@ -1102,7 +1102,7 @@ pub fn alignof(ty: Type, comp: *const Compilation) u29 {
11021102 .double => comp.target.cTypeAlignment(.double),
11031103 .long_double => comp.target.cTypeAlignment(.longdouble),
11041104
1105 .int128, .uint128 => if (comp.target.cpu.arch == .s390x and comp.target.os.tag == .linux and comp.target.isGnu()) 8 else 16,
1105 .int128, .uint128 => if (comp.target.cpu.arch == .s390x and comp.target.os.tag == .linux and comp.target.abi.isGnu()) 8 else 16,
11061106 .fp16, .float16 => 2,
11071107
11081108 .float128 => 16,
lib/compiler/aro/aro/target.zig+8-9
......@@ -117,8 +117,8 @@ pub fn int64Type(target: std.Target) Type {
117117
118118 .sparc64 => return intMaxType(target),
119119
120 .x86, .x86_64 => if (!target.isDarwin()) return intMaxType(target),
121 .aarch64, .aarch64_be => if (!target.isDarwin() and target.os.tag != .openbsd and target.os.tag != .windows) return .{ .specifier = .long },
120 .x86, .x86_64 => if (!target.os.tag.isDarwin()) return intMaxType(target),
121 .aarch64, .aarch64_be => if (!target.os.tag.isDarwin() and target.os.tag != .openbsd and target.os.tag != .windows) return .{ .specifier = .long },
122122 else => {},
123123 }
124124 return .{ .specifier = .long_long };
......@@ -144,7 +144,7 @@ pub fn defaultFunctionAlignment(target: std.Target) u8 {
144144}
145145
146146pub fn isTlsSupported(target: std.Target) bool {
147 if (target.isDarwin()) {
147 if (target.os.tag.isDarwin()) {
148148 var supported = false;
149149 switch (target.os.tag) {
150150 .macos => supported = !(target.os.isAtLeast(.macos, .{ .major = 10, .minor = 7, .patch = 0 }) orelse false),
......@@ -199,7 +199,7 @@ pub fn minZeroWidthBitfieldAlignment(target: std.Target) ?u29 {
199199pub fn unnamedFieldAffectsAlignment(target: std.Target) bool {
200200 switch (target.cpu.arch) {
201201 .aarch64 => {
202 if (target.isDarwin() or target.os.tag == .windows) return false;
202 if (target.os.tag.isDarwin() or target.os.tag == .windows) return false;
203203 return true;
204204 },
205205 .armeb => {
......@@ -229,7 +229,7 @@ pub fn packAllEnums(target: std.Target) bool {
229229pub fn defaultAlignment(target: std.Target) u29 {
230230 switch (target.cpu.arch) {
231231 .avr => return 1,
232 .arm => if (target.isAndroid() or target.os.tag == .ios) return 16 else return 8,
232 .arm => if (target.abi.isAndroid() or target.os.tag == .ios) return 16 else return 8,
233233 .sparc => if (std.Target.sparc.featureSetHas(target.cpu.features, .v9)) return 16 else return 8,
234234 .mips, .mipsel => switch (target.abi) {
235235 .none, .gnuabi64 => return 16,
......@@ -242,9 +242,8 @@ pub fn defaultAlignment(target: std.Target) u29 {
242242pub fn systemCompiler(target: std.Target) LangOpts.Compiler {
243243 // Android is linux but not gcc, so these checks go first
244244 // the rest for documentation as fn returns .clang
245 if (target.isDarwin() or
246 target.isAndroid() or
247 target.isBSD() or
245 if (target.abi.isAndroid() or
246 target.os.tag.isBSD() or
248247 target.os.tag == .fuchsia or
249248 target.os.tag == .solaris or
250249 target.os.tag == .haiku or
......@@ -268,7 +267,7 @@ pub fn systemCompiler(target: std.Target) LangOpts.Compiler {
268267
269268pub fn hasFloat128(target: std.Target) bool {
270269 if (target.cpu.arch.isWasm()) return true;
271 if (target.isDarwin()) return false;
270 if (target.os.tag.isDarwin()) return false;
272271 if (target.cpu.arch.isPowerPC()) return std.Target.powerpc.featureSetHas(target.cpu.features, .float128);
273272 return switch (target.os.tag) {
274273 .dragonfly,
lib/compiler/aro/aro/toolchains/Linux.zig+7-7
......@@ -27,7 +27,7 @@ pub fn discover(self: *Linux, tc: *Toolchain) !void {
2727fn buildExtraOpts(self: *Linux, tc: *const Toolchain) !void {
2828 const gpa = tc.driver.comp.gpa;
2929 const target = tc.getTarget();
30 const is_android = target.isAndroid();
30 const is_android = target.abi.isAndroid();
3131 if (self.distro.isAlpine() or is_android) {
3232 try self.extra_opts.ensureUnusedCapacity(gpa, 2);
3333 self.extra_opts.appendAssumeCapacity("-z");
......@@ -113,7 +113,7 @@ fn findPaths(self: *Linux, tc: *Toolchain) !void {
113113 try tc.addPathIfExists(&.{ sysroot, "/lib", multiarch_triple }, .file);
114114 try tc.addPathIfExists(&.{ sysroot, "/lib", "..", os_lib_dir }, .file);
115115
116 if (target.isAndroid()) {
116 if (target.abi.isAndroid()) {
117117 // TODO
118118 }
119119 try tc.addPathIfExists(&.{ sysroot, "/usr", "lib", multiarch_triple }, .file);
......@@ -156,7 +156,7 @@ fn getStatic(self: *const Linux, d: *const Driver) bool {
156156
157157pub fn getDefaultLinker(self: *const Linux, target: std.Target) []const u8 {
158158 _ = self;
159 if (target.isAndroid()) {
159 if (target.abi.isAndroid()) {
160160 return "ld.lld";
161161 }
162162 return "ld";
......@@ -169,7 +169,7 @@ pub fn buildLinkerArgs(self: *const Linux, tc: *const Toolchain, argv: *std.Arra
169169 const is_pie = self.getPIE(d);
170170 const is_static_pie = try self.getStaticPIE(d);
171171 const is_static = self.getStatic(d);
172 const is_android = target.isAndroid();
172 const is_android = target.abi.isAndroid();
173173 const is_iamcu = target.os.tag == .elfiamcu;
174174 const is_ve = target.cpu.arch == .ve;
175175 const has_crt_begin_end_files = target.abi != .none; // TODO: clang checks for MIPS vendor
......@@ -326,7 +326,7 @@ pub fn buildLinkerArgs(self: *const Linux, tc: *const Toolchain, argv: *std.Arra
326326}
327327
328328fn getMultiarchTriple(target: std.Target) ?[]const u8 {
329 const is_android = target.isAndroid();
329 const is_android = target.abi.isAndroid();
330330 const is_mips_r6 = std.Target.mips.featureSetHas(target.cpu.features, .mips32r6);
331331 return switch (target.cpu.arch) {
332332 .arm, .thumb => if (is_android) "arm-linux-androideabi" else if (target.abi == .gnueabihf) "arm-linux-gnueabihf" else "arm-linux-gnueabi",
......@@ -380,7 +380,7 @@ pub fn defineSystemIncludes(self: *const Linux, tc: *const Toolchain) !void {
380380
381381 // musl prefers /usr/include before builtin includes, so musl targets will add builtins
382382 // at the end of this function (unless disabled with nostdlibinc)
383 if (!tc.driver.nobuiltininc and (!target.isMusl() or tc.driver.nostdlibinc)) {
383 if (!tc.driver.nobuiltininc and (!target.abi.isMusl() or tc.driver.nostdlibinc)) {
384384 try comp.addBuiltinIncludeDir(tc.driver.aro_name);
385385 }
386386
......@@ -411,7 +411,7 @@ pub fn defineSystemIncludes(self: *const Linux, tc: *const Toolchain) !void {
411411 try comp.addSystemIncludeDir("/usr/include");
412412
413413 std.debug.assert(!tc.driver.nostdlibinc);
414 if (!tc.driver.nobuiltininc and target.isMusl()) {
414 if (!tc.driver.nobuiltininc and target.abi.isMusl()) {
415415 try comp.addBuiltinIncludeDir(tc.driver.aro_name);
416416 }
417417}
lib/compiler_rt/common.zig+3-3
......@@ -14,7 +14,7 @@ else
1414/// For WebAssembly this allows the symbol to be resolved to other modules, but will not
1515/// export it to the host runtime.
1616pub const visibility: std.builtin.SymbolVisibility =
17 if (builtin.target.isWasm() and linkage != .internal) .hidden else .default;
17 if (builtin.target.cpu.arch.isWasm() and linkage != .internal) .hidden else .default;
1818
1919pub const want_aeabi = switch (builtin.abi) {
2020 .eabi,
......@@ -92,7 +92,7 @@ pub const panic = if (builtin.is_test) std.debug.FullPanic(std.debug.defaultPani
9292pub fn F16T(comptime OtherType: type) type {
9393 return switch (builtin.cpu.arch) {
9494 .arm, .armeb, .thumb, .thumbeb => if (std.Target.arm.featureSetHas(builtin.cpu.features, .has_v8))
95 switch (builtin.abi.floatAbi()) {
95 switch (builtin.abi.float()) {
9696 .soft => u16,
9797 .hard => f16,
9898 }
......@@ -100,7 +100,7 @@ pub fn F16T(comptime OtherType: type) type {
100100 u16,
101101 .aarch64, .aarch64_be => f16,
102102 .riscv32, .riscv64 => f16,
103 .x86, .x86_64 => if (builtin.target.isDarwin()) switch (OtherType) {
103 .x86, .x86_64 => if (builtin.target.os.tag.isDarwin()) switch (OtherType) {
104104 // Starting with LLVM 16, Darwin uses different abi for f16
105105 // depending on the type of the other return/argument..???
106106 f32, f64 => u16,
lib/std/Build/Step/Compile.zig+3-3
......@@ -465,7 +465,7 @@ pub fn create(owner: *std.Build, options: Options) *Compile {
465465 if (compile.linkage != null and compile.linkage.? == .static) {
466466 compile.out_lib_filename = compile.out_filename;
467467 } else if (compile.version) |version| {
468 if (target.isDarwin()) {
468 if (target.os.tag.isDarwin()) {
469469 compile.major_only_filename = owner.fmt("lib{s}.{d}.dylib", .{
470470 compile.name,
471471 version.major,
......@@ -480,7 +480,7 @@ pub fn create(owner: *std.Build, options: Options) *Compile {
480480 compile.out_lib_filename = compile.out_filename;
481481 }
482482 } else {
483 if (target.isDarwin()) {
483 if (target.os.tag.isDarwin()) {
484484 compile.out_lib_filename = compile.out_filename;
485485 } else if (target.os.tag == .windows) {
486486 compile.out_lib_filename = owner.fmt("{s}.lib", .{compile.name});
......@@ -1524,7 +1524,7 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {
15241524 try zig_args.append(b.fmt("{}", .{version}));
15251525 }
15261526
1527 if (compile.rootModuleTarget().isDarwin()) {
1527 if (compile.rootModuleTarget().os.tag.isDarwin()) {
15281528 const install_name = compile.install_name orelse b.fmt("@rpath/{s}{s}{s}", .{
15291529 compile.rootModuleTarget().libPrefix(),
15301530 compile.name,
lib/std/Target.zig+24-42
......@@ -144,10 +144,6 @@ pub const Os = struct {
144144 };
145145 }
146146
147 pub inline fn isGnuLibC(tag: Os.Tag, abi: Abi) bool {
148 return (tag == .hurd or tag == .linux) and abi.isGnu();
149 }
150
151147 pub fn defaultVersionRange(tag: Tag, arch: Cpu.Arch, abi: Abi) Os {
152148 return .{
153149 .tag = tag,
......@@ -973,7 +969,12 @@ pub const Abi = enum {
973969 };
974970 }
975971
976 pub inline fn floatAbi(abi: Abi) FloatAbi {
972 pub const Float = enum {
973 hard,
974 soft,
975 };
976
977 pub inline fn float(abi: Abi) Float {
977978 return switch (abi) {
978979 .androideabi,
979980 .eabi,
......@@ -2022,48 +2023,29 @@ pub fn libPrefix(target: Target) [:0]const u8 {
20222023}
20232024
20242025pub inline fn isMinGW(target: Target) bool {
2025 return target.os.tag == .windows and target.isGnu();
2026}
2027
2028pub inline fn isGnu(target: Target) bool {
2029 return target.abi.isGnu();
2030}
2031
2032pub inline fn isMusl(target: Target) bool {
2033 return target.abi.isMusl();
2034}
2035
2036pub inline fn isAndroid(target: Target) bool {
2037 return target.abi.isAndroid();
2038}
2039
2040pub inline fn isWasm(target: Target) bool {
2041 return target.cpu.arch.isWasm();
2042}
2043
2044pub inline fn isDarwin(target: Target) bool {
2045 return target.os.tag.isDarwin();
2046}
2047
2048pub inline fn isBSD(target: Target) bool {
2049 return target.os.tag.isBSD();
2026 return target.os.tag == .windows and target.abi.isGnu();
20502027}
20512028
20522029pub inline fn isGnuLibC(target: Target) bool {
2053 return target.os.tag.isGnuLibC(target.abi);
2030 return switch (target.os.tag) {
2031 .hurd, .linux => target.abi.isGnu(),
2032 else => false,
2033 };
20542034}
20552035
2056pub inline fn isSpirV(target: Target) bool {
2057 return target.cpu.arch.isSpirV();
2036pub inline fn isMuslLibC(target: Target) bool {
2037 return target.os.tag == .linux and target.abi.isMusl();
20582038}
20592039
2060pub const FloatAbi = enum {
2061 hard,
2062 soft,
2063};
2040pub inline fn isDarwinLibC(target: Target) bool {
2041 return switch (target.abi) {
2042 .none, .macabi, .simulator => target.os.tag.isDarwin(),
2043 else => false,
2044 };
2045}
20642046
2065pub inline fn floatAbi(target: Target) FloatAbi {
2066 return target.abi.floatAbi();
2047pub inline fn isWasiLibC(target: Target) bool {
2048 return target.os.tag == .wasi and target.abi.isMusl();
20672049}
20682050
20692051pub const DynamicLinker = struct {
......@@ -2699,7 +2681,7 @@ pub fn stackAlignment(target: Target) u16 {
26992681/// Note that char signedness is implementation-defined and many compilers provide
27002682/// an option to override the default signedness e.g. GCC's -funsigned-char / -fsigned-char
27012683pub fn charSignedness(target: Target) std.builtin.Signedness {
2702 if (target.isDarwin() or target.os.tag == .windows or target.os.tag == .uefi) return .signed;
2684 if (target.os.tag.isDarwin() or target.os.tag == .windows or target.os.tag == .uefi) return .signed;
27032685
27042686 return switch (target.cpu.arch) {
27052687 .arm,
......@@ -3292,7 +3274,7 @@ pub fn cCallingConvention(target: Target) ?std.builtin.CallingConvention {
32923274 .windows => .{ .aarch64_aapcs_win = .{} },
32933275 else => .{ .aarch64_aapcs = .{} },
32943276 },
3295 .arm, .armeb, .thumb, .thumbeb => switch (target.abi.floatAbi()) {
3277 .arm, .armeb, .thumb, .thumbeb => switch (target.abi.float()) {
32963278 .soft => .{ .arm_aapcs = .{} },
32973279 .hard => .{ .arm_aapcs_vfp = .{} },
32983280 },
......@@ -3305,7 +3287,7 @@ pub fn cCallingConvention(target: Target) ?std.builtin.CallingConvention {
33053287 .riscv32 => .{ .riscv32_ilp32 = .{} },
33063288 .sparc64 => .{ .sparc64_sysv = .{} },
33073289 .sparc => .{ .sparc_sysv = .{} },
3308 .powerpc64 => if (target.isMusl())
3290 .powerpc64 => if (target.abi.isMusl())
33093291 .{ .powerpc64_elf_v2 = .{} }
33103292 else
33113293 .{ .powerpc64_elf = .{} },
lib/std/Target/Query.zig+2-3
......@@ -26,7 +26,7 @@ os_version_min: ?OsVersion = null,
2626os_version_max: ?OsVersion = null,
2727
2828/// `null` means default when cross compiling, or native when `os_tag` is native.
29/// If `isGnuLibC()` is `false`, this must be `null` and is ignored.
29/// If `isGnu()` is `false`, this must be `null` and is ignored.
3030glibc_version: ?SemanticVersion = null,
3131
3232/// `null` means default when cross compiling, or native when `os_tag` is native.
......@@ -235,8 +235,7 @@ pub fn parse(args: ParseOptions) !Query {
235235
236236 const abi_ver_text = abi_it.rest();
237237 if (abi_it.next() != null) {
238 const tag = result.os_tag orelse builtin.os.tag;
239 if (tag.isGnuLibC(abi)) {
238 if (abi.isGnu()) {
240239 result.glibc_version = parseVersion(abi_ver_text) catch |err| switch (err) {
241240 error.Overflow => return error.InvalidAbiVersion,
242241 error.InvalidVersion => return error.InvalidAbiVersion,
lib/std/Thread.zig+1-1
......@@ -734,7 +734,7 @@ const PosixThreadImpl = struct {
734734 else => {
735735 var count: c_int = undefined;
736736 var count_len: usize = @sizeOf(c_int);
737 const name = if (comptime target.isDarwin()) "hw.logicalcpu" else "hw.ncpu";
737 const name = if (comptime target.os.tag.isDarwin()) "hw.logicalcpu" else "hw.ncpu";
738738 posix.sysctlbynameZ(name, &count, &count_len, null, 0) catch |err| switch (err) {
739739 error.NameTooLong, error.UnknownName => unreachable,
740740 else => |e| return e,
lib/std/Thread/Futex.zig+1-1
......@@ -80,7 +80,7 @@ else if (builtin.os.tag == .openbsd)
8080 OpenbsdImpl
8181else if (builtin.os.tag == .dragonfly)
8282 DragonflyImpl
83else if (builtin.target.isWasm())
83else if (builtin.target.cpu.arch.isWasm())
8484 WasmImpl
8585else if (std.Thread.use_pthreads)
8686 PosixImpl
lib/std/builtin.zig+1-1
......@@ -957,7 +957,7 @@ pub const VaList = switch (builtin.cpu.arch) {
957957 .amdgcn => *u8,
958958 .avr => *anyopaque,
959959 .bpfel, .bpfeb => *anyopaque,
960 .hexagon => if (builtin.target.isMusl()) VaListHexagon else *u8,
960 .hexagon => if (builtin.target.abi.isMusl()) VaListHexagon else *u8,
961961 .loongarch32, .loongarch64 => *anyopaque,
962962 .mips, .mipsel, .mips64, .mips64el => *anyopaque,
963963 .riscv32, .riscv64 => *anyopaque,
lib/std/c.zig+6-6
......@@ -2808,7 +2808,7 @@ pub const Sigaction = switch (native_os) {
28082808 .mipsel,
28092809 .mips64,
28102810 .mips64el,
2811 => if (builtin.target.isMusl())
2811 => if (builtin.target.abi.isMusl())
28122812 linux.Sigaction
28132813 else if (builtin.target.ptrBitWidth() == 64) extern struct {
28142814 pub const handler_fn = *align(1) const fn (i32) callconv(.c) void;
......@@ -6701,7 +6701,7 @@ pub const Stat = switch (native_os) {
67016701 return self.ctim;
67026702 }
67036703 },
6704 .mips, .mipsel => if (builtin.target.isMusl()) extern struct {
6704 .mips, .mipsel => if (builtin.target.abi.isMusl()) extern struct {
67056705 dev: dev_t,
67066706 __pad0: [2]i32,
67076707 ino: ino_t,
......@@ -6762,7 +6762,7 @@ pub const Stat = switch (native_os) {
67626762 return self.ctim;
67636763 }
67646764 },
6765 .mips64, .mips64el => if (builtin.target.isMusl()) extern struct {
6765 .mips64, .mips64el => if (builtin.target.abi.isMusl()) extern struct {
67666766 dev: dev_t,
67676767 __pad0: [3]i32,
67686768 ino: ino_t,
......@@ -9863,16 +9863,16 @@ pub const LC = enum(c_int) {
98639863
98649864pub extern "c" fn setlocale(category: LC, locale: ?[*:0]const u8) ?[*:0]const u8;
98659865
9866pub const getcontext = if (builtin.target.isAndroid() or builtin.target.os.tag == .openbsd)
9866pub const getcontext = if (builtin.target.abi.isAndroid() or builtin.target.os.tag == .openbsd)
98679867{} // android bionic and openbsd libc does not implement getcontext
9868else if (native_os == .linux and builtin.target.isMusl())
9868else if (native_os == .linux and builtin.target.abi.isMusl())
98699869 linux.getcontext
98709870else
98719871 private.getcontext;
98729872
98739873pub const max_align_t = if (native_abi == .msvc or native_abi == .itanium)
98749874 f64
9875else if (builtin.target.isDarwin())
9875else if (native_os.isDarwin())
98769876 c_longdouble
98779877else
98789878 extern struct {
lib/std/c/darwin.zig+1-1
......@@ -979,7 +979,7 @@ pub const kevent64_s = extern struct {
979979// to make sure the struct is laid out the same. These values were
980980// produced from C code using the offsetof macro.
981981comptime {
982 if (builtin.target.isDarwin()) {
982 if (builtin.target.os.tag.isDarwin()) {
983983 assert(@offsetOf(kevent64_s, "ident") == 0);
984984 assert(@offsetOf(kevent64_s, "filter") == 8);
985985 assert(@offsetOf(kevent64_s, "flags") == 10);
lib/std/debug.zig+4-4
......@@ -292,7 +292,7 @@ pub fn dumpHexFallible(bytes: []const u8) !void {
292292/// TODO multithreaded awareness
293293pub fn dumpCurrentStackTrace(start_addr: ?usize) void {
294294 nosuspend {
295 if (builtin.target.isWasm()) {
295 if (builtin.target.cpu.arch.isWasm()) {
296296 if (native_os == .wasi) {
297297 const stderr = io.getStdErr().writer();
298298 stderr.print("Unable to dump stack trace: not implemented for Wasm\n", .{}) catch return;
......@@ -380,7 +380,7 @@ pub inline fn getContext(context: *ThreadContext) bool {
380380/// TODO multithreaded awareness
381381pub fn dumpStackTraceFromBase(context: *ThreadContext) void {
382382 nosuspend {
383 if (builtin.target.isWasm()) {
383 if (builtin.target.cpu.arch.isWasm()) {
384384 if (native_os == .wasi) {
385385 const stderr = io.getStdErr().writer();
386386 stderr.print("Unable to dump stack trace: not implemented for Wasm\n", .{}) catch return;
......@@ -478,7 +478,7 @@ pub fn captureStackTrace(first_address: ?usize, stack_trace: *std.builtin.StackT
478478/// TODO multithreaded awareness
479479pub fn dumpStackTrace(stack_trace: std.builtin.StackTrace) void {
480480 nosuspend {
481 if (builtin.target.isWasm()) {
481 if (builtin.target.cpu.arch.isWasm()) {
482482 if (native_os == .wasi) {
483483 const stderr = io.getStdErr().writer();
484484 stderr.print("Unable to dump stack trace: not implemented for Wasm\n", .{}) catch return;
......@@ -759,7 +759,7 @@ pub const StackIterator = struct {
759759 pub fn initWithContext(first_address: ?usize, debug_info: *SelfInfo, context: *posix.ucontext_t) !StackIterator {
760760 // The implementation of DWARF unwinding on aarch64-macos is not complete. However, Apple mandates that
761761 // the frame pointer register is always used, so on this platform we can safely use the FP-based unwinder.
762 if (builtin.target.isDarwin() and native_arch == .aarch64)
762 if (builtin.target.os.tag.isDarwin() and native_arch == .aarch64)
763763 return init(first_address, @truncate(context.mcontext.ss.fp));
764764
765765 if (SelfInfo.supports_unwinding) {
lib/std/debug/SelfInfo.zig+4-4
......@@ -121,13 +121,13 @@ pub fn deinit(self: *SelfInfo) void {
121121}
122122
123123pub fn getModuleForAddress(self: *SelfInfo, address: usize) !*Module {
124 if (builtin.target.isDarwin()) {
124 if (builtin.target.os.tag.isDarwin()) {
125125 return self.lookupModuleDyld(address);
126126 } else if (native_os == .windows) {
127127 return self.lookupModuleWin32(address);
128128 } else if (native_os == .haiku) {
129129 return self.lookupModuleHaiku(address);
130 } else if (builtin.target.isWasm()) {
130 } else if (builtin.target.cpu.arch.isWasm()) {
131131 return self.lookupModuleWasm(address);
132132 } else {
133133 return self.lookupModuleDl(address);
......@@ -138,13 +138,13 @@ pub fn getModuleForAddress(self: *SelfInfo, address: usize) !*Module {
138138// This can be called when getModuleForAddress fails, so implementations should provide
139139// a path that doesn't rely on any side-effects of a prior successful module lookup.
140140pub fn getModuleNameForAddress(self: *SelfInfo, address: usize) ?[]const u8 {
141 if (builtin.target.isDarwin()) {
141 if (builtin.target.os.tag.isDarwin()) {
142142 return self.lookupModuleNameDyld(address);
143143 } else if (native_os == .windows) {
144144 return self.lookupModuleNameWin32(address);
145145 } else if (native_os == .haiku) {
146146 return null;
147 } else if (builtin.target.isWasm()) {
147 } else if (builtin.target.cpu.arch.isWasm()) {
148148 return null;
149149 } else {
150150 return self.lookupModuleNameDl(address);
lib/std/fs/Dir.zig+1-1
......@@ -2587,7 +2587,7 @@ const CopyFileRawError = error{SystemResources} || posix.CopyFileRangeError || p
25872587// The copy starts at offset 0, the initial offsets are preserved.
25882588// No metadata is transferred over.
25892589fn copy_file(fd_in: posix.fd_t, fd_out: posix.fd_t, maybe_size: ?u64) CopyFileRawError!void {
2590 if (builtin.target.isDarwin()) {
2590 if (builtin.target.os.tag.isDarwin()) {
25912591 const rc = posix.system.fcopyfile(fd_in, fd_out, null, .{ .DATA = true });
25922592 switch (posix.errno(rc)) {
25932593 .SUCCESS => return,
lib/std/heap.zig+3-3
......@@ -348,7 +348,7 @@ pub const page_allocator: Allocator = if (@hasDecl(root, "os") and
348348 @hasDecl(root.os, "heap") and
349349 @hasDecl(root.os.heap, "page_allocator"))
350350 root.os.heap.page_allocator
351else if (builtin.target.isWasm()) .{
351else if (builtin.target.cpu.arch.isWasm()) .{
352352 .ptr = undefined,
353353 .vtable = &WasmAllocator.vtable,
354354} else if (builtin.target.os.tag == .plan9) .{
......@@ -508,7 +508,7 @@ test PageAllocator {
508508 const allocator = page_allocator;
509509 try testAllocator(allocator);
510510 try testAllocatorAligned(allocator);
511 if (!builtin.target.isWasm()) {
511 if (!builtin.target.cpu.arch.isWasm()) {
512512 try testAllocatorLargeAlignment(allocator);
513513 try testAllocatorAlignedShrink(allocator);
514514 }
......@@ -990,7 +990,7 @@ test {
990990 _ = FixedBufferAllocator;
991991 _ = ThreadSafeAllocator;
992992 _ = SbrkAllocator;
993 if (builtin.target.isWasm()) {
993 if (builtin.target.cpu.arch.isWasm()) {
994994 _ = WasmAllocator;
995995 }
996996 if (!builtin.single_threaded) _ = smp_allocator;
lib/std/heap/WasmAllocator.zig+1-1
......@@ -7,7 +7,7 @@ const wasm = std.wasm;
77const math = std.math;
88
99comptime {
10 if (!builtin.target.isWasm()) {
10 if (!builtin.target.cpu.arch.isWasm()) {
1111 @compileError("only available for wasm32 arch");
1212 }
1313 if (!builtin.single_threaded) {
lib/std/heap/debug_allocator.zig+2-2
......@@ -1140,7 +1140,7 @@ test "shrink" {
11401140}
11411141
11421142test "large object - grow" {
1143 if (builtin.target.isWasm()) {
1143 if (builtin.target.cpu.arch.isWasm()) {
11441144 // Not expected to pass on targets that do not have memory mapping.
11451145 return error.SkipZigTest;
11461146 }
......@@ -1319,7 +1319,7 @@ test "realloc large object to larger alignment" {
13191319}
13201320
13211321test "large object rejects shrinking to small" {
1322 if (builtin.target.isWasm()) {
1322 if (builtin.target.cpu.arch.isWasm()) {
13231323 // Not expected to pass on targets that do not have memory mapping.
13241324 return error.SkipZigTest;
13251325 }
lib/std/math/big/int_test.zig+1-1
......@@ -2262,7 +2262,7 @@ test "bitNotWrap more than two limbs" {
22622262 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
22632263 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
22642264 // LLVM: unexpected runtime library name: __umodei4
2265 if (builtin.zig_backend == .stage2_llvm and comptime builtin.target.isWasm()) return error.SkipZigTest; // TODO
2265 if (builtin.zig_backend == .stage2_llvm and comptime builtin.target.cpu.arch.isWasm()) return error.SkipZigTest; // TODO
22662266
22672267 var a = try Managed.initSet(testing.allocator, maxInt(Limb));
22682268 defer a.deinit();
lib/std/math/gamma.zig+1-1
......@@ -263,7 +263,7 @@ test gamma {
263263}
264264
265265test "gamma.special" {
266 if (builtin.cpu.arch.isArm() and builtin.target.floatAbi() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234
266 if (builtin.cpu.arch.isArm() and builtin.target.abi.float() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234
267267
268268 inline for (&.{ f32, f64 }) |T| {
269269 try expect(std.math.isNan(gamma(T, -std.math.nan(T))));
lib/std/math/log10.zig+1-1
......@@ -135,7 +135,7 @@ test log10_int {
135135 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
136136 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
137137 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
138 if (builtin.zig_backend == .stage2_llvm and comptime builtin.target.isWasm()) return error.SkipZigTest; // TODO
138 if (builtin.zig_backend == .stage2_llvm and comptime builtin.target.cpu.arch.isWasm()) return error.SkipZigTest; // TODO
139139
140140 inline for (
141141 .{ u8, u16, u32, u64, u128, u256, u512 },
lib/std/posix.zig+2-2
......@@ -3583,7 +3583,7 @@ pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!socket_t
35833583 return rc;
35843584 }
35853585
3586 const have_sock_flags = !builtin.target.isDarwin() and native_os != .haiku;
3586 const have_sock_flags = !builtin.target.os.tag.isDarwin() and native_os != .haiku;
35873587 const filtered_sock_type = if (!have_sock_flags)
35883588 socket_type & ~@as(u32, SOCK.NONBLOCK | SOCK.CLOEXEC)
35893589 else
......@@ -3879,7 +3879,7 @@ pub fn accept(
38793879 /// description of the `CLOEXEC` flag in `open` for reasons why this may be useful.
38803880 flags: u32,
38813881) AcceptError!socket_t {
3882 const have_accept4 = !(builtin.target.isDarwin() or native_os == .windows or native_os == .haiku);
3882 const have_accept4 = !(builtin.target.os.tag.isDarwin() or native_os == .windows or native_os == .haiku);
38833883 assert(0 == (flags & ~@as(u32, SOCK.NONBLOCK | SOCK.CLOEXEC))); // Unsupported flag(s)
38843884
38853885 const accepted_sock: socket_t = while (true) {
lib/std/zig/LibCDirs.zig+2-2
......@@ -127,7 +127,7 @@ fn detectFromInstallation(arena: Allocator, target: std.Target, lci: *const LibC
127127
128128 var sysroot: ?[]const u8 = null;
129129
130 if (target.isDarwin()) d: {
130 if (target.os.tag.isDarwin()) d: {
131131 const down1 = std.fs.path.dirname(lci.sys_include_dir.?) orelse break :d;
132132 const down2 = std.fs.path.dirname(down1) orelse break :d;
133133 try framework_list.append(try std.fs.path.join(arena, &.{ down2, "System", "Library", "Frameworks" }));
......@@ -150,7 +150,7 @@ pub fn detectFromBuilding(
150150) !LibCDirs {
151151 const s = std.fs.path.sep_str;
152152
153 if (target.isDarwin()) {
153 if (target.os.tag.isDarwin()) {
154154 const list = try arena.alloc([]const u8, 1);
155155 list[0] = try std.fmt.allocPrint(
156156 arena,
lib/std/zig/LibCInstallation.zig+5-5
......@@ -81,7 +81,7 @@ pub fn parse(
8181 }
8282
8383 const os_tag = target.os.tag;
84 if (self.crt_dir == null and !target.isDarwin()) {
84 if (self.crt_dir == null and !target.os.tag.isDarwin()) {
8585 log.err("crt_dir may not be empty for {s}", .{@tagName(os_tag)});
8686 return error.ParseError;
8787 }
......@@ -167,7 +167,7 @@ pub const FindNativeOptions = struct {
167167pub fn findNative(args: FindNativeOptions) FindError!LibCInstallation {
168168 var self: LibCInstallation = .{};
169169
170 if (is_darwin and args.target.isDarwin()) {
170 if (is_darwin and args.target.os.tag.isDarwin()) {
171171 if (!std.zig.system.darwin.isSdkInstalled(args.allocator))
172172 return error.DarwinSdkNotFound;
173173 const sdk = std.zig.system.darwin.getSdk(args.allocator, args.target) orelse
......@@ -444,7 +444,7 @@ fn findNativeCrtDirPosix(self: *LibCInstallation, args: FindNativeOptions) FindE
444444 self.crt_dir = try ccPrintFileName(.{
445445 .allocator = args.allocator,
446446 .search_basename = switch (args.target.os.tag) {
447 .linux => if (args.target.isAndroid()) "crtbegin_dynamic.o" else "crt1.o",
447 .linux => if (args.target.abi.isAndroid()) "crtbegin_dynamic.o" else "crt1.o",
448448 else => "crt1.o",
449449 },
450450 .want_dirname = .only_dir,
......@@ -734,7 +734,7 @@ pub const CrtBasenames = struct {
734734
735735 const target = args.target;
736736
737 if (target.isAndroid()) return switch (mode) {
737 if (target.abi.isAndroid()) return switch (mode) {
738738 .dynamic_lib => .{
739739 .crtbegin = "crtbegin_so.o",
740740 .crtend = "crtend_so.o",
......@@ -1025,7 +1025,7 @@ const fs = std.fs;
10251025const Allocator = std.mem.Allocator;
10261026const Path = std.Build.Cache.Path;
10271027
1028const is_darwin = builtin.target.isDarwin();
1028const is_darwin = builtin.target.os.tag.isDarwin();
10291029const is_windows = builtin.target.os.tag == .windows;
10301030const is_haiku = builtin.target.os.tag == .haiku;
10311031
lib/std/zig/system.zig+1-1
......@@ -415,7 +415,7 @@ pub fn resolveTargetQuery(query: Target.Query) DetectError!Target {
415415 }
416416
417417 // https://github.com/llvm/llvm-project/issues/105978
418 if (result.cpu.arch.isArm() and result.abi.floatAbi() == .soft) {
418 if (result.cpu.arch.isArm() and result.abi.float() == .soft) {
419419 result.cpu.features.removeFeature(@intFromEnum(Target.arm.Feature.vfp2));
420420 }
421421 }
lib/std/zig/system/NativePaths.zig+1-1
......@@ -83,7 +83,7 @@ pub fn detect(arena: Allocator, native_target: std.Target) !NativePaths {
8383
8484 // TODO: consider also adding homebrew paths
8585 // TODO: consider also adding macports paths
86 if (builtin.target.isDarwin()) {
86 if (builtin.target.os.tag.isDarwin()) {
8787 if (std.zig.system.darwin.isSdkInstalled(arena)) sdk: {
8888 const sdk = std.zig.system.darwin.getSdk(arena, native_target) orelse break :sdk;
8989 try self.addLibDir(try std.fs.path.join(arena, &.{ sdk, "usr/lib" }));
src/Compilation.zig+6-15
......@@ -1766,11 +1766,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
17661766 if (comp.config.link_libc and is_exe_or_dyn_lib) {
17671767 // If the "is darwin" check is moved below the libc_installation check below,
17681768 // error.LibCInstallationMissingCrtDir is returned from lci.resolveCrtPaths().
1769 if (target.isDarwin()) {
1770 switch (target.abi) {
1771 .none, .simulator, .macabi => {},
1772 else => return error.LibCUnavailable,
1773 }
1769 if (target.isDarwinLibC()) {
17741770 // TODO delete logic from MachO flush() and queue up tasks here instead.
17751771 } else if (comp.libc_installation) |lci| {
17761772 const basenames = LibCInstallation.CrtBasenames.get(.{
......@@ -1793,7 +1789,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
17931789 // Loads the libraries provided by `target_util.libcFullLinkFlags(target)`.
17941790 comp.link_task_queue.shared.appendAssumeCapacity(.load_host_libc);
17951791 comp.remaining_prelink_tasks += 1;
1796 } else if (target.isMusl() and !target.isWasm()) {
1792 } else if (target.isMuslLibC()) {
17971793 if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable;
17981794
17991795 if (musl.needsCrt0(comp.config.output_mode, comp.config.link_mode, comp.config.pie)) |f| {
......@@ -1817,7 +1813,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
18171813
18181814 comp.queued_jobs.glibc_crt_file[@intFromEnum(glibc.CrtFile.libc_nonshared_a)] = true;
18191815 comp.remaining_prelink_tasks += 1;
1820 } else if (target.isWasm() and target.os.tag == .wasi) {
1816 } else if (target.isWasiLibC()) {
18211817 if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable;
18221818
18231819 for (comp.wasi_emulated_libs) |crt_file| {
......@@ -1839,11 +1835,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
18391835 // When linking mingw-w64 there are some import libs we always need.
18401836 try comp.windows_libs.ensureUnusedCapacity(gpa, mingw.always_link_libs.len);
18411837 for (mingw.always_link_libs) |name| comp.windows_libs.putAssumeCapacity(name, {});
1842 } else if (target.isDarwin()) {
1843 switch (target.abi) {
1844 .none, .simulator, .macabi => {},
1845 else => return error.LibCUnavailable,
1846 }
18471838 } else if (target.os.tag == .freestanding and capable_of_building_zig_libc) {
18481839 comp.queued_jobs.zig_libc = true;
18491840 comp.remaining_prelink_tasks += 1;
......@@ -5545,7 +5536,7 @@ pub fn addCCArgs(
55455536
55465537 // We might want to support -mfloat-abi=softfp for Arm and CSKY here in the future.
55475538 if (target_util.clangSupportsFloatAbiArg(target)) {
5548 const fabi = @tagName(target.floatAbi());
5539 const fabi = @tagName(target.abi.float());
55495540
55505541 try argv.append(switch (target.cpu.arch) {
55515542 // For whatever reason, Clang doesn't support `-mfloat-abi` for s390x.
......@@ -5598,7 +5589,7 @@ pub fn addCCArgs(
55985589 if (ext != .assembly) {
55995590 try argv.append(if (target.os.tag == .freestanding) "-ffreestanding" else "-fhosted");
56005591
5601 if (target_util.clangSupportsNoImplicitFloatArg(target) and target.floatAbi() == .soft) {
5592 if (target_util.clangSupportsNoImplicitFloatArg(target) and target.abi.float() == .soft) {
56025593 try argv.append("-mno-implicit-float");
56035594 }
56045595
......@@ -5646,7 +5637,7 @@ pub fn addCCArgs(
56465637 // LLVM IR files don't support these flags.
56475638 if (ext != .ll and ext != .bc) {
56485639 // https://github.com/llvm/llvm-project/issues/105972
5649 if (target.cpu.arch.isPowerPC() and target.floatAbi() == .soft) {
5640 if (target.cpu.arch.isPowerPC() and target.abi.float() == .soft) {
56505641 try argv.append("-D__NO_FPRS__");
56515642 try argv.append("-D_SOFT_FLOAT");
56525643 try argv.append("-D_SOFT_DOUBLE");
src/Sema.zig+3-3
......@@ -9378,7 +9378,7 @@ pub fn handleExternLibName(
93789378 );
93799379 break :blk;
93809380 }
9381 if (!target.isWasm() and !block.ownerModule().pic) {
9381 if (!target.cpu.arch.isWasm() and !block.ownerModule().pic) {
93829382 return sema.fail(
93839383 block,
93849384 src_loc,
......@@ -26511,7 +26511,7 @@ fn zirWasmMemorySize(
2651126511 const index_src = block.builtinCallArgSrc(extra.node, 0);
2651226512 const builtin_src = block.nodeOffset(extra.node);
2651326513 const target = sema.pt.zcu.getTarget();
26514 if (!target.isWasm()) {
26514 if (!target.cpu.arch.isWasm()) {
2651526515 return sema.fail(block, builtin_src, "builtin @wasmMemorySize is available when targeting WebAssembly; targeted CPU architecture is {s}", .{@tagName(target.cpu.arch)});
2651626516 }
2651726517
......@@ -26536,7 +26536,7 @@ fn zirWasmMemoryGrow(
2653626536 const index_src = block.builtinCallArgSrc(extra.node, 0);
2653726537 const delta_src = block.builtinCallArgSrc(extra.node, 1);
2653826538 const target = sema.pt.zcu.getTarget();
26539 if (!target.isWasm()) {
26539 if (!target.cpu.arch.isWasm()) {
2654026540 return sema.fail(block, builtin_src, "builtin @wasmMemoryGrow is available when targeting WebAssembly; targeted CPU architecture is {s}", .{@tagName(target.cpu.arch)});
2654126541 }
2654226542
src/arch/x86_64/CodeGen.zig+1-1
......@@ -90078,7 +90078,7 @@ fn floatCompilerRtAbiName(float_bits: u32) u8 {
9007890078fn floatCompilerRtAbiType(self: *CodeGen, ty: Type, other_ty: Type) Type {
9007990079 if (ty.toIntern() == .f16_type and
9008090080 (other_ty.toIntern() == .f32_type or other_ty.toIntern() == .f64_type) and
90081 self.target.isDarwin()) return .u16;
90081 self.target.os.tag.isDarwin()) return .u16;
9008290082 return ty;
9008390083}
9008490084
src/codegen/llvm.zig+9-9
......@@ -1301,7 +1301,7 @@ pub const Object = struct {
13011301 .large => .Large,
13021302 };
13031303
1304 const float_abi: llvm.TargetMachine.FloatABI = if (comp.root_mod.resolved_target.result.floatAbi() == .hard)
1304 const float_abi: llvm.TargetMachine.FloatABI = if (comp.root_mod.resolved_target.result.abi.float() == .hard)
13051305 .Hard
13061306 else
13071307 .Soft;
......@@ -2939,7 +2939,7 @@ pub const Object = struct {
29392939 function_index.setLinkage(.internal, &o.builder);
29402940 function_index.setUnnamedAddr(.unnamed_addr, &o.builder);
29412941 } else {
2942 if (target.isWasm()) {
2942 if (target.cpu.arch.isWasm()) {
29432943 try attributes.addFnAttr(.{ .string = .{
29442944 .kind = try o.builder.string("wasm-import-name"),
29452945 .value = try o.builder.string(nav.name.toSlice(ip)),
......@@ -3156,7 +3156,7 @@ pub const Object = struct {
31563156 .value = try o.builder.string(std.mem.span(s)),
31573157 } }, &o.builder);
31583158 }
3159 if (target.floatAbi() == .soft) {
3159 if (target.abi.float() == .soft) {
31603160 // `use-soft-float` means "use software routines for floating point computations". In
31613161 // other words, it configures how LLVM lowers basic float instructions like `fcmp`,
31623162 // `fadd`, etc. The float calling convention is configured on `TargetMachine` and is
......@@ -4830,7 +4830,7 @@ pub const NavGen = struct {
48304830 const global_index = o.nav_map.get(nav_index).?;
48314831
48324832 const decl_name = decl_name: {
4833 if (zcu.getTarget().isWasm() and ty.zigTypeTag(zcu) == .@"fn") {
4833 if (zcu.getTarget().cpu.arch.isWasm() and ty.zigTypeTag(zcu) == .@"fn") {
48344834 if (lib_name.toSlice(ip)) |lib_name_slice| {
48354835 if (!std.mem.eql(u8, lib_name_slice, "c")) {
48364836 break :decl_name try o.builder.strtabStringFmt("{}|{s}", .{ nav.name.fmt(ip), lib_name_slice });
......@@ -6567,7 +6567,7 @@ pub const FuncGen = struct {
65676567 // Workaround for:
65686568 // * https://github.com/llvm/llvm-project/blob/56905dab7da50bccfcceaeb496b206ff476127e1/llvm/lib/MC/WasmObjectWriter.cpp#L560
65696569 // * https://github.com/llvm/llvm-project/blob/56905dab7da50bccfcceaeb496b206ff476127e1/llvm/test/MC/WebAssembly/blockaddress.ll
6570 if (zcu.comp.getTarget().isWasm()) break :jmp_table null;
6570 if (zcu.comp.getTarget().cpu.arch.isWasm()) break :jmp_table null;
65716571
65726572 // On a 64-bit target, 1024 pointers in our jump table is about 8K of pointers. This seems just
65736573 // about acceptable - it won't fill L1d cache on most CPUs.
......@@ -10024,7 +10024,7 @@ pub const FuncGen = struct {
1002410024 // of the length. This means we need to emit a check where we skip the memset when the length
1002510025 // is 0 as we allow for undefined pointers in 0-sized slices.
1002610026 // This logic can be removed once https://github.com/ziglang/zig/issues/16360 is done.
10027 const intrinsic_len0_traps = o.target.isWasm() and
10027 const intrinsic_len0_traps = o.target.cpu.arch.isWasm() and
1002810028 ptr_ty.isSlice(zcu) and
1002910029 std.Target.wasm.featureSetHas(o.target.cpu.features, .bulk_memory);
1003010030
......@@ -10181,7 +10181,7 @@ pub const FuncGen = struct {
1018110181 // For this reason we must add a check for 0-sized slices as its pointer field can be undefined.
1018210182 // We only have to do this for slices as arrays will have a valid pointer.
1018310183 // This logic can be removed once https://github.com/ziglang/zig/issues/16360 is done.
10184 if (o.target.isWasm() and
10184 if (o.target.cpu.arch.isWasm() and
1018510185 std.Target.wasm.featureSetHas(o.target.cpu.features, .bulk_memory) and
1018610186 dest_ptr_ty.isSlice(zcu))
1018710187 {
......@@ -12696,7 +12696,7 @@ fn backendSupportsF16(target: std.Target) bool {
1269612696 .armeb,
1269712697 .thumb,
1269812698 .thumbeb,
12699 => target.floatAbi() == .soft or std.Target.arm.featureSetHas(target.cpu.features, .fp_armv8),
12699 => target.abi.float() == .soft or std.Target.arm.featureSetHas(target.cpu.features, .fp_armv8),
1270012700 .aarch64,
1270112701 .aarch64_be,
1270212702 => std.Target.aarch64.featureSetHas(target.cpu.features, .fp_armv8),
......@@ -12723,7 +12723,7 @@ fn backendSupportsF128(target: std.Target) bool {
1272312723 .armeb,
1272412724 .thumb,
1272512725 .thumbeb,
12726 => target.floatAbi() == .soft or std.Target.arm.featureSetHas(target.cpu.features, .fp_armv8),
12726 => target.abi.float() == .soft or std.Target.arm.featureSetHas(target.cpu.features, .fp_armv8),
1272712727 .aarch64,
1272812728 .aarch64_be,
1272912729 => std.Target.aarch64.featureSetHas(target.cpu.features, .fp_armv8),
src/libtsan.zig+6-6
......@@ -36,7 +36,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo
3636 .watchos => if (target.abi == .simulator) "clang_rt.tsan_watchossim_dynamic" else "clang_rt.tsan_watchos_dynamic",
3737 else => "tsan",
3838 };
39 const link_mode: std.builtin.LinkMode = if (target.isDarwin()) .dynamic else .static;
39 const link_mode: std.builtin.LinkMode = if (target.os.tag.isDarwin()) .dynamic else .static;
4040 const output_mode = .Lib;
4141 const basename = try std.zig.binNameAlloc(arena, .{
4242 .root_name = root_name,
......@@ -52,9 +52,9 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo
5252
5353 const optimize_mode = comp.compilerRtOptMode();
5454 const strip = comp.compilerRtStrip();
55 const link_libcpp = target.isDarwin();
5655 const unwind_tables: std.builtin.UnwindTables =
5756 if (target.cpu.arch == .x86 and target.os.tag == .windows) .none else .@"async";
57 const link_libcpp = target.os.tag.isDarwin();
5858
5959 const config = Compilation.Config.resolve(.{
6060 .output_mode = output_mode,
......@@ -276,14 +276,14 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo
276276 });
277277 }
278278
279 const skip_linker_dependencies = !target.isDarwin();
280 const linker_allow_shlib_undefined = target.isDarwin();
281 const install_name = if (target.isDarwin())
279 const skip_linker_dependencies = !target.os.tag.isDarwin();
280 const linker_allow_shlib_undefined = target.os.tag.isDarwin();
281 const install_name = if (target.os.tag.isDarwin())
282282 try std.fmt.allocPrintZ(arena, "@rpath/{s}", .{basename})
283283 else
284284 null;
285285 // Workaround for https://github.com/llvm/llvm-project/issues/97627
286 const headerpad_size: ?u32 = if (target.isDarwin()) 32 else null;
286 const headerpad_size: ?u32 = if (target.os.tag.isDarwin()) 32 else null;
287287 const sub_compilation = Compilation.create(comp.gpa, arena, .{
288288 .local_cache_directory = comp.global_cache_directory,
289289 .global_cache_directory = comp.global_cache_directory,
src/libunwind.zig+1-1
......@@ -136,7 +136,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
136136 if (!comp.config.any_non_single_threaded) {
137137 try cflags.append("-D_LIBUNWIND_HAS_NO_THREADS");
138138 }
139 if (target.cpu.arch.isArm() and target.abi.floatAbi() == .hard) {
139 if (target.cpu.arch.isArm() and target.abi.float() == .hard) {
140140 try cflags.append("-DCOMPILER_RT_ARMHF_TARGET");
141141 }
142142 try cflags.append("-Wno-bitwise-conditional-parentheses");
src/link.zig+2-2
......@@ -2067,7 +2067,7 @@ fn resolveLibInput(
20672067
20682068 const lib_name = name_query.name;
20692069
2070 if (target.isDarwin() and link_mode == .dynamic) tbd: {
2070 if (target.os.tag.isDarwin() and link_mode == .dynamic) tbd: {
20712071 // Prefer .tbd over .dylib.
20722072 const test_path: Path = .{
20732073 .root_dir = lib_directory,
......@@ -2104,7 +2104,7 @@ fn resolveLibInput(
21042104
21052105 // In the case of Darwin, the main check will be .dylib, so here we
21062106 // additionally check for .so files.
2107 if (target.isDarwin() and link_mode == .dynamic) so: {
2107 if (target.os.tag.isDarwin() and link_mode == .dynamic) so: {
21082108 const test_path: Path = .{
21092109 .root_dir = lib_directory,
21102110 .sub_path = try std.fmt.allocPrint(arena, "lib{s}.so", .{lib_name}),
src/link/Coff.zig+1-1
......@@ -1881,7 +1881,7 @@ fn linkWithLLD(coff: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_node:
18811881 try argv.append(try allocPrint(arena, "-MLLVM:-target-abi={s}", .{mabi}));
18821882 }
18831883
1884 try argv.append(try allocPrint(arena, "-MLLVM:-float-abi={s}", .{if (target.abi.floatAbi() == .hard) "hard" else "soft"}));
1884 try argv.append(try allocPrint(arena, "-MLLVM:-float-abi={s}", .{if (target.abi.float() == .hard) "hard" else "soft"}));
18851885
18861886 if (comp.config.lto != .none) {
18871887 switch (optimize_mode) {
src/link/Elf.zig+2-2
......@@ -1709,7 +1709,7 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s
17091709
17101710 try argv.appendSlice(&.{
17111711 "-mllvm",
1712 try std.fmt.allocPrint(arena, "-float-abi={s}", .{if (target.abi.floatAbi() == .hard) "hard" else "soft"}),
1712 try std.fmt.allocPrint(arena, "-float-abi={s}", .{if (target.abi.float() == .hard) "hard" else "soft"}),
17131713 });
17141714
17151715 if (comp.config.lto != .none) {
......@@ -2053,7 +2053,7 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s
20532053 try argv.append(lib_path);
20542054 }
20552055 try argv.append(try comp.crtFileAsString(arena, "libc_nonshared.a"));
2056 } else if (target.isMusl()) {
2056 } else if (target.abi.isMusl()) {
20572057 try argv.append(try comp.crtFileAsString(arena, switch (link_mode) {
20582058 .static => "libc.a",
20592059 .dynamic => "libc.so",
src/link/MachO.zig+1-1
......@@ -3548,7 +3548,7 @@ pub fn getTarget(self: MachO) std.Target {
35483548pub fn invalidateKernelCache(dir: fs.Dir, sub_path: []const u8) !void {
35493549 const tracy = trace(@src());
35503550 defer tracy.end();
3551 if (builtin.target.isDarwin() and builtin.target.cpu.arch == .aarch64) {
3551 if (builtin.target.os.tag.isDarwin() and builtin.target.cpu.arch == .aarch64) {
35523552 try dir.copyFile(sub_path, dir, sub_path, .{});
35533553 }
35543554}
src/main.zig+1-1
......@@ -3983,7 +3983,7 @@ fn createModule(
39833983 }
39843984 create_module.lib_dir_args = undefined; // From here we use lib_directories instead.
39853985
3986 if (resolved_target.is_native_os and target.isDarwin()) {
3986 if (resolved_target.is_native_os and target.os.tag.isDarwin()) {
39873987 // If we want to link against frameworks, we need system headers.
39883988 if (create_module.frameworks.count() > 0)
39893989 create_module.want_native_include_dirs = true;
src/target.zig+4-4
......@@ -12,7 +12,7 @@ pub const default_stack_protector_buffer_size = 4;
1212pub fn cannotDynamicLink(target: std.Target) bool {
1313 return switch (target.os.tag) {
1414 .freestanding => true,
15 else => target.isSpirV(),
15 else => target.cpu.arch.isSpirV(),
1616 };
1717}
1818
......@@ -40,12 +40,12 @@ pub fn libcNeedsLibUnwind(target: std.Target) bool {
4040}
4141
4242pub fn requiresPIE(target: std.Target) bool {
43 return target.isAndroid() or target.isDarwin() or target.os.tag == .openbsd;
43 return target.abi.isAndroid() or target.os.tag.isDarwin() or target.os.tag == .openbsd;
4444}
4545
4646/// This function returns whether non-pic code is completely invalid on the given target.
4747pub fn requiresPIC(target: std.Target, linking_libc: bool) bool {
48 return target.isAndroid() or
48 return target.abi.isAndroid() or
4949 target.os.tag == .windows or target.os.tag == .uefi or
5050 osRequiresLibC(target) or
5151 (linking_libc and target.isGnuLibC());
......@@ -245,7 +245,7 @@ pub fn clangSupportsStackProtector(target: std.Target) bool {
245245}
246246
247247pub fn libcProvidesStackProtector(target: std.Target) bool {
248 return !target.isMinGW() and target.os.tag != .wasi and !target.isSpirV();
248 return !target.isMinGW() and target.os.tag != .wasi and !target.cpu.arch.isSpirV();
249249}
250250
251251pub fn supportsReturnAddress(target: std.Target) bool {
test/behavior/floatop.zig+2-2
......@@ -126,7 +126,7 @@ test "cmp f16" {
126126 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
127127 if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
128128 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
129 if (builtin.cpu.arch.isArm() and builtin.target.floatAbi() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234
129 if (builtin.cpu.arch.isArm() and builtin.target.abi.float() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234
130130
131131 try testCmp(f16);
132132 try comptime testCmp(f16);
......@@ -135,7 +135,7 @@ test "cmp f16" {
135135test "cmp f32/f64" {
136136 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
137137 if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
138 if (builtin.cpu.arch.isArm() and builtin.target.floatAbi() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234
138 if (builtin.cpu.arch.isArm() and builtin.target.abi.float() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234
139139
140140 try testCmp(f32);
141141 try comptime testCmp(f32);
test/behavior/math.zig+3-3
......@@ -1639,7 +1639,7 @@ test "NaN comparison" {
16391639 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
16401640 if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
16411641 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
1642 if (builtin.cpu.arch.isArm() and builtin.target.floatAbi() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234
1642 if (builtin.cpu.arch.isArm() and builtin.target.abi.float() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234
16431643
16441644 try testNanEqNan(f16);
16451645 try testNanEqNan(f32);
......@@ -1795,7 +1795,7 @@ test "runtime comparison to NaN is comptime-known" {
17951795 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
17961796 if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
17971797 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
1798 if (builtin.cpu.arch.isArm() and builtin.target.floatAbi() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234
1798 if (builtin.cpu.arch.isArm() and builtin.target.abi.float() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234
17991799
18001800 const S = struct {
18011801 fn doTheTest(comptime F: type, x: F) void {
......@@ -1826,7 +1826,7 @@ test "runtime int comparison to inf is comptime-known" {
18261826 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
18271827 if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
18281828 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
1829 if (builtin.cpu.arch.isArm() and builtin.target.floatAbi() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234
1829 if (builtin.cpu.arch.isArm() and builtin.target.abi.float() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234
18301830
18311831 const S = struct {
18321832 fn doTheTest(comptime F: type, x: u32) void {
test/c_abi/main.zig+4-4
......@@ -135,7 +135,7 @@ export fn zig_f64(x: f64) void {
135135 expect(x == 56.78) catch @panic("test failure: zig_f64");
136136}
137137export fn zig_longdouble(x: c_longdouble) void {
138 if (!builtin.target.isWasm()) return; // waiting for #1481
138 if (!builtin.target.cpu.arch.isWasm()) return; // waiting for #1481
139139 expect(x == 12.34) catch @panic("test failure: zig_longdouble");
140140}
141141
......@@ -1661,7 +1661,7 @@ test "bool simd vector" {
16611661 }
16621662
16631663 {
1664 if (!builtin.target.isWasm()) c_vector_256_bool(.{
1664 if (!builtin.target.cpu.arch.isWasm()) c_vector_256_bool(.{
16651665 false,
16661666 true,
16671667 true,
......@@ -2179,7 +2179,7 @@ test "bool simd vector" {
21792179 try expect(vec[255] == false);
21802180 }
21812181 {
2182 if (!builtin.target.isWasm()) c_vector_512_bool(.{
2182 if (!builtin.target.cpu.arch.isWasm()) c_vector_512_bool(.{
21832183 true,
21842184 true,
21852185 true,
......@@ -5593,7 +5593,7 @@ test "f80 extra struct" {
55935593
55945594comptime {
55955595 skip: {
5596 if (builtin.target.isWasm()) break :skip;
5596 if (builtin.target.cpu.arch.isWasm()) break :skip;
55975597
55985598 _ = struct {
55995599 export fn zig_f128(x: f128) f128 {
test/standalone/stack_iterator/build.zig+2-2
......@@ -24,7 +24,7 @@ pub fn build(b: *std.Build) void {
2424 .root_source_file = b.path("unwind.zig"),
2525 .target = target,
2626 .optimize = optimize,
27 .unwind_tables = if (target.result.isDarwin()) .@"async" else null,
27 .unwind_tables = if (target.result.os.tag.isDarwin()) .@"async" else null,
2828 .omit_frame_pointer = false,
2929 }),
3030 });
......@@ -94,7 +94,7 @@ pub fn build(b: *std.Build) void {
9494 .root_source_file = b.path("shared_lib_unwind.zig"),
9595 .target = target,
9696 .optimize = optimize,
97 .unwind_tables = if (target.result.isDarwin()) .@"async" else null,
97 .unwind_tables = if (target.result.os.tag.isDarwin()) .@"async" else null,
9898 .omit_frame_pointer = true,
9999 }),
100100 });
test/standalone/stack_iterator/shared_lib_unwind.zig+2-2
......@@ -36,8 +36,8 @@ extern fn frame0(
3636
3737pub fn main() !void {
3838 // Disabled until the DWARF unwinder bugs on .aarch64 are solved
39 if (builtin.omit_frame_pointer and comptime builtin.target.isDarwin() and builtin.cpu.arch == .aarch64) return;
40 if (builtin.target.isDarwin() and builtin.cpu.arch == .x86_64) return; // https://github.com/ziglang/zig/issues/21337
39 if (builtin.omit_frame_pointer and comptime builtin.target.os.tag.isDarwin() and builtin.cpu.arch == .aarch64) return;
40 if (builtin.target.os.tag.isDarwin() and builtin.cpu.arch == .x86_64) return; // https://github.com/ziglang/zig/issues/21337
4141
4242 if (!std.debug.have_ucontext or !std.debug.have_getcontext) return;
4343
test/standalone/stack_iterator/unwind.zig+1-1
......@@ -88,7 +88,7 @@ noinline fn frame0(expected: *[4]usize, unwound: *[4]usize) void {
8888
8989pub fn main() !void {
9090 // Disabled until the DWARF unwinder bugs on .aarch64 are solved
91 if (builtin.omit_frame_pointer and comptime builtin.target.isDarwin() and builtin.cpu.arch == .aarch64) return;
91 if (builtin.omit_frame_pointer and comptime builtin.target.os.tag.isDarwin() and builtin.cpu.arch == .aarch64) return;
9292
9393 if (!std.debug.have_ucontext or !std.debug.have_getcontext) return;
9494