authorgravatar for me@gasinfinity.devGasInfinity <me@gasinfinity.dev> 2025-08-20 22:53:36+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-08-22 04:14:53+02:00
logcc71936eb9ddb94b163b296e5a8e8c3f2f7c87d4
treeb066aa40763dd0bb8bde5cc2660b60cbff19bce9
parent55daefdb108ea0bf0406dcc3e0569f7b72c639b3

feat(std.Target): add 3ds os


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

lib/std/Target.zig+27-2
...@@ -50,6 +50,8 @@ pub const Os = struct {...@@ -50,6 +50,8 @@ pub const Os = struct {
50 windows,50 windows,
51 uefi,51 uefi,
5252
53 @"3ds",
54
53 ps3,55 ps3,
54 ps4,56 ps4,
55 ps5,57 ps5,
...@@ -194,6 +196,8 @@ pub const Os = struct {...@@ -194,6 +196,8 @@ pub const Os = struct {
194196
195 .uefi,197 .uefi,
196198
199 .@"3ds",
200
197 .wasi,201 .wasi,
198202
199 .amdhsa,203 .amdhsa,
...@@ -603,7 +607,12 @@ pub const Os = struct {...@@ -603,7 +607,12 @@ pub const Os = struct {
603 .max = .{ .major = 2, .minor = 11, .patch = 0 },607 .max = .{ .major = 2, .minor = 11, .patch = 0 },
604 },608 },
605 },609 },
606610 .@"3ds" => .{
611 .semver = .{
612 .min = .{ .major = 2, .minor = 27, .patch = 0 }, // 1.0.0-0
613 .max = .{ .major = 2, .minor = 58, .patch = 0 }, // 11.17.0-50
614 },
615 },
607 .wasi => .{616 .wasi => .{
608 .semver = .{617 .semver = .{
609 .min = .{ .major = 0, .minor = 1, .patch = 0 },618 .min = .{ .major = 0, .minor = 1, .patch = 0 },
...@@ -861,6 +870,7 @@ pub const Abi = enum {...@@ -861,6 +870,7 @@ pub const Abi = enum {
861 .tvos, .visionos, .watchos => if (arch == .x86_64) .simulator else .none,870 .tvos, .visionos, .watchos => if (arch == .x86_64) .simulator else .none,
862 .windows => .gnu,871 .windows => .gnu,
863 .uefi => .msvc,872 .uefi => .msvc,
873 .@"3ds" => .eabihf,
864 .wasi, .emscripten => .musl,874 .wasi, .emscripten => .musl,
865875
866 .contiki,876 .contiki,
...@@ -1828,7 +1838,10 @@ pub const Cpu = struct {...@@ -1828,7 +1838,10 @@ pub const Cpu = struct {
1828 pub fn baseline(arch: Arch, os: Os) *const Model {1838 pub fn baseline(arch: Arch, os: Os) *const Model {
1829 return switch (arch) {1839 return switch (arch) {
1830 .amdgcn => &amdgcn.cpu.gfx906,1840 .amdgcn => &amdgcn.cpu.gfx906,
1831 .arm, .armeb, .thumb, .thumbeb => &arm.cpu.baseline,1841 .arm, .armeb, .thumb, .thumbeb => switch (os.tag) {
1842 .@"3ds" => &arm.cpu.mpcore,
1843 else => &arm.cpu.baseline,
1844 },
1832 .aarch64 => switch (os.tag) {1845 .aarch64 => switch (os.tag) {
1833 .driverkit, .macos => &aarch64.cpu.apple_m1,1846 .driverkit, .macos => &aarch64.cpu.apple_m1,
1834 .ios, .tvos => &aarch64.cpu.apple_a7,1847 .ios, .tvos => &aarch64.cpu.apple_a7,
...@@ -2055,6 +2068,7 @@ pub fn requiresLibC(target: *const Target) bool {...@@ -2055,6 +2068,7 @@ pub fn requiresLibC(target: *const Target) bool {
2055 .vulkan,2068 .vulkan,
2056 .plan9,2069 .plan9,
2057 .other,2070 .other,
2071 .@"3ds",
2058 => false,2072 => false,
2059 };2073 };
2060}2074}
...@@ -2153,6 +2167,8 @@ pub const DynamicLinker = struct {...@@ -2153,6 +2167,8 @@ pub const DynamicLinker = struct {
2153 .uefi,2167 .uefi,
2154 .windows,2168 .windows,
21552169
2170 .@"3ds",
2171
2156 .emscripten,2172 .emscripten,
2157 .wasi,2173 .wasi,
21582174
...@@ -2537,6 +2553,8 @@ pub const DynamicLinker = struct {...@@ -2537,6 +2553,8 @@ pub const DynamicLinker = struct {
2537 .uefi,2553 .uefi,
2538 .windows,2554 .windows,
25392555
2556 .@"3ds",
2557
2540 .emscripten,2558 .emscripten,
2541 .wasi,2559 .wasi,
25422560
...@@ -3044,6 +3062,13 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {...@@ -3044,6 +3062,13 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
3044 .longdouble => return 128,3062 .longdouble => return 128,
3045 },3063 },
30463064
3065 .@"3ds" => switch (c_type) {
3066 .char => return 8,
3067 .short, .ushort => return 16,
3068 .int, .uint, .float, .long, .ulong => return 32,
3069 .longlong, .ulonglong, .double, .longdouble => return 64,
3070 },
3071
3047 .ps4, .ps5 => switch (c_type) {3072 .ps4, .ps5 => switch (c_type) {
3048 .char => return 8,3073 .char => return 8,
3049 .short, .ushort => return 16,3074 .short, .ushort => return 16,
src/Compilation.zig+5
...@@ -6924,6 +6924,11 @@ pub fn addCCArgs(...@@ -6924,6 +6924,11 @@ pub fn addCCArgs(
6924 },6924 },
6925 }6925 }
69266926
6927 switch (target.os.tag) {
6928 .@"3ds" => try argv.append("-D__3DS__"),
6929 else => {},
6930 }
6931
6927 if (comp.config.link_libc) {6932 if (comp.config.link_libc) {
6928 if (target.isGnuLibC()) {6933 if (target.isGnuLibC()) {
6929 const target_version = target.os.versionRange().gnuLibCVersion().?;6934 const target_version = target.os.versionRange().gnuLibCVersion().?;
src/codegen/llvm.zig+1
...@@ -228,6 +228,7 @@ pub fn targetTriple(allocator: Allocator, target: *const std.Target) ![]const u8...@@ -228,6 +228,7 @@ pub fn targetTriple(allocator: Allocator, target: *const std.Target) ![]const u8
228 .serenity => "serenity",228 .serenity => "serenity",
229 .vulkan => "vulkan",229 .vulkan => "vulkan",
230230
231 .@"3ds",
231 .opengl,232 .opengl,
232 .plan9,233 .plan9,
233 .contiki,234 .contiki,
test/llvm_targets.zig+2
...@@ -48,6 +48,7 @@ const targets = [_]std.Target.Query{...@@ -48,6 +48,7 @@ const targets = [_]std.Target.Query{
48 .{ .cpu_arch = .arc, .os_tag = .linux, .abi = .gnu },48 .{ .cpu_arch = .arc, .os_tag = .linux, .abi = .gnu },
49 .{ .cpu_arch = .arc, .os_tag = .linux, .abi = .none },49 .{ .cpu_arch = .arc, .os_tag = .linux, .abi = .none },
5050
51 .{ .cpu_arch = .arm, .os_tag = .@"3ds", .abi = .eabihf },
51 .{ .cpu_arch = .arm, .os_tag = .freebsd, .abi = .eabihf },52 .{ .cpu_arch = .arm, .os_tag = .freebsd, .abi = .eabihf },
52 .{ .cpu_arch = .arm, .os_tag = .freestanding, .abi = .eabi },53 .{ .cpu_arch = .arm, .os_tag = .freestanding, .abi = .eabi },
53 .{ .cpu_arch = .arm, .os_tag = .freestanding, .abi = .eabihf },54 .{ .cpu_arch = .arm, .os_tag = .freestanding, .abi = .eabihf },
...@@ -250,6 +251,7 @@ const targets = [_]std.Target.Query{...@@ -250,6 +251,7 @@ const targets = [_]std.Target.Query{
250 .{ .cpu_arch = .sparc64, .os_tag = .rtems, .abi = .none },251 .{ .cpu_arch = .sparc64, .os_tag = .rtems, .abi = .none },
251 .{ .cpu_arch = .sparc64, .os_tag = .solaris, .abi = .none },252 .{ .cpu_arch = .sparc64, .os_tag = .solaris, .abi = .none },
252253
254 .{ .cpu_arch = .thumb, .os_tag = .@"3ds", .abi = .eabihf },
253 .{ .cpu_arch = .thumb, .os_tag = .freestanding, .abi = .eabi },255 .{ .cpu_arch = .thumb, .os_tag = .freestanding, .abi = .eabi },
254 .{ .cpu_arch = .thumb, .os_tag = .freestanding, .abi = .eabihf },256 .{ .cpu_arch = .thumb, .os_tag = .freestanding, .abi = .eabihf },
255 .{ .cpu_arch = .thumb, .os_tag = .linux, .abi = .eabi },257 .{ .cpu_arch = .thumb, .os_tag = .linux, .abi = .eabi },