diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Compilation.zig | 21 | ||||
| -rw-r--r-- | src/Sema.zig | 6 | ||||
| -rw-r--r-- | src/arch/x86_64/CodeGen.zig | 2 | ||||
| -rw-r--r-- | src/codegen/llvm.zig | 18 | ||||
| -rw-r--r-- | src/libtsan.zig | 12 | ||||
| -rw-r--r-- | src/libunwind.zig | 2 | ||||
| -rw-r--r-- | src/link.zig | 4 | ||||
| -rw-r--r-- | src/link/Coff.zig | 2 | ||||
| -rw-r--r-- | src/link/Elf.zig | 4 | ||||
| -rw-r--r-- | src/link/MachO.zig | 2 | ||||
| -rw-r--r-- | src/main.zig | 2 | ||||
| -rw-r--r-- | src/target.zig | 8 |
12 files changed, 37 insertions, 46 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index 5bbeca4b7d..aafbc30fef 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -1766,11 +1766,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil if (comp.config.link_libc and is_exe_or_dyn_lib) { // If the "is darwin" check is moved below the libc_installation check below, // error.LibCInstallationMissingCrtDir is returned from lci.resolveCrtPaths(). - if (target.isDarwin()) { - switch (target.abi) { - .none, .simulator, .macabi => {}, - else => return error.LibCUnavailable, - } + if (target.isDarwinLibC()) { // TODO delete logic from MachO flush() and queue up tasks here instead. } else if (comp.libc_installation) |lci| { const basenames = LibCInstallation.CrtBasenames.get(.{ @@ -1793,7 +1789,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil // Loads the libraries provided by `target_util.libcFullLinkFlags(target)`. comp.link_task_queue.shared.appendAssumeCapacity(.load_host_libc); comp.remaining_prelink_tasks += 1; - } else if (target.isMusl() and !target.isWasm()) { + } else if (target.isMuslLibC()) { if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; 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 comp.queued_jobs.glibc_crt_file[@intFromEnum(glibc.CrtFile.libc_nonshared_a)] = true; comp.remaining_prelink_tasks += 1; - } else if (target.isWasm() and target.os.tag == .wasi) { + } else if (target.isWasiLibC()) { if (!std.zig.target.canBuildLibC(target)) return error.LibCUnavailable; for (comp.wasi_emulated_libs) |crt_file| { @@ -1839,11 +1835,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil // When linking mingw-w64 there are some import libs we always need. try comp.windows_libs.ensureUnusedCapacity(gpa, mingw.always_link_libs.len); for (mingw.always_link_libs) |name| comp.windows_libs.putAssumeCapacity(name, {}); - } else if (target.isDarwin()) { - switch (target.abi) { - .none, .simulator, .macabi => {}, - else => return error.LibCUnavailable, - } } else if (target.os.tag == .freestanding and capable_of_building_zig_libc) { comp.queued_jobs.zig_libc = true; comp.remaining_prelink_tasks += 1; @@ -5545,7 +5536,7 @@ pub fn addCCArgs( // We might want to support -mfloat-abi=softfp for Arm and CSKY here in the future. if (target_util.clangSupportsFloatAbiArg(target)) { - const fabi = @tagName(target.floatAbi()); + const fabi = @tagName(target.abi.float()); try argv.append(switch (target.cpu.arch) { // For whatever reason, Clang doesn't support `-mfloat-abi` for s390x. @@ -5598,7 +5589,7 @@ pub fn addCCArgs( if (ext != .assembly) { try argv.append(if (target.os.tag == .freestanding) "-ffreestanding" else "-fhosted"); - if (target_util.clangSupportsNoImplicitFloatArg(target) and target.floatAbi() == .soft) { + if (target_util.clangSupportsNoImplicitFloatArg(target) and target.abi.float() == .soft) { try argv.append("-mno-implicit-float"); } @@ -5646,7 +5637,7 @@ pub fn addCCArgs( // LLVM IR files don't support these flags. if (ext != .ll and ext != .bc) { // https://github.com/llvm/llvm-project/issues/105972 - if (target.cpu.arch.isPowerPC() and target.floatAbi() == .soft) { + if (target.cpu.arch.isPowerPC() and target.abi.float() == .soft) { try argv.append("-D__NO_FPRS__"); try argv.append("-D_SOFT_FLOAT"); try argv.append("-D_SOFT_DOUBLE"); diff --git a/src/Sema.zig b/src/Sema.zig index 78a7a8f658..cbfeef6339 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -9378,7 +9378,7 @@ pub fn handleExternLibName( ); break :blk; } - if (!target.isWasm() and !block.ownerModule().pic) { + if (!target.cpu.arch.isWasm() and !block.ownerModule().pic) { return sema.fail( block, src_loc, @@ -26511,7 +26511,7 @@ fn zirWasmMemorySize( const index_src = block.builtinCallArgSrc(extra.node, 0); const builtin_src = block.nodeOffset(extra.node); const target = sema.pt.zcu.getTarget(); - if (!target.isWasm()) { + if (!target.cpu.arch.isWasm()) { return sema.fail(block, builtin_src, "builtin @wasmMemorySize is available when targeting WebAssembly; targeted CPU architecture is {s}", .{@tagName(target.cpu.arch)}); } @@ -26536,7 +26536,7 @@ fn zirWasmMemoryGrow( const index_src = block.builtinCallArgSrc(extra.node, 0); const delta_src = block.builtinCallArgSrc(extra.node, 1); const target = sema.pt.zcu.getTarget(); - if (!target.isWasm()) { + if (!target.cpu.arch.isWasm()) { return sema.fail(block, builtin_src, "builtin @wasmMemoryGrow is available when targeting WebAssembly; targeted CPU architecture is {s}", .{@tagName(target.cpu.arch)}); } diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig index b46c839687..1afa8d2aff 100644 --- a/src/arch/x86_64/CodeGen.zig +++ b/src/arch/x86_64/CodeGen.zig @@ -90078,7 +90078,7 @@ fn floatCompilerRtAbiName(float_bits: u32) u8 { fn floatCompilerRtAbiType(self: *CodeGen, ty: Type, other_ty: Type) Type { if (ty.toIntern() == .f16_type and (other_ty.toIntern() == .f32_type or other_ty.toIntern() == .f64_type) and - self.target.isDarwin()) return .u16; + self.target.os.tag.isDarwin()) return .u16; return ty; } diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 91bbea8b4a..41c817303c 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -1301,7 +1301,7 @@ pub const Object = struct { .large => .Large, }; - const float_abi: llvm.TargetMachine.FloatABI = if (comp.root_mod.resolved_target.result.floatAbi() == .hard) + const float_abi: llvm.TargetMachine.FloatABI = if (comp.root_mod.resolved_target.result.abi.float() == .hard) .Hard else .Soft; @@ -2939,7 +2939,7 @@ pub const Object = struct { function_index.setLinkage(.internal, &o.builder); function_index.setUnnamedAddr(.unnamed_addr, &o.builder); } else { - if (target.isWasm()) { + if (target.cpu.arch.isWasm()) { try attributes.addFnAttr(.{ .string = .{ .kind = try o.builder.string("wasm-import-name"), .value = try o.builder.string(nav.name.toSlice(ip)), @@ -3156,7 +3156,7 @@ pub const Object = struct { .value = try o.builder.string(std.mem.span(s)), } }, &o.builder); } - if (target.floatAbi() == .soft) { + if (target.abi.float() == .soft) { // `use-soft-float` means "use software routines for floating point computations". In // other words, it configures how LLVM lowers basic float instructions like `fcmp`, // `fadd`, etc. The float calling convention is configured on `TargetMachine` and is @@ -4830,7 +4830,7 @@ pub const NavGen = struct { const global_index = o.nav_map.get(nav_index).?; const decl_name = decl_name: { - if (zcu.getTarget().isWasm() and ty.zigTypeTag(zcu) == .@"fn") { + if (zcu.getTarget().cpu.arch.isWasm() and ty.zigTypeTag(zcu) == .@"fn") { if (lib_name.toSlice(ip)) |lib_name_slice| { if (!std.mem.eql(u8, lib_name_slice, "c")) { break :decl_name try o.builder.strtabStringFmt("{}|{s}", .{ nav.name.fmt(ip), lib_name_slice }); @@ -6567,7 +6567,7 @@ pub const FuncGen = struct { // Workaround for: // * https://github.com/llvm/llvm-project/blob/56905dab7da50bccfcceaeb496b206ff476127e1/llvm/lib/MC/WasmObjectWriter.cpp#L560 // * https://github.com/llvm/llvm-project/blob/56905dab7da50bccfcceaeb496b206ff476127e1/llvm/test/MC/WebAssembly/blockaddress.ll - if (zcu.comp.getTarget().isWasm()) break :jmp_table null; + if (zcu.comp.getTarget().cpu.arch.isWasm()) break :jmp_table null; // On a 64-bit target, 1024 pointers in our jump table is about 8K of pointers. This seems just // about acceptable - it won't fill L1d cache on most CPUs. @@ -10024,7 +10024,7 @@ pub const FuncGen = struct { // of the length. This means we need to emit a check where we skip the memset when the length // is 0 as we allow for undefined pointers in 0-sized slices. // This logic can be removed once https://github.com/ziglang/zig/issues/16360 is done. - const intrinsic_len0_traps = o.target.isWasm() and + const intrinsic_len0_traps = o.target.cpu.arch.isWasm() and ptr_ty.isSlice(zcu) and std.Target.wasm.featureSetHas(o.target.cpu.features, .bulk_memory); @@ -10181,7 +10181,7 @@ pub const FuncGen = struct { // For this reason we must add a check for 0-sized slices as its pointer field can be undefined. // We only have to do this for slices as arrays will have a valid pointer. // This logic can be removed once https://github.com/ziglang/zig/issues/16360 is done. - if (o.target.isWasm() and + if (o.target.cpu.arch.isWasm() and std.Target.wasm.featureSetHas(o.target.cpu.features, .bulk_memory) and dest_ptr_ty.isSlice(zcu)) { @@ -12696,7 +12696,7 @@ fn backendSupportsF16(target: std.Target) bool { .armeb, .thumb, .thumbeb, - => target.floatAbi() == .soft or std.Target.arm.featureSetHas(target.cpu.features, .fp_armv8), + => target.abi.float() == .soft or std.Target.arm.featureSetHas(target.cpu.features, .fp_armv8), .aarch64, .aarch64_be, => std.Target.aarch64.featureSetHas(target.cpu.features, .fp_armv8), @@ -12723,7 +12723,7 @@ fn backendSupportsF128(target: std.Target) bool { .armeb, .thumb, .thumbeb, - => target.floatAbi() == .soft or std.Target.arm.featureSetHas(target.cpu.features, .fp_armv8), + => target.abi.float() == .soft or std.Target.arm.featureSetHas(target.cpu.features, .fp_armv8), .aarch64, .aarch64_be, => std.Target.aarch64.featureSetHas(target.cpu.features, .fp_armv8), diff --git a/src/libtsan.zig b/src/libtsan.zig index fc1bfc4a36..f1bab36582 100644 --- a/src/libtsan.zig +++ b/src/libtsan.zig @@ -36,7 +36,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo .watchos => if (target.abi == .simulator) "clang_rt.tsan_watchossim_dynamic" else "clang_rt.tsan_watchos_dynamic", else => "tsan", }; - const link_mode: std.builtin.LinkMode = if (target.isDarwin()) .dynamic else .static; + const link_mode: std.builtin.LinkMode = if (target.os.tag.isDarwin()) .dynamic else .static; const output_mode = .Lib; const basename = try std.zig.binNameAlloc(arena, .{ .root_name = root_name, @@ -52,9 +52,9 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo const optimize_mode = comp.compilerRtOptMode(); const strip = comp.compilerRtStrip(); - const link_libcpp = target.isDarwin(); const unwind_tables: std.builtin.UnwindTables = if (target.cpu.arch == .x86 and target.os.tag == .windows) .none else .@"async"; + const link_libcpp = target.os.tag.isDarwin(); const config = Compilation.Config.resolve(.{ .output_mode = output_mode, @@ -276,14 +276,14 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo }); } - const skip_linker_dependencies = !target.isDarwin(); - const linker_allow_shlib_undefined = target.isDarwin(); - const install_name = if (target.isDarwin()) + const skip_linker_dependencies = !target.os.tag.isDarwin(); + const linker_allow_shlib_undefined = target.os.tag.isDarwin(); + const install_name = if (target.os.tag.isDarwin()) try std.fmt.allocPrintZ(arena, "@rpath/{s}", .{basename}) else null; // Workaround for https://github.com/llvm/llvm-project/issues/97627 - const headerpad_size: ?u32 = if (target.isDarwin()) 32 else null; + const headerpad_size: ?u32 = if (target.os.tag.isDarwin()) 32 else null; const sub_compilation = Compilation.create(comp.gpa, arena, .{ .local_cache_directory = comp.global_cache_directory, .global_cache_directory = comp.global_cache_directory, diff --git a/src/libunwind.zig b/src/libunwind.zig index 75b573b520..937501933f 100644 --- a/src/libunwind.zig +++ b/src/libunwind.zig @@ -136,7 +136,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr if (!comp.config.any_non_single_threaded) { try cflags.append("-D_LIBUNWIND_HAS_NO_THREADS"); } - if (target.cpu.arch.isArm() and target.abi.floatAbi() == .hard) { + if (target.cpu.arch.isArm() and target.abi.float() == .hard) { try cflags.append("-DCOMPILER_RT_ARMHF_TARGET"); } try cflags.append("-Wno-bitwise-conditional-parentheses"); diff --git a/src/link.zig b/src/link.zig index ec59cce101..d805b331e3 100644 --- a/src/link.zig +++ b/src/link.zig @@ -2067,7 +2067,7 @@ fn resolveLibInput( const lib_name = name_query.name; - if (target.isDarwin() and link_mode == .dynamic) tbd: { + if (target.os.tag.isDarwin() and link_mode == .dynamic) tbd: { // Prefer .tbd over .dylib. const test_path: Path = .{ .root_dir = lib_directory, @@ -2104,7 +2104,7 @@ fn resolveLibInput( // In the case of Darwin, the main check will be .dylib, so here we // additionally check for .so files. - if (target.isDarwin() and link_mode == .dynamic) so: { + if (target.os.tag.isDarwin() and link_mode == .dynamic) so: { const test_path: Path = .{ .root_dir = lib_directory, .sub_path = try std.fmt.allocPrint(arena, "lib{s}.so", .{lib_name}), diff --git a/src/link/Coff.zig b/src/link/Coff.zig index abba4f2a6a..3a9ba1e149 100644 --- a/src/link/Coff.zig +++ b/src/link/Coff.zig @@ -1881,7 +1881,7 @@ fn linkWithLLD(coff: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: try argv.append(try allocPrint(arena, "-MLLVM:-target-abi={s}", .{mabi})); } - try argv.append(try allocPrint(arena, "-MLLVM:-float-abi={s}", .{if (target.abi.floatAbi() == .hard) "hard" else "soft"})); + try argv.append(try allocPrint(arena, "-MLLVM:-float-abi={s}", .{if (target.abi.float() == .hard) "hard" else "soft"})); if (comp.config.lto != .none) { switch (optimize_mode) { diff --git a/src/link/Elf.zig b/src/link/Elf.zig index edd45f65ee..990dacf67f 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -1709,7 +1709,7 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s try argv.appendSlice(&.{ "-mllvm", - try std.fmt.allocPrint(arena, "-float-abi={s}", .{if (target.abi.floatAbi() == .hard) "hard" else "soft"}), + try std.fmt.allocPrint(arena, "-float-abi={s}", .{if (target.abi.float() == .hard) "hard" else "soft"}), }); if (comp.config.lto != .none) { @@ -2053,7 +2053,7 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s try argv.append(lib_path); } try argv.append(try comp.crtFileAsString(arena, "libc_nonshared.a")); - } else if (target.isMusl()) { + } else if (target.abi.isMusl()) { try argv.append(try comp.crtFileAsString(arena, switch (link_mode) { .static => "libc.a", .dynamic => "libc.so", diff --git a/src/link/MachO.zig b/src/link/MachO.zig index a5d4379004..a5e3d2e070 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -3548,7 +3548,7 @@ pub fn getTarget(self: MachO) std.Target { pub fn invalidateKernelCache(dir: fs.Dir, sub_path: []const u8) !void { const tracy = trace(@src()); defer tracy.end(); - if (builtin.target.isDarwin() and builtin.target.cpu.arch == .aarch64) { + if (builtin.target.os.tag.isDarwin() and builtin.target.cpu.arch == .aarch64) { try dir.copyFile(sub_path, dir, sub_path, .{}); } } diff --git a/src/main.zig b/src/main.zig index 773426dab9..eac8674b19 100644 --- a/src/main.zig +++ b/src/main.zig @@ -3983,7 +3983,7 @@ fn createModule( } create_module.lib_dir_args = undefined; // From here we use lib_directories instead. - if (resolved_target.is_native_os and target.isDarwin()) { + if (resolved_target.is_native_os and target.os.tag.isDarwin()) { // If we want to link against frameworks, we need system headers. if (create_module.frameworks.count() > 0) create_module.want_native_include_dirs = true; diff --git a/src/target.zig b/src/target.zig index 621cac3479..8ccec7f7a8 100644 --- a/src/target.zig +++ b/src/target.zig @@ -12,7 +12,7 @@ pub const default_stack_protector_buffer_size = 4; pub fn cannotDynamicLink(target: std.Target) bool { return switch (target.os.tag) { .freestanding => true, - else => target.isSpirV(), + else => target.cpu.arch.isSpirV(), }; } @@ -40,12 +40,12 @@ pub fn libcNeedsLibUnwind(target: std.Target) bool { } pub fn requiresPIE(target: std.Target) bool { - return target.isAndroid() or target.isDarwin() or target.os.tag == .openbsd; + return target.abi.isAndroid() or target.os.tag.isDarwin() or target.os.tag == .openbsd; } /// This function returns whether non-pic code is completely invalid on the given target. pub fn requiresPIC(target: std.Target, linking_libc: bool) bool { - return target.isAndroid() or + return target.abi.isAndroid() or target.os.tag == .windows or target.os.tag == .uefi or osRequiresLibC(target) or (linking_libc and target.isGnuLibC()); @@ -245,7 +245,7 @@ pub fn clangSupportsStackProtector(target: std.Target) bool { } pub fn libcProvidesStackProtector(target: std.Target) bool { - return !target.isMinGW() and target.os.tag != .wasi and !target.isSpirV(); + return !target.isMinGW() and target.os.tag != .wasi and !target.cpu.arch.isSpirV(); } pub fn supportsReturnAddress(target: std.Target) bool { |
