Merge pull request #25700 from alexrp/solaris-illumos-stuff

Some Solaris/illumos fixes
This commit is contained in:
Alex Rønne Petersen 2025-10-26 00:59:33 +02:00 committed by GitHub
commit 433846100b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 32 additions and 4 deletions

View file

@ -2528,6 +2528,8 @@ pub const _SC = if (builtin.abi.isAndroid()) enum(c_int) {
.solaris, .illumos => enum(c_int) { .solaris, .illumos => enum(c_int) {
PAGESIZE = 11, PAGESIZE = 11,
NPROCESSORS_ONLN = 15, NPROCESSORS_ONLN = 15,
SIGRT_MIN = 40,
SIGRT_MAX = 41,
}, },
// https://github.com/SerenityOS/serenity/blob/1dfc9e2df39dd23f1de92530677c845aae4345f2/Kernel/API/POSIX/unistd.h#L36-L52 // https://github.com/SerenityOS/serenity/blob/1dfc9e2df39dd23f1de92530677c845aae4345f2/Kernel/API/POSIX/unistd.h#L36-L52
.serenity => enum(c_int) { .serenity => enum(c_int) {
@ -5776,6 +5778,20 @@ pub const MSG = switch (native_os) {
pub const FBLOCKING = 0x10000; pub const FBLOCKING = 0x10000;
pub const FNONBLOCKING = 0x20000; pub const FNONBLOCKING = 0x20000;
}, },
.solaris, .illumos => struct {
pub const OOB = 0x0001;
pub const PEEK = 0x0002;
pub const DONTROUTE = 0x0004;
pub const EOR = 0x0008;
pub const CTRUNC = 0x0010;
pub const TRUNC = 0x0020;
pub const WAITALL = 0x0040;
pub const DONTWAIT = 0x0080;
pub const NOTIFICATION = 0x0100;
pub const NOSIGNAL = 0x0200;
pub const CMSG_CLOEXEC = 0x1000;
pub const CMSG_CLOFORK = 0x2000;
},
else => void, else => void,
}; };
pub const SOCK = switch (native_os) { pub const SOCK = switch (native_os) {
@ -10298,7 +10314,7 @@ pub extern "c" fn setrlimit64(resource: rlimit_resource, rlim: *const rlimit) c_
pub const arc4random_buf = switch (native_os) { pub const arc4random_buf = switch (native_os) {
.linux => if (builtin.abi.isAndroid()) private.arc4random_buf else {}, .linux => if (builtin.abi.isAndroid()) private.arc4random_buf else {},
.dragonfly, .netbsd, .freebsd, .solaris, .openbsd, .serenity, .macos, .ios, .tvos, .watchos, .visionos => private.arc4random_buf, .dragonfly, .netbsd, .freebsd, .solaris, .illumos, .openbsd, .serenity, .macos, .ios, .tvos, .watchos, .visionos => private.arc4random_buf,
else => {}, else => {},
}; };
pub const getentropy = switch (native_os) { pub const getentropy = switch (native_os) {
@ -10475,6 +10491,7 @@ pub fn sigrtmin() u8 {
return switch (native_os) { return switch (native_os) {
.freebsd => 65, .freebsd => 65,
.netbsd => 33, .netbsd => 33,
.solaris, .illumos => @truncate(sysconf(@intFromEnum(_SC.SIGRT_MIN))),
else => @truncate(@as(c_uint, @bitCast(private.__libc_current_sigrtmin()))), else => @truncate(@as(c_uint, @bitCast(private.__libc_current_sigrtmin()))),
}; };
} }
@ -10484,6 +10501,7 @@ pub fn sigrtmax() u8 {
return switch (native_os) { return switch (native_os) {
.freebsd => 126, .freebsd => 126,
.netbsd => 63, .netbsd => 63,
.solaris, .illumos => @truncate(sysconf(@intFromEnum(_SC.SIGRT_MAX))),
else => @truncate(@as(c_uint, @bitCast(private.__libc_current_sigrtmax()))), else => @truncate(@as(c_uint, @bitCast(private.__libc_current_sigrtmax()))),
}; };
} }

View file

@ -1963,6 +1963,9 @@ const signal_ucontext_t = switch (native_os) {
_trapno: i64, _trapno: i64,
_err: i64, _err: i64,
rip: u64, rip: u64,
_cs: i64,
_rflags: i64,
rsp: u64,
}, },
}, },
else => unreachable, else => unreachable,
@ -2012,6 +2015,9 @@ const signal_ucontext_t = switch (native_os) {
_trapno: i64, _trapno: i64,
_err: i64, _err: i64,
rip: u64, rip: u64,
_cs: i64,
_rflags: i64,
rsp: u64,
}, },
else => unreachable, else => unreachable,
}, },

