authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-09-27 02:01:07+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-09-28 21:43:52+02:00
log537a873b171b521d422704fc1f9c23f8d3b954ea
tree5fb4a2dee58220de64e158b95ba02a23e9eda613
parent4ceefca14be313e91a248fdc532e37edf4a02a51
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

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

https://llvm.org/docs/HowToBuildWindowsItaniumPrograms.html This is a weird middle ground between `*-windows-gnu` and `*-windows-msvc`. It uses the C++ ABI of the former while using the system libraries of the latter.

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

lib/compiler_rt/aulldiv.zig+2-1
......@@ -1,13 +1,14 @@
11const std = @import("std");
22const builtin = @import("builtin");
33const arch = builtin.cpu.arch;
4const os = builtin.os.tag;
45const abi = builtin.abi;
56const common = @import("common.zig");
67
78pub const panic = common.panic;
89
910comptime {
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) {
1112 // Don't let LLVM apply the stdcall name mangling on those MSVC builtins
1213 @export(&_alldiv, .{ .name = "\x01__alldiv", .linkage = common.linkage, .visibility = common.visibility });
1314 @export(&_aulldiv, .{ .name = "\x01__aulldiv", .linkage = common.linkage, .visibility = common.visibility });
lib/compiler_rt/aullrem.zig+2-1
......@@ -1,13 +1,14 @@
11const std = @import("std");
22const builtin = @import("builtin");
33const arch = builtin.cpu.arch;
4const os = builtin.os.tag;
45const abi = builtin.abi;
56const common = @import("common.zig");
67
78pub const panic = common.panic;
89
910comptime {
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) {
1112 // Don't let LLVM apply the stdcall name mangling on those MSVC builtins
1213 @export(&_allrem, .{ .name = "\x01__allrem", .linkage = common.linkage, .visibility = common.visibility });
1314 @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 {
113113
114114 pub fn staticLibSuffix(tag: Tag, abi: Abi) [:0]const u8 {
115115 return switch (abi) {
116 .msvc => ".lib",
116 .msvc, .itanium => ".lib",
117117 else => switch (tag) {
118118 .windows, .uefi => ".lib",
119119 else => ".a",
......@@ -138,7 +138,7 @@ pub const Os = struct {
138138
139139 pub fn libPrefix(tag: Os.Tag, abi: Abi) [:0]const u8 {
140140 return switch (abi) {
141 .msvc => "",
141 .msvc, .itanium => "",
142142 else => switch (tag) {
143143 .windows, .uefi => "",
144144 else => "lib",
lib/std/c.zig+1-1
......@@ -9506,7 +9506,7 @@ else if (native_os == .linux and builtin.target.isMusl())
95069506else
95079507 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)
95109510 f64
95119511else if (builtin.target.isDarwin())
95129512 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;
99export var __xl_z: windows.PIMAGE_TLS_CALLBACK linksection(".CRT$XLZ") = null;
1010
1111comptime {
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) {
1313 // The __tls_array is the offset of the ThreadLocalStoragePointer field
1414 // in the TEB block whose base address held in the %fs segment.
1515 asm (
lib/std/zig/LibCDirs.zig+1-1
......@@ -69,7 +69,7 @@ pub fn detect(
6969 // On windows, instead of the native (mingw) abi, we want to check
7070 // for the MSVC abi as a fallback.
7171 const use_system_abi = if (builtin.os.tag == .windows)
72 target.abi == .msvc
72 target.abi == .msvc or target.abi == .itanium
7373 else
7474 is_native_abi;
7575
lib/std/zig/LibCInstallation.zig+2-2
......@@ -86,14 +86,14 @@ pub fn parse(
8686 return error.ParseError;
8787 }
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)) {
9090 log.err("msvc_lib_dir may not be empty for {s}-{s}", .{
9191 @tagName(os_tag),
9292 @tagName(target.abi),
9393 });
9494 return error.ParseError;
9595 }
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)) {
9797 log.err("kernel32_lib_dir may not be empty for {s}-{s}", .{
9898 @tagName(os_tag),
9999 @tagName(target.abi),
src/Compilation.zig+1-1
......@@ -2639,7 +2639,7 @@ fn addNonIncrementalStuffToCacheManifest(
26392639 const target = comp.root_mod.resolved_target.result;
26402640 if (comp.libc_installation) |libc_installation| {
26412641 man.hash.addOptionalBytes(libc_installation.crt_dir);
2642 if (target.abi == .msvc) {
2642 if (target.abi == .msvc or target.abi == .itanium) {
26432643 man.hash.addOptionalBytes(libc_installation.msvc_lib_dir);
26442644 man.hash.addOptionalBytes(libc_installation.kernel32_lib_dir);
26452645 }
src/clang.zig+1-1
......@@ -64,7 +64,7 @@ pub const APValueKind = enum(c_int) {
6464
6565pub const APValue = extern struct {
6666 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
6969 pub const getKind = ZigClangAPValue_getKind;
7070 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!
221221 for (libcxx_files) |cxx_src| {
222222 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) {
225225 // Filesystem stuff isn't supported on WASI and Windows (MSVC).
226226 if (std.mem.startsWith(u8, cxx_src, "src/filesystem/"))
227227 continue;
src/link/C.zig+1-1
......@@ -398,7 +398,7 @@ fn abiDefines(self: *C, target: std.Target) !std.ArrayList(u8) {
398398 errdefer defines.deinit();
399399 const writer = defines.writer();
400400 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"),
402402 else => {},
403403 }
404404 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
9393 man.hash.add(comp.libc_installation != null);
9494 if (comp.libc_installation) |libc_installation| {
9595 man.hash.addBytes(libc_installation.crt_dir.?);
96 if (target.abi == .msvc) {
96 if (target.abi == .msvc or target.abi == .itanium) {
9797 man.hash.addBytes(libc_installation.msvc_lib_dir.?);
9898 man.hash.addBytes(libc_installation.kernel32_lib_dir.?);
9999 }
......@@ -256,7 +256,7 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_no
256256 if (comp.libc_installation) |libc_installation| {
257257 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) {
260260 try argv.append(try allocPrint(arena, "-LIBPATH:{s}", .{libc_installation.msvc_lib_dir.?}));
261261 try argv.append(try allocPrint(arena, "-LIBPATH:{s}", .{libc_installation.kernel32_lib_dir.?}));
262262 }
......@@ -499,7 +499,7 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, tid: Zcu.PerThread.Id, prog_no
499499 continue;
500500 }
501501 }
502 if (target.abi == .msvc) {
502 if (target.abi == .msvc or target.abi == .itanium) {
503503 argv.appendAssumeCapacity(lib_basename);
504504 continue;
505505 }
src/main.zig+1-1
......@@ -3874,7 +3874,7 @@ fn createModule(
38743874 };
38753875 }
38763876
3877 if (builtin.target.os.tag == .windows and target.abi == .msvc and
3877 if (builtin.target.os.tag == .windows and (target.abi == .msvc or target.abi == .itanium) and
38783878 external_system_libs.len != 0)
38793879 {
38803880 if (create_module.libc_installation == null) {
src/target.zig+2-2
......@@ -31,7 +31,7 @@ pub fn libcNeedsLibUnwind(target: std.Target) bool {
3131 .wasi, // Wasm/WASI currently doesn't offer support for libunwind, so don't link it.
3232 => false,
3333
34 .windows => target.abi != .msvc,
34 .windows => target.abi.isGnu(),
3535 else => true,
3636 };
3737}
......@@ -87,7 +87,7 @@ pub fn hasValgrindSupport(target: std.Target) bool {
8787 .aarch64_be,
8888 => {
8989 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());
9191 },
9292 else => return false,
9393 }