commit fdf19984b8af9781cd68dda3fcbcc44ac8ade80e (tree)
parent b4d134a0d2ee238cab70f1e967b2172edbec1b41
Author: Nathan Bourgeois <iridescentrosesfall@gmail.com>
Date: Sat, 21 Mar 2026 01:47:21 -0400
std.Target: add psp os
Diffstat:
5 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/lib/std/Target.zig b/lib/std/Target.zig
@@ -53,6 +53,7 @@ pub const Os = struct {
ps3,
ps4,
ps5,
+ psp,
vita,
emscripten,
@@ -194,6 +195,7 @@ pub const Os = struct {
.@"3ds",
+ .psp,
.vita,
.wasi,
@@ -612,6 +614,13 @@ pub const Os = struct {
},
},
+ .psp => .{
+ .semver = .{
+ .min = .{ .major = 1, .minor = 0, .patch = 0 },
+ .max = .{ .major = 6, .minor = 61, .patch = 0 },
+ },
+ },
+
.vita => .{
.semver = .{
// 1.3 is the first public release
@@ -919,6 +928,7 @@ pub const Abi = enum {
.tvos,
.visionos,
.watchos,
+ .psp,
.ps3,
.ps4,
.ps5,
@@ -2023,7 +2033,10 @@ pub const Cpu = struct {
.lanai => &lanai.cpu.v11, // clang does not have a generic lanai model.
.loongarch64 => &loongarch.cpu.la64v1_0,
.m68k => &m68k.cpu.M68000,
- .mips, .mipsel => &mips.cpu.mips32r2,
+ .mips, .mipsel => switch (os.tag) {
+ .psp => &mips.cpu.mips2, // mips2 with some custom instructions, no trap instructions
+ else => &mips.cpu.mips32r2,
+ },
.mips64, .mips64el => &mips.cpu.mips64r2,
.msp430 => &msp430.cpu.msp430,
.nvptx, .nvptx64 => &nvptx.cpu.sm_52,
@@ -2204,6 +2217,7 @@ pub fn requiresLibC(target: *const Target) bool {
.amdhsa,
.ps4,
.ps5,
+ .psp,
.vita,
.mesa3d,
.contiki,
@@ -2379,6 +2393,7 @@ pub const DynamicLinker = struct {
.ps3,
.ps4,
.ps5,
+ .psp,
.vita,
=> .none,
};
@@ -2783,6 +2798,7 @@ pub const DynamicLinker = struct {
.@"3ds",
+ .psp,
.vita,
.emscripten,
@@ -3338,7 +3354,7 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
.longlong, .ulonglong, .double => return 64,
.longdouble => return 80,
},
- .vita => switch (c_type) {
+ .psp, .vita => switch (c_type) {
.char => return 8,
.short, .ushort => return 16,
.int, .uint, .float => return 32,
diff --git a/lib/std/heap.zig b/lib/std/heap.zig
@@ -805,6 +805,11 @@ const page_size_min_default: ?usize = switch (builtin.os.tag) {
.x86, .x86_64 => 16 << 10,
else => null,
},
+ .psp => switch (builtin.cpu.arch) {
+ // minimum block allocation by testing sceKernel
+ .mips, .mipsel => 1 << 8, // 256
+ else => null,
+ },
// system/lib/libc/musl/arch/emscripten/bits/limits.h
.emscripten => 64 << 10,
.linux => switch (builtin.cpu.arch) {
@@ -963,6 +968,11 @@ const page_size_max_default: ?usize = switch (builtin.os.tag) {
.x86, .x86_64 => 16 << 10,
else => null,
},
+ .psp => switch (builtin.cpu.arch) {
+ // minimum block allocation by testing sceKernel
+ .mips, .mipsel => 1 << 8, // 256
+ else => null,
+ },
// system/lib/libc/musl/arch/emscripten/bits/limits.h
.emscripten => 64 << 10,
.linux => switch (builtin.cpu.arch) {
diff --git a/lib/std/start.zig b/lib/std/start.zig
@@ -65,7 +65,7 @@ comptime {
// case it's not required to provide an entrypoint such as main.
if (!@hasDecl(root, start_sym_name) and @hasDecl(root, "main")) @export(&wasm_freestanding_start, .{ .name = start_sym_name });
} else switch (native_os) {
- .other, .freestanding, .@"3ds", .vita => {},
+ .other, .freestanding, .@"3ds", .psp, .vita => {},
else => if (!@hasDecl(root, start_sym_name)) @export(&_start, .{ .name = start_sym_name }),
}
}
diff --git a/src/Compilation.zig b/src/Compilation.zig
@@ -6420,6 +6420,7 @@ fn addCommonCCArgs(
.illumos => try argv.append("__illumos__"),
// Homebrew targets without LLVM support; use communities's preferred macros.
.@"3ds" => try argv.append("-D__3DS__"),
+ .psp => try argv.append("-D__PSP__"),
.vita => try argv.append("-D__vita__"),
else => {},
}
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
@@ -247,6 +247,7 @@ pub fn targetTriple(allocator: Allocator, target: *const std.Target) ![]const u8
.opengl,
.other,
.plan9,
+ .psp,
.vita,
=> "unknown",
};