From 097f1e563b0b40388f94ed123ce6280c46c020c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=27vesim=27=20Kuli=C5=84ski?= Date: Mon, 21 Jul 2025 13:02:27 +0200 Subject: [PATCH 1/2] std.Target: add vita os --- lib/std/Target.zig | 21 ++++++++++++++++++--- src/Compilation.zig | 5 +++++ src/codegen/llvm.zig | 3 ++- test/llvm_targets.zig | 2 ++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/lib/std/Target.zig b/lib/std/Target.zig index c75e2b51fba0..43467834a925 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -53,6 +53,7 @@ pub const Os = struct { ps3, ps4, ps5, + vita, emscripten, wasi, @@ -203,6 +204,8 @@ pub const Os = struct { .opencl, .opengl, .vulkan, + + .vita, => .semver, .hurd => .hurd, @@ -649,6 +652,13 @@ pub const Os = struct { .max = .{ .major = 1, .minor = 4, .patch = 313 }, }, }, + .vita => .{ + .semver = .{ + // 1.3 is the first public release + .min = .{ .major = 1, .minor = 3, .patch = 0 }, + .max = .{ .major = 3, .minor = 60, .patch = 0 }, + }, + }, }; } }; @@ -725,13 +735,14 @@ pub const Os = struct { .freestanding, .fuchsia, .ps3, + .ps4, + .ps5, + .vita, .zos, .rtems, .cuda, .nvcl, .amdhsa, - .ps4, - .ps5, .mesa3d, .contiki, .amdpal, @@ -913,6 +924,7 @@ pub const Abi = enum { .windows => .gnu, .uefi => .msvc, .wasi, .emscripten => .musl, + .vita => .eabihf, .contiki, .fuchsia, @@ -2164,6 +2176,7 @@ pub const DynamicLinker = struct { .ps3, .ps4, .ps5, + .vita, => .none, }; } @@ -2544,6 +2557,8 @@ pub const DynamicLinker = struct { .opencl, .opengl, .vulkan, + + .vita, => none, // TODO go over each item in this list and either move it to the above list, or @@ -2747,7 +2762,7 @@ pub fn cTypeByteSize(t: *const Target, c_type: CType) u16 { pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 { switch (target.os.tag) { - .freestanding, .other => switch (target.cpu.arch) { + .freestanding, .other, .vita, => switch (target.cpu.arch) { .msp430 => switch (c_type) { .char => return 8, .short, .ushort, .int, .uint => return 16, diff --git a/src/Compilation.zig b/src/Compilation.zig index b5597017c4b2..b2843d1ef664 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -6350,6 +6350,11 @@ pub fn addCCArgs( // doesn't matter which one gets overridden. argv.appendAssumeCapacity("-Wno-overriding-option"); }, + .vita => { + // LLVM doesn't support this target, so we + // have to add this manually + try argv.append("-D__vita__"); + }, else => {}, } diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index a570dd5ec0cd..48444ccaad2a 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -197,7 +197,6 @@ pub fn targetTriple(allocator: Allocator, target: *const std.Target) ![]const u8 .freebsd => "freebsd", .fuchsia => "fuchsia", .linux => "linux", - .ps3 => "lv2", .netbsd => "netbsd", .openbsd => "openbsd", .solaris, .illumos => "solaris", @@ -210,8 +209,10 @@ pub fn targetTriple(allocator: Allocator, target: *const std.Target) ![]const u8 .nvcl => "nvcl", .amdhsa => "amdhsa", .opencl => "unknown", // https://llvm.org/docs/SPIRVUsage.html#target-triples + .ps3 => "lv2", .ps4 => "ps4", .ps5 => "ps5", + .vita => "unknown", // LLVM doesn't know about this target .mesa3d => "mesa3d", .amdpal => "amdpal", .hermit => "hermit", diff --git a/test/llvm_targets.zig b/test/llvm_targets.zig index 3cb867f76335..ba569cc00c43 100644 --- a/test/llvm_targets.zig +++ b/test/llvm_targets.zig @@ -67,6 +67,7 @@ const targets = [_]std.Target.Query{ .{ .cpu_arch = .arm, .os_tag = .openbsd, .abi = .eabihf }, .{ .cpu_arch = .arm, .os_tag = .rtems, .abi = .eabi }, .{ .cpu_arch = .arm, .os_tag = .rtems, .abi = .eabihf }, + .{ .cpu_arch = .arm, .os_tag = .vita, .abi = .eabihf }, // .{ .cpu_arch = .arm, .os_tag = .uefi, .abi = .eabi }, // .{ .cpu_arch = .arm, .os_tag = .uefi, .abi = .eabihf }, @@ -261,6 +262,7 @@ const targets = [_]std.Target.Query{ .{ .cpu_arch = .thumb, .os_tag = .windows, .abi = .gnu }, .{ .cpu_arch = .thumb, .os_tag = .windows, .abi = .itanium }, .{ .cpu_arch = .thumb, .os_tag = .windows, .abi = .msvc }, + .{ .cpu_arch = .thumb, .os_tag = .vita, .abi = .eabihf }, .{ .cpu_arch = .thumbeb, .os_tag = .freestanding, .abi = .eabi }, .{ .cpu_arch = .thumbeb, .os_tag = .freestanding, .abi = .eabihf }, From 519c86c15853b65bf35d2143012da627dcdcb934 Mon Sep 17 00:00:00 2001 From: Vesim Date: Mon, 21 Jul 2025 13:21:04 +0200 Subject: [PATCH 2/2] fix formatting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alex Rønne Petersen --- lib/std/Target.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/std/Target.zig b/lib/std/Target.zig index 43467834a925..d8de04fd45cf 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -2762,7 +2762,7 @@ pub fn cTypeByteSize(t: *const Target, c_type: CType) u16 { pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 { switch (target.os.tag) { - .freestanding, .other, .vita, => switch (target.cpu.arch) { + .freestanding, .other, .vita => switch (target.cpu.arch) { .msp430 => switch (c_type) { .char => return 8, .short, .ushort, .int, .uint => return 16,