View file

@ -257,6 +257,10 @@ pub fn hasNewLinkerSupport(ofmt: std.Target.ObjectFormat, backend: std.builtin.C
pub fn selfHostedBackendIsAsRobustAsLlvm(target: *const std.Target) bool { pub fn selfHostedBackendIsAsRobustAsLlvm(target: *const std.Target) bool {
if (target.cpu.arch.isSpirV()) return true; if (target.cpu.arch.isSpirV()) return true;
if (target.cpu.arch == .x86_64 and target.ptrBitWidth() == 64) { if (target.cpu.arch == .x86_64 and target.ptrBitWidth() == 64) {
if (target.os.tag.isSolarish()) {
// https://github.com/ziglang/zig/issues/25699
return false;
}
if (target.os.tag.isBSD()) { if (target.os.tag.isBSD()) {
// Self-hosted linker needs work: https://github.com/ziglang/zig/issues/24341 // Self-hosted linker needs work: https://github.com/ziglang/zig/issues/24341
return false; return false;

View file

@ -41,7 +41,7 @@ pub fn addCase(self: *ErrorTrace, case: Case) void {
fn shouldTestNonLlvm(target: *const std.Target) bool { fn shouldTestNonLlvm(target: *const std.Target) bool {
return switch (target.cpu.arch) { return switch (target.cpu.arch) {
.x86_64 => switch (target.ofmt) { .x86_64 => switch (target.ofmt) {
.elf => !target.os.tag.isBSD(), .elf => !target.os.tag.isBSD() and !target.os.tag.isSolarish(),
else => false, else => false,
}, },
else => false, else => false,

View file

@ -46,7 +46,7 @@ fn addCaseTarget(
) void { ) void {
const both_backends = switch (target.result.cpu.arch) { const both_backends = switch (target.result.cpu.arch) {
.x86_64 => switch (target.result.ofmt) { .x86_64 => switch (target.result.ofmt) {
.elf => !target.result.os.tag.isBSD(), .elf => !target.result.os.tag.isBSD() and !target.result.os.tag.isSolarish(),
else => false, else => false,
}, },
else => false, else => false,

View file

@ -2493,7 +2493,7 @@ pub fn wouldUseLlvm(use_llvm: ?bool, query: std.Target.Query, optimize_mode: Opt
const cpu_arch = query.cpu_arch orelse builtin.cpu.arch; const cpu_arch = query.cpu_arch orelse builtin.cpu.arch;
const os_tag = query.os_tag orelse builtin.os.tag; const os_tag = query.os_tag orelse builtin.os.tag;
switch (cpu_arch) { switch (cpu_arch) {
.x86_64 => if (os_tag.isBSD() or std.Target.ptrBitWidth_arch_abi(cpu_arch, query.abi orelse .none) != 64) return true, .x86_64 => if (os_tag.isBSD() or os_tag.isSolarish() or std.Target.ptrBitWidth_arch_abi(cpu_arch, query.abi orelse .none) != 64) return true,
.spirv32, .spirv64 => return false, .spirv32, .spirv64 => return false,
else => return true, else => return true,
} }