authorgravatar for vesim809@pm.meMaciej 'vesim' Kuliński <vesim809@pm.me> 2025-07-21 13:02:27+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-08-26 07:50:06+02:00
logff859088e409f3fcf7c4f52e58ec4e6e9f7f1c4e
treea4de53d27594d23fb8cb61364d745feb1e11bd0b
parent99b2b61516b7ee9c4cd31ebe88161dd7191c2e0d

std.Target: add vita os

Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>

4 files changed, 37 insertions(+), 2 deletions(-)

lib/std/Target.zig+31-1
...@@ -55,6 +55,7 @@ pub const Os = struct {...@@ -55,6 +55,7 @@ pub const Os = struct {
55 ps3,55 ps3,
56 ps4,56 ps4,
57 ps5,57 ps5,
58 vita,
5859
59 emscripten,60 emscripten,
60 wasi,61 wasi,
...@@ -198,6 +199,8 @@ pub const Os = struct {...@@ -198,6 +199,8 @@ pub const Os = struct {
198199
199 .@"3ds",200 .@"3ds",
200201
202 .vita,
203
201 .wasi,204 .wasi,
202205
203 .amdhsa,206 .amdhsa,
...@@ -607,6 +610,7 @@ pub const Os = struct {...@@ -607,6 +610,7 @@ pub const Os = struct {
607 .max = .{ .major = 2, .minor = 11, .patch = 0 },610 .max = .{ .major = 2, .minor = 11, .patch = 0 },
608 },611 },
609 },612 },
613
610 .@"3ds" => .{614 .@"3ds" => .{
611 .semver = .{615 .semver = .{
612 // These signify release versions (https://www.3dbrew.org/wiki/NCCH/Extended_Header#ARM11_Kernel_Capabilities)616 // These signify release versions (https://www.3dbrew.org/wiki/NCCH/Extended_Header#ARM11_Kernel_Capabilities)
...@@ -618,6 +622,15 @@ pub const Os = struct {...@@ -618,6 +622,15 @@ pub const Os = struct {
618 .max = .{ .major = 2, .minor = 58, .patch = 0 }, // 11.17.0-50622 .max = .{ .major = 2, .minor = 58, .patch = 0 }, // 11.17.0-50
619 },623 },
620 },624 },
625
626 .vita => .{
627 .semver = .{
628 // 1.3 is the first public release
629 .min = .{ .major = 1, .minor = 3, .patch = 0 },
630 .max = .{ .major = 3, .minor = 60, .patch = 0 },
631 },
632 },
633
621 .wasi => .{634 .wasi => .{
622 .semver = .{635 .semver = .{
623 .min = .{ .major = 0, .minor = 1, .patch = 0 },636 .min = .{ .major = 0, .minor = 1, .patch = 0 },
...@@ -876,6 +889,7 @@ pub const Abi = enum {...@@ -876,6 +889,7 @@ pub const Abi = enum {
876 .windows => .gnu,889 .windows => .gnu,
877 .uefi => .msvc,890 .uefi => .msvc,
878 .@"3ds" => .eabihf,891 .@"3ds" => .eabihf,
892 .vita => .eabihf,
879 .wasi, .emscripten => .musl,893 .wasi, .emscripten => .musl,
880894
881 .contiki,895 .contiki,
...@@ -1863,9 +1877,14 @@ pub const Cpu = struct {...@@ -1863,9 +1877,14 @@ pub const Cpu = struct {
1863 .amdgcn => &amdgcn.cpu.gfx906,1877 .amdgcn => &amdgcn.cpu.gfx906,
1864 .arm => switch (os.tag) {1878 .arm => switch (os.tag) {
1865 .@"3ds" => &arm.cpu.mpcore,1879 .@"3ds" => &arm.cpu.mpcore,
1880 .vita => &arm.cpu.cortex_a9,
1881 else => &arm.cpu.baseline,
1882 },
1883 .thumb => switch (os.tag) {
1884 .vita => &arm.cpu.cortex_a9,
1866 else => &arm.cpu.baseline,1885 else => &arm.cpu.baseline,
1867 },1886 },
1868 .armeb, .thumb, .thumbeb => &arm.cpu.baseline,1887 .armeb, .thumbeb => &arm.cpu.baseline,
1869 .aarch64 => switch (os.tag) {1888 .aarch64 => switch (os.tag) {
1870 .driverkit, .macos => &aarch64.cpu.apple_m1,1889 .driverkit, .macos => &aarch64.cpu.apple_m1,
1871 .ios, .tvos => &aarch64.cpu.apple_a7,1890 .ios, .tvos => &aarch64.cpu.apple_a7,
...@@ -2079,6 +2098,7 @@ pub fn requiresLibC(target: *const Target) bool {...@@ -2079,6 +2098,7 @@ pub fn requiresLibC(target: *const Target) bool {
2079 .amdhsa,2098 .amdhsa,
2080 .ps4,2099 .ps4,
2081 .ps5,2100 .ps5,
2101 .vita,
2082 .mesa3d,2102 .mesa3d,
2083 .contiki,2103 .contiki,
2084 .amdpal,2104 .amdpal,
...@@ -2208,6 +2228,7 @@ pub const DynamicLinker = struct {...@@ -2208,6 +2228,7 @@ pub const DynamicLinker = struct {
2208 .ps3,2228 .ps3,
2209 .ps4,2229 .ps4,
2210 .ps5,2230 .ps5,
2231 .vita,
2211 => .none,2232 => .none,
2212 };2233 };
2213 }2234 }
...@@ -2579,6 +2600,8 @@ pub const DynamicLinker = struct {...@@ -2579,6 +2600,8 @@ pub const DynamicLinker = struct {
25792600
2580 .@"3ds",2601 .@"3ds",
25812602
2603 .vita,
2604
2582 .emscripten,2605 .emscripten,
2583 .wasi,2606 .wasi,
25842607
...@@ -3111,6 +3134,13 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {...@@ -3111,6 +3134,13 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
3111 .longlong, .ulonglong, .double => return 64,3134 .longlong, .ulonglong, .double => return 64,
3112 .longdouble => return 80,3135 .longdouble => return 80,
3113 },3136 },
3137 .vita => switch (c_type) {
3138 .char => return 8,
3139 .short, .ushort => return 16,
3140 .int, .uint, .float => return 32,
3141 .long, .ulong => return 64,
3142 .longlong, .ulonglong, .double, .longdouble => return 64,
3143 },
31143144
3115 .ps3,3145 .ps3,
3116 .contiki,3146 .contiki,
src/Compilation.zig+2
...@@ -6927,8 +6927,10 @@ pub fn addCCArgs(...@@ -6927,8 +6927,10 @@ pub fn addCCArgs(
6927 },6927 },
6928 }6928 }
69296929
6930 // Homebrew targets without LLVM support; use communities's preferred macros.
6930 switch (target.os.tag) {6931 switch (target.os.tag) {
6931 .@"3ds" => try argv.append("-D__3DS__"),6932 .@"3ds" => try argv.append("-D__3DS__"),
6933 .vita => try argv.append("-D__vita__"),
6932 else => {},6934 else => {},
6933 }6935 }
69346936
src/codegen/llvm.zig+2-1
...@@ -200,7 +200,6 @@ pub fn targetTriple(allocator: Allocator, target: *const std.Target) ![]const u8...@@ -200,7 +200,6 @@ pub fn targetTriple(allocator: Allocator, target: *const std.Target) ![]const u8
200 .freebsd => "freebsd",200 .freebsd => "freebsd",
201 .fuchsia => "fuchsia",201 .fuchsia => "fuchsia",
202 .linux => "linux",202 .linux => "linux",
203 .ps3 => "lv2",
204 .netbsd => "netbsd",203 .netbsd => "netbsd",
205 .openbsd => "openbsd",204 .openbsd => "openbsd",
206 .solaris, .illumos => "solaris",205 .solaris, .illumos => "solaris",
...@@ -213,8 +212,10 @@ pub fn targetTriple(allocator: Allocator, target: *const std.Target) ![]const u8...@@ -213,8 +212,10 @@ pub fn targetTriple(allocator: Allocator, target: *const std.Target) ![]const u8
213 .nvcl => "nvcl",212 .nvcl => "nvcl",
214 .amdhsa => "amdhsa",213 .amdhsa => "amdhsa",
215 .opencl => "unknown", // https://llvm.org/docs/SPIRVUsage.html#target-triples214 .opencl => "unknown", // https://llvm.org/docs/SPIRVUsage.html#target-triples
215 .ps3 => "lv2",
216 .ps4 => "ps4",216 .ps4 => "ps4",
217 .ps5 => "ps5",217 .ps5 => "ps5",
218 .vita => "unknown", // LLVM doesn't know about this target
218 .mesa3d => "mesa3d",219 .mesa3d => "mesa3d",
219 .amdpal => "amdpal",220 .amdpal => "amdpal",
220 .hermit => "hermit",221 .hermit => "hermit",
test/llvm_targets.zig+2
...@@ -70,6 +70,7 @@ const targets = [_]std.Target.Query{...@@ -70,6 +70,7 @@ const targets = [_]std.Target.Query{
70 .{ .cpu_arch = .arm, .os_tag = .rtems, .abi = .eabihf },70 .{ .cpu_arch = .arm, .os_tag = .rtems, .abi = .eabihf },
71 // .{ .cpu_arch = .arm, .os_tag = .uefi, .abi = .eabi },71 // .{ .cpu_arch = .arm, .os_tag = .uefi, .abi = .eabi },
72 // .{ .cpu_arch = .arm, .os_tag = .uefi, .abi = .eabihf },72 // .{ .cpu_arch = .arm, .os_tag = .uefi, .abi = .eabihf },
73 .{ .cpu_arch = .arm, .os_tag = .vita, .abi = .eabihf },
7374
74 .{ .cpu_arch = .armeb, .os_tag = .freestanding, .abi = .eabi },75 .{ .cpu_arch = .armeb, .os_tag = .freestanding, .abi = .eabi },
75 .{ .cpu_arch = .armeb, .os_tag = .freestanding, .abi = .eabihf },76 .{ .cpu_arch = .armeb, .os_tag = .freestanding, .abi = .eabihf },
...@@ -263,6 +264,7 @@ const targets = [_]std.Target.Query{...@@ -263,6 +264,7 @@ const targets = [_]std.Target.Query{
263 .{ .cpu_arch = .thumb, .os_tag = .linux, .abi = .musleabihf },264 .{ .cpu_arch = .thumb, .os_tag = .linux, .abi = .musleabihf },
264 .{ .cpu_arch = .thumb, .os_tag = .rtems, .abi = .eabi },265 .{ .cpu_arch = .thumb, .os_tag = .rtems, .abi = .eabi },
265 .{ .cpu_arch = .thumb, .os_tag = .rtems, .abi = .eabihf },266 .{ .cpu_arch = .thumb, .os_tag = .rtems, .abi = .eabihf },
267 .{ .cpu_arch = .thumb, .os_tag = .vita, .abi = .eabihf },
266 .{ .cpu_arch = .thumb, .os_tag = .windows, .abi = .gnu },268 .{ .cpu_arch = .thumb, .os_tag = .windows, .abi = .gnu },
267 .{ .cpu_arch = .thumb, .os_tag = .windows, .abi = .itanium },269 .{ .cpu_arch = .thumb, .os_tag = .windows, .abi = .itanium },
268 .{ .cpu_arch = .thumb, .os_tag = .windows, .abi = .msvc },270 .{ .cpu_arch = .thumb, .os_tag = .windows, .abi = .msvc },