authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-10-03 21:53:22+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-10-03 21:53:22+02:00
log9b273f6b9acaf288920e8320adaa34f30348e97f
treee7e9aff879d1662028514a4685bc31b22d23facd
parent69ce7f0e085b5fb3bf7356e9999940c60c79cfe2
parent537a873b171b521d422704fc1f9c23f8d3b954ea
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #21570 from alexrp/windows-itanium

Initial port work for `*-windows-itanium` support.

14 files changed, 21 insertions(+), 19 deletions(-)

lib/compiler_rt/aulldiv.zig+2-1
...@@ -1,13 +1,14 @@...@@ -1,13 +1,14 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");2const builtin = @import("builtin");
3const arch = builtin.cpu.arch;3const arch = builtin.cpu.arch;
4const os = builtin.os.tag;
4const abi = builtin.abi;5const abi = builtin.abi;
5const common = @import("common.zig");6const common = @import("common.zig");
67
7pub const panic = common.panic;8pub const panic = common.panic;
89
9comptime {10comptime {
10 if (arch == .x86 and abi == .msvc and builtin.zig_backend != .stage2_c) {11 if (arch == .x86 and os == .windows and (abi == .msvc or abi == .itanium) and builtin.zig_backend != .stage2_c) {
11 // Don't let LLVM apply the stdcall name mangling on those MSVC builtins12 // Don't let LLVM apply the stdcall name mangling on those MSVC builtins
12 @export(&_alldiv, .{ .name = "\x01__alldiv", .linkage = common.linkage, .visibility = common.visibility });13 @export(&_alldiv, .{ .name = "\x01__alldiv", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&_aulldiv, .{ .name = "\x01__aulldiv", .linkage = common.linkage, .visibility = common.visibility });14 @export(&_aulldiv, .{ .name = "\x01__aulldiv", .linkage = common.linkage, .visibility = common.visibility });
lib/compiler_rt/aullrem.zig+2-1
...@@ -1,13 +1,14 @@...@@ -1,13 +1,14 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");2const builtin = @import("builtin");
3const arch = builtin.cpu.arch;3const arch = builtin.cpu.arch;
4const os = builtin.os.tag;
4const abi = builtin.abi;5const abi = builtin.abi;
5const common = @import("common.zig");6const common = @import("common.zig");
67
7pub const panic = common.panic;8pub const panic = common.panic;
89
9comptime {10comptime {
10 if (arch == .x86 and abi == .msvc and builtin.zig_backend != .stage2_c) {11 if (arch == .x86 and os == .windows and (abi == .msvc or abi == .itanium) and builtin.zig_backend != .stage2_c) {
11 // Don't let LLVM apply the stdcall name mangling on those MSVC builtins12 // Don't let LLVM apply the stdcall name mangling on those MSVC builtins
12 @export(&_allrem, .{ .name = "\x01__allrem", .linkage = common.linkage, .visibility = common.visibility });13 @export(&_allrem, .{ .name = "\x01__allrem", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&_aullrem, .{ .name = "\x01__aullrem", .linkage = common.linkage, .visibility = common.visibility });14 @export(&_aullrem, .{ .name = "\x01__aullrem", .linkage = common.linkage, .visibility = common.visibility });
lib/std/Target.zig+2-2
...@@ -113,7 +113,7 @@ pub const Os = struct {...@@ -113,7 +113,7 @@ pub const Os = struct {
113113
114 pub fn staticLibSuffix(tag: Tag, abi: Abi) [:0]const u8 {114 pub fn staticLibSuffix(tag: Tag, abi: Abi) [:0]const u8 {
115 return switch (abi) {115 return switch (abi) {
116 .msvc => ".lib",116 .msvc, .itanium => ".lib",
117 else => switch (tag) {117 else => switch (tag) {
118 .windows, .uefi => ".lib",118 .windows, .uefi => ".lib",
119 else => ".a",119 else => ".a",
...@@ -138,7 +138,7 @@ pub const Os = struct {...@@ -138,7 +138,7 @@ pub const Os = struct {
138138
139 pub fn libPrefix(tag: Os.Tag, abi: Abi) [:0]const u8 {139 pub fn libPrefix(tag: Os.Tag, abi: Abi) [:0]const u8 {
140 return switch (abi) {140 return switch (abi) {
141 .msvc => "",141 .msvc, .itanium => "",
142 else => switch (tag) {142 else => switch (tag) {
143 .windows, .uefi => "",143 .windows, .uefi => "",
144 else => "lib",144 else => "lib",
lib/std/c.zig+1-1
...@@ -9506,7 +9506,7 @@ else if (native_os == .linux and builtin.target.isMusl())...@@ -9506,7 +9506,7 @@ else if (native_os == .linux and builtin.target.isMusl())
9506else9506else
9507 private.getcontext;9507 private.getcontext;
95089508
9509pub const max_align_t = if (native_abi == .msvc)9509pub const max_align_t = if (native_abi == .msvc or native_abi == .itanium)
9510 f649510 f64
9511else if (builtin.target.isDarwin())9511else if (builtin.target.isDarwin())
9512 c_longdouble9512 c_longdouble
lib/std/os/windows/tls.zig+1-1
...@@ -9,7 +9,7 @@ export var __xl_a: windows.PIMAGE_TLS_CALLBACK linksection(".CRT$XLA") = null;...@@ -9,7 +9,7 @@ export var __xl_a: windows.PIMAGE_TLS_CALLBACK linksection(".CRT$XLA") = null;
9export var __xl_z: windows.PIMAGE_TLS_CALLBACK linksection(".CRT$XLZ") = null;9export var __xl_z: windows.PIMAGE_TLS_CALLBACK linksection(".CRT$XLZ") = null;
1010
11comptime {11comptime {
12 if (builtin.cpu.arch == .x86 and builtin.abi == .msvc and builtin.zig_backend != .stage2_c) {12 if (builtin.cpu.arch == .x86 and !builtin.abi.isGnu() and builtin.zig_backend != .stage2_c) {
13 // The __tls_array is the offset of the ThreadLocalStoragePointer field13 // The __tls_array is the offset of the ThreadLocalStoragePointer field
14 // in the TEB block whose base address held in the %fs segment.14 // in the TEB block whose base address held in the %fs segment.
15 asm (15 asm (
lib/std/zig/LibCDirs.zig+1-1
...@@ -69,7 +69,7 @@ pub fn detect(...@@ -69,7 +69,7 @@ pub fn detect(
69 // On windows, instead of the native (mingw) abi, we want to check69 // On windows, instead of the native (mingw) abi, we want to check
70 // for the MSVC abi as a fallback.70 // for the MSVC abi as a fallback.
71 const use_system_abi = if (builtin.os.tag == .windows)71 const use_system_abi = if (builtin.os.tag == .windows)
72 target.abi == .msvc72 target.abi == .msvc or target.abi == .itanium
73 else73 else
74 is_native_abi;74 is_native_abi;
7575
lib/std/zig/LibCInstallation.zig+2-2
...@@ -86,14 +86,14 @@ pub fn parse(...@@ -86,14 +86,14 @@ pub fn parse(
86 return error.ParseError;86 return error.ParseError;
87 }87 }
8888
89 if (self.msvc_lib_dir == null and os_tag == .windows and target.abi == .msvc) {89 if (self.msvc_lib_dir == null and os_tag == .windows and (target.abi == .msvc or target.abi == .itanium)) {
90 log.err("msvc_lib_dir may not be empty for {s}-{s}", .{90 log.err("msvc_lib_dir may not be empty for {s}-{s}", .{
91 @tagName(os_tag),91 @tagName(os_tag),
92 @tagName(target.abi),92 @tagName(target.abi),
93 });93 });
94 return error.ParseError;94 return error.ParseError;
95 }95 }
96 if (self.kernel32_lib_dir == null and os_tag == .windows and target.abi == .msvc) {96 if (self.kernel32_lib_dir == null and os_tag == .windows and (target.abi == .msvc or target.abi == .itanium)) {
97 log.err("kernel32_lib_dir may not be empty for {s}-{s}", .{97 log.err("kernel32_lib_dir may not be empty for {s}-{s}", .{
98 @tagName(os_tag),98 @tagName(os_tag),
99 @tagName(target.abi),99 @tagName(target.abi),
src/Compilation.zig+1-1
...@@ -2631,7 +2631,7 @@ fn addNonIncrementalStuffToCacheManifest(...@@ -2631,7 +2631,7 @@ fn addNonIncrementalStuffToCacheManifest(
2631 const target = comp.root_mod.resolved_target.result;2631 const target = comp.root_mod.resolved_target.result;
2632 if (comp.libc_installation) |libc_installation| {2632 if (comp.libc_installation) |libc_installation| {
2633 man.hash.addOptionalBytes(libc_installation.crt_dir);2633 man.hash.addOptionalBytes(libc_installation.crt_dir);
2634 if (target.abi == .msvc) {2634 if (target.abi == .msvc or target.abi == .itanium) {
2635 man.hash.addOptionalBytes(libc_installation.msvc_lib_dir);2635 man.hash.addOptionalBytes(libc_installation.msvc_lib_dir);
2636 man.hash.addOptionalBytes(libc_installation.kernel32_lib_dir);2636 man.hash.addOptionalBytes(libc_installation.kernel32_lib_dir);
2637 }2637 }
src/clang.zig+1-1
...@@ -64,7 +64,7 @@ pub const APValueKind = enum(c_int) {...@@ -64,7 +64,7 @@ pub const APValueKind = enum(c_int) {
6464
65pub const APValue = extern struct {65pub const APValue = extern struct {
66 Kind: APValueKind,66 Kind: APValueKind,
67 Data: if (builtin.os.tag == .windows and builtin.abi == .msvc) [52]u8 else [68]u8,67 Data: if (builtin.os.tag == .windows and (builtin.abi == .msvc or builtin.abi == .itanium)) [52]u8 else [68]u8,
6868
69 pub const getKind = ZigClangAPValue_getKind;69 pub const getKind = ZigClangAPValue_getKind;
70 extern fn ZigClangAPValue_getKind(*const APValue) APValueKind;70 extern fn ZigClangAPValue_getKind(*const APValue) APValueKind;
src/libcxx.zig+1-1
...@@ -221,7 +221,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: std.Progress.Node) BuildError!...@@ -221,7 +221,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: std.Progress.Node) BuildError!
221 for (libcxx_files) |cxx_src| {221 for (libcxx_files) |cxx_src| {
222 var cflags = std.ArrayList([]const u8).init(arena);222 var cflags = std.ArrayList([]const u8).init(arena);
223223
224 if ((target.os.tag == .windows and target.abi == .msvc) or target.os.tag == .wasi) {224 if ((target.os.tag == .windows and (target.abi == .msvc or target.abi == .itanium)) or target.os.tag == .wasi) {
225 // Filesystem stuff isn't supported on WASI and Windows (MSVC).225 // Filesystem stuff isn't supported on WASI and Windows (MSVC).
226 if (std.mem.startsWith(u8, cxx_src, "src/filesystem/"))226 if (std.mem.startsWith(u8, cxx_src, "src/filesystem/"))
227 continue;227 continue;
src/link/C.zig+1-1
...@@ -398,7 +398,7 @@ fn abiDefines(self: *C, target: std.Target) !std.ArrayList(u8) {...@@ -398,7 +398,7 @@ fn abiDefines(self: *C, target: std.Target) !std.ArrayList(u8) {
398 errdefer defines.deinit();398 errdefer defines.deinit();
399 const writer = defines.writer();399 const writer = defines.writer();
400 switch (target.abi) {400 switch (target.abi) {
401 .msvc => try writer.writeAll("#define ZIG_TARGET_ABI_MSVC\n"),401 .msvc, .itanium => try writer.writeAll("#define ZIG_TARGET_ABI_MSVC\n"),
402 else => {},402 else => {},
403 }403 }
404 try writer.print("#define ZIG_TARGET_MAX_INT_ALIGNMENT {d}\n", .{404 try writer.print("#define ZIG_TARGET_MAX_INT_ALIGNMENT {d}\n", .{
src/link/Coff/lld.zig+3-3
...@@ -93,7 +93,7 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_no...@@ -93,7 +93,7 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_no
93 man.hash.add(comp.libc_installation != null);93 man.hash.add(comp.libc_installation != null);
94 if (comp.libc_installation) |libc_installation| {94 if (comp.libc_installation) |libc_installation| {
95 man.hash.addBytes(libc_installation.crt_dir.?);95 man.hash.addBytes(libc_installation.crt_dir.?);
96 if (target.abi == .msvc) {96 if (target.abi == .msvc or target.abi == .itanium) {
97 man.hash.addBytes(libc_installation.msvc_lib_dir.?);97 man.hash.addBytes(libc_installation.msvc_lib_dir.?);
98 man.hash.addBytes(libc_installation.kernel32_lib_dir.?);98 man.hash.addBytes(libc_installation.kernel32_lib_dir.?);
99 }99 }
...@@ -256,7 +256,7 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_no...@@ -256,7 +256,7 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_no
256 if (comp.libc_installation) |libc_installation| {256 if (comp.libc_installation) |libc_installation| {
257 try argv.append(try allocPrint(arena, "-LIBPATH:{s}", .{libc_installation.crt_dir.?}));257 try argv.append(try allocPrint(arena, "-LIBPATH:{s}", .{libc_installation.crt_dir.?}));
258258
259 if (target.abi == .msvc) {259 if (target.abi == .msvc or target.abi == .itanium) {
260 try argv.append(try allocPrint(arena, "-LIBPATH:{s}", .{libc_installation.msvc_lib_dir.?}));260 try argv.append(try allocPrint(arena, "-LIBPATH:{s}", .{libc_installation.msvc_lib_dir.?}));
261 try argv.append(try allocPrint(arena, "-LIBPATH:{s}", .{libc_installation.kernel32_lib_dir.?}));261 try argv.append(try allocPrint(arena, "-LIBPATH:{s}", .{libc_installation.kernel32_lib_dir.?}));
262 }262 }
...@@ -499,7 +499,7 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_no...@@ -499,7 +499,7 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_no
499 continue;499 continue;
500 }500 }
501 }501 }
502 if (target.abi == .msvc) {502 if (target.abi == .msvc or target.abi == .itanium) {
503 argv.appendAssumeCapacity(lib_basename);503 argv.appendAssumeCapacity(lib_basename);
504 continue;504 continue;
505 }505 }
src/main.zig+1-1
...@@ -3876,7 +3876,7 @@ fn createModule(...@@ -3876,7 +3876,7 @@ fn createModule(
3876 };3876 };
3877 }3877 }
38783878
3879 if (builtin.target.os.tag == .windows and target.abi == .msvc and3879 if (builtin.target.os.tag == .windows and (target.abi == .msvc or target.abi == .itanium) and
3880 external_system_libs.len != 0)3880 external_system_libs.len != 0)
3881 {3881 {
3882 if (create_module.libc_installation == null) {3882 if (create_module.libc_installation == null) {
src/target.zig+2-2
...@@ -31,7 +31,7 @@ pub fn libcNeedsLibUnwind(target: std.Target) bool {...@@ -31,7 +31,7 @@ pub fn libcNeedsLibUnwind(target: std.Target) bool {
31 .wasi, // Wasm/WASI currently doesn't offer support for libunwind, so don't link it.31 .wasi, // Wasm/WASI currently doesn't offer support for libunwind, so don't link it.
32 => false,32 => false,
3333
34 .windows => target.abi != .msvc,34 .windows => target.abi.isGnu(),
35 else => true,35 else => true,
36 };36 };
37}37}
...@@ -87,7 +87,7 @@ pub fn hasValgrindSupport(target: std.Target) bool {...@@ -87,7 +87,7 @@ pub fn hasValgrindSupport(target: std.Target) bool {
87 .aarch64_be,87 .aarch64_be,
88 => {88 => {
89 return target.os.tag == .linux or target.os.tag == .solaris or target.os.tag == .illumos or89 return target.os.tag == .linux or target.os.tag == .solaris or target.os.tag == .illumos or
90 (target.os.tag == .windows and target.abi != .msvc);90 (target.os.tag == .windows and target.abi.isGnu());
91 },91 },
92 else => return false,92 else => return false,
93 }93 }