Skip to content

std.Target: add vita os #24527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions lib/std/Target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub const Os = struct {
ps3,
ps4,
ps5,
vita,

emscripten,
wasi,
Expand Down Expand Up @@ -203,6 +204,8 @@ pub const Os = struct {
.opencl,
.opengl,
.vulkan,

.vita,
=> .semver,

.hurd => .hurd,
Expand Down Expand Up @@ -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 },
},
},
};
}
};
Expand Down Expand Up @@ -725,13 +735,14 @@ pub const Os = struct {
.freestanding,
.fuchsia,
.ps3,
.ps4,
.ps5,
.vita,
.zos,
.rtems,
.cuda,
.nvcl,
.amdhsa,
.ps4,
.ps5,
.mesa3d,
.contiki,
.amdpal,
Expand Down Expand Up @@ -913,6 +924,7 @@ pub const Abi = enum {
.windows => .gnu,
.uefi => .msvc,
.wasi, .emscripten => .musl,
.vita => .eabihf,

.contiki,
.fuchsia,
Expand Down Expand Up @@ -2164,6 +2176,7 @@ pub const DynamicLinker = struct {
.ps3,
.ps4,
.ps5,
.vita,
=> .none,
};
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions src/Compilation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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__");
},
Comment on lines +6353 to +6357
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should rather go near where we define GLIBC_MINOR and others.

else => {},
}

Expand Down
3 changes: 2 additions & 1 deletion src/codegen/llvm.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions test/llvm_targets.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Comment on lines +70 to 72
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.{ .cpu_arch = .arm, .os_tag = .vita, .abi = .eabihf },
// .{ .cpu_arch = .arm, .os_tag = .uefi, .abi = .eabi },
// .{ .cpu_arch = .arm, .os_tag = .uefi, .abi = .eabihf },
// .{ .cpu_arch = .arm, .os_tag = .uefi, .abi = .eabi },
// .{ .cpu_arch = .arm, .os_tag = .uefi, .abi = .eabihf },
.{ .cpu_arch = .arm, .os_tag = .vita, .abi = .eabihf },


Expand Down Expand Up @@ -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 },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

V before W


.{ .cpu_arch = .thumbeb, .os_tag = .freestanding, .abi = .eabi },
.{ .cpu_arch = .thumbeb, .os_tag = .freestanding, .abi = .eabihf },
Expand Down