authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-10-03 11:04:41-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-10-03 11:04:41-07:00
log77338947617f5aed0bfe50ca4975d284736a5d90
treec16c472fe582471051c9d17dbd757704985aed46
parent47f08605bd3ce01fb38e0d41408f4e09268fce09
parentdd026588d081c639f59696bb1e2f0998f0f10f11
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #17341 from rzezeski/illumos-updates

Illumos/Solaris updates

26 files changed, 132 insertions(+), 53 deletions(-)

CMakeLists.txt+22-8
......@@ -1,4 +1,5 @@
11cmake_minimum_required(VERSION 3.5)
2include(CheckSymbolExists)
23
34if(NOT CMAKE_BUILD_TYPE)
45 set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
......@@ -706,9 +707,25 @@ target_link_libraries(zigcpp LINK_PUBLIC
706707 ${CMAKE_THREAD_LIBS_INIT}
707708)
708709
710string(TOLOWER "${CMAKE_HOST_SYSTEM_NAME}" ZIG_HOST_TARGET_OS)
711if(ZIG_HOST_TARGET_OS STREQUAL "darwin")
712 set(ZIG_HOST_TARGET_OS "macos")
713elseif(ZIG_HOST_TARGET_OS STREQUAL "sunos")
714 check_symbol_exists(__illumos__ "" ZIG_HOST_TARGET_HAS_ILLUMOS_MACRO)
715 if (ZIG_HOST_TARGET_HAS_ILLUMOS_MACRO)
716 set(ZIG_HOST_TARGET_OS "illumos")
717 else()
718 set(ZIG_HOST_TARGET_OS "solaris")
719 endif()
720endif()
721
709722string(TOLOWER "${CMAKE_HOST_SYSTEM_PROCESSOR}" ZIG_HOST_TARGET_ARCH)
710723if(ZIG_HOST_TARGET_ARCH MATCHES "^i[3-9]86$")
711 set(ZIG_HOST_TARGET_ARCH "x86")
724 if (ZIG_HOST_TARGET_OS MATCHES "(solaris|illumos)")
725 set(ZIG_HOST_TARGET_ARCH "x86_64")
726 else()
727 set(ZIG_HOST_TARGET_ARCH "x86")
728 endif()
712729elseif(ZIG_HOST_TARGET_ARCH STREQUAL "amd64")
713730 set(ZIG_HOST_TARGET_ARCH "x86_64")
714731elseif(ZIG_HOST_TARGET_ARCH STREQUAL "arm64")
......@@ -720,7 +737,6 @@ elseif(ZIG_HOST_TARGET_ARCH STREQUAL "armv7b")
720737endif()
721738string(REGEX REPLACE "^((arm|thumb)(hf?)?)el$" "\\1" ZIG_HOST_TARGET_ARCH "${ZIG_HOST_TARGET_ARCH}")
722739if(ZIG_HOST_TARGET_ARCH MATCHES "^arm(hf?)?(eb)?$")
723 include(CheckSymbolExists)
724740 check_symbol_exists(__thumb__ "" ZIG_HOST_TARGET_DEFAULTS_TO_THUMB)
725741 if(ZIG_HOST_TARGET_DEFAULTS_TO_THUMB)
726742 string(REGEX REPLACE "^arm" "thumb" ZIG_HOST_TARGET_ARCH "${ZIG_HOST_TARGET_ARCH}")
......@@ -728,11 +744,6 @@ if(ZIG_HOST_TARGET_ARCH MATCHES "^arm(hf?)?(eb)?$")
728744endif()
729745string(REGEX REPLACE "^ppc((64)?(le)?)$" "powerpc\\1" ZIG_HOST_TARGET_ARCH "${ZIG_HOST_TARGET_ARCH}")
730746
731string(TOLOWER "${CMAKE_HOST_SYSTEM_NAME}" ZIG_HOST_TARGET_OS)
732if(ZIG_HOST_TARGET_OS STREQUAL "darwin")
733 set(ZIG_HOST_TARGET_OS "macos")
734endif()
735
736747if(MSVC)
737748 set(ZIG_HOST_TARGET_ABI "-msvc")
738749elseif(MINGW)
......@@ -759,6 +770,9 @@ else()
759770 set(ZIG2_LINK_FLAGS "-Wl,-stack_size,0x10000000")
760771 elseif(MINGW)
761772 set(ZIG2_LINK_FLAGS "-Wl,--stack,0x10000000")
773 # Solaris/illumos ld(1) does not provide a --stack-size option.
774 elseif(CMAKE_HOST_SOLARIS)
775 unset(ZIG2_LINK_FLAGS)
762776 else()
763777 set(ZIG2_LINK_FLAGS "-Wl,-z,stack-size=0x10000000")
764778 endif()
......@@ -832,7 +846,7 @@ add_custom_command(
832846add_executable(zig2 ${ZIG2_C_SOURCE} ${ZIG_COMPILER_RT_C_SOURCE})
833847set_target_properties(zig2 PROPERTIES
834848 COMPILE_FLAGS ${ZIG2_COMPILE_FLAGS}
835 LINK_FLAGS ${ZIG2_LINK_FLAGS}
849 LINK_FLAGS "${ZIG2_LINK_FLAGS}"
836850)
837851target_include_directories(zig2 PUBLIC "${CMAKE_SOURCE_DIR}/stage1")
838852target_link_libraries(zig2 LINK_PUBLIC zigcpp)
build.zig+4
......@@ -673,6 +673,10 @@ fn addCmakeCfgOptionsToExe(
673673 try addCxxKnownPath(b, cfg, exe, b.fmt("libstdc++.{s}", .{lib_suffix}), null, need_cpp_includes);
674674 }
675675 },
676 .solaris, .illumos => {
677 try addCxxKnownPath(b, cfg, exe, b.fmt("libstdc++.{s}", .{lib_suffix}), null, need_cpp_includes);
678 try addCxxKnownPath(b, cfg, exe, b.fmt("libgcc_eh.{s}", .{lib_suffix}), null, need_cpp_includes);
679 },
676680 else => {},
677681 }
678682 }
lib/std/Thread.zig+4-4
......@@ -43,7 +43,7 @@ pub const max_name_len = switch (target.os.tag) {
4343 .freebsd => 15,
4444 .openbsd => 23,
4545 .dragonfly => 1023,
46 .solaris => 31,
46 .solaris, .illumos => 31,
4747 else => 0,
4848};
4949
......@@ -123,7 +123,7 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void {
123123 else => |e| return os.unexpectedErrno(e),
124124 }
125125 },
126 .netbsd, .solaris => if (use_pthreads) {
126 .netbsd, .solaris, .illumos => if (use_pthreads) {
127127 const err = std.c.pthread_setname_np(self.getHandle(), name_with_terminator.ptr, null);
128128 switch (err) {
129129 .SUCCESS => return,
......@@ -229,7 +229,7 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co
229229 else => |e| return os.unexpectedErrno(e),
230230 }
231231 },
232 .netbsd, .solaris => if (use_pthreads) {
232 .netbsd, .solaris, .illumos => if (use_pthreads) {
233233 const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1);
234234 switch (err) {
235235 .SUCCESS => return std.mem.sliceTo(buffer, 0),
......@@ -636,7 +636,7 @@ const PosixThreadImpl = struct {
636636 };
637637 return @as(usize, @intCast(count));
638638 },
639 .solaris => {
639 .solaris, .illumos => {
640640 // The "proper" way to get the cpu count would be to query
641641 // /dev/kstat via ioctls, and traverse a linked list for each
642642 // cpu.
lib/std/c.zig+1-1
......@@ -49,7 +49,7 @@ pub usingnamespace switch (builtin.os.tag) {
4949 .openbsd => @import("c/openbsd.zig"),
5050 .haiku => @import("c/haiku.zig"),
5151 .hermit => @import("c/hermit.zig"),
52 .solaris => @import("c/solaris.zig"),
52 .solaris, .illumos => @import("c/solaris.zig"),
5353 .fuchsia => @import("c/fuchsia.zig"),
5454 .minix => @import("c/minix.zig"),
5555 .emscripten => @import("c/emscripten.zig"),
lib/std/c/solaris.zig+15
......@@ -498,6 +498,7 @@ pub const NI = struct {
498498 pub const MAXSERV = 32;
499499};
500500
501pub const NAME_MAX = 255;
501502pub const PATH_MAX = 1024;
502503pub const IOV_MAX = 1024;
503504
......@@ -1069,7 +1070,21 @@ pub const mcontext_t = extern struct {
10691070};
10701071
10711072pub const REG = struct {
1073 pub const R15 = 0;
1074 pub const R14 = 1;
1075 pub const R13 = 2;
1076 pub const R12 = 3;
1077 pub const R11 = 4;
1078 pub const R10 = 5;
1079 pub const R9 = 6;
1080 pub const R8 = 7;
1081 pub const RDI = 8;
1082 pub const RSI = 9;
10721083 pub const RBP = 10;
1084 pub const RBX = 11;
1085 pub const RDX = 12;
1086 pub const RCX = 13;
1087 pub const RAX = 14;
10731088 pub const RIP = 17;
10741089 pub const RSP = 20;
10751090};
lib/std/crypto/Certificate/Bundle.zig+10
......@@ -64,6 +64,7 @@ pub fn rescan(cb: *Bundle, gpa: Allocator) RescanError!void {
6464 .netbsd => return rescanBSD(cb, gpa, "/etc/openssl/certs/ca-certificates.crt"),
6565 .dragonfly => return rescanBSD(cb, gpa, "/usr/local/etc/ssl/cert.pem"),
6666 .windows => return rescanWindows(cb, gpa),
67 .solaris, .illumos => return rescanSolaris(cb, gpa, "/etc/ssl/cacert.pem"),
6768 else => {},
6869 }
6970}
......@@ -151,6 +152,15 @@ fn rescanWindows(cb: *Bundle, gpa: Allocator) RescanWindowsError!void {
151152 cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len);
152153}
153154
155const RescanSolarisError = AddCertsFromFilePathError;
156
157fn rescanSolaris(cb: *Bundle, gpa: Allocator, cert_file_path: []const u8) RescanSolarisError!void {
158 cb.bytes.clearRetainingCapacity();
159 cb.map.clearRetainingCapacity();
160 try addCertsFromFilePathAbsolute(cb, gpa, cert_file_path);
161 cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len);
162}
163
154164pub const AddCertsFromDirPathError = fs.File.OpenError || AddCertsFromDirError;
155165
156166pub fn addCertsFromDirPath(
lib/std/crypto/tlcsprng.zig+1
......@@ -25,6 +25,7 @@ const os_has_fork = switch (builtin.os.tag) {
2525 .netbsd,
2626 .openbsd,
2727 .solaris,
28 .illumos,
2829 .tvos,
2930 .watchos,
3031 .haiku,
lib/std/debug.zig+4-2
......@@ -990,6 +990,7 @@ pub fn openSelfDebugInfo(allocator: mem.Allocator) OpenSelfDebugInfoError!DebugI
990990 .openbsd,
991991 .macos,
992992 .solaris,
993 .illumos,
993994 .windows,
994995 => return try DebugInfo.init(allocator),
995996 else => return error.UnsupportedOperatingSystem,
......@@ -2228,7 +2229,7 @@ pub const ModuleDebugInfo = switch (native_os) {
22282229 };
22292230 }
22302231 },
2231 .linux, .netbsd, .freebsd, .dragonfly, .openbsd, .haiku, .solaris => struct {
2232 .linux, .netbsd, .freebsd, .dragonfly, .openbsd, .haiku, .solaris, .illumos => struct {
22322233 base_address: usize,
22332234 dwarf: DW.DwarfInfo,
22342235 mapped_memory: []align(mem.page_size) const u8,
......@@ -2313,6 +2314,7 @@ pub const have_segfault_handling_support = switch (native_os) {
23132314 .macos,
23142315 .netbsd,
23152316 .solaris,
2317 .illumos,
23162318 .windows,
23172319 => true,
23182320
......@@ -2386,7 +2388,7 @@ fn handleSegfaultPosix(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const any
23862388 .freebsd, .macos => @intFromPtr(info.addr),
23872389 .netbsd => @intFromPtr(info.info.reason.fault.addr),
23882390 .openbsd => @intFromPtr(info.data.fault.addr),
2389 .solaris => @intFromPtr(info.reason.fault.addr),
2391 .solaris, .illumos => @intFromPtr(info.reason.fault.addr),
23902392 else => unreachable,
23912393 };
23922394
lib/std/dwarf/abi.zig+8-5
......@@ -6,11 +6,11 @@ const mem = std.mem;
66pub fn supportsUnwinding(target: std.Target) bool {
77 return switch (target.cpu.arch) {
88 .x86 => switch (target.os.tag) {
9 .linux, .netbsd, .solaris => true,
9 .linux, .netbsd, .solaris, .illumos => true,
1010 else => false,
1111 },
1212 .x86_64 => switch (target.os.tag) {
13 .linux, .netbsd, .freebsd, .openbsd, .macos, .ios, .solaris => true,
13 .linux, .netbsd, .freebsd, .openbsd, .macos, .ios, .solaris, .illumos => true,
1414 else => false,
1515 },
1616 .arm => switch (target.os.tag) {
......@@ -194,7 +194,7 @@ pub fn regBytes(
194194 const ucontext_ptr = thread_context_ptr;
195195 return switch (builtin.cpu.arch) {
196196 .x86 => switch (builtin.os.tag) {
197 .linux, .netbsd, .solaris => switch (reg_number) {
197 .linux, .netbsd, .solaris, .illumos => switch (reg_number) {
198198 0 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.EAX]),
199199 1 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.ECX]),
200200 2 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.EDX]),
......@@ -229,7 +229,7 @@ pub fn regBytes(
229229 else => error.UnimplementedOs,
230230 },
231231 .x86_64 => switch (builtin.os.tag) {
232 .linux, .solaris => switch (reg_number) {
232 .linux, .solaris, .illumos => switch (reg_number) {
233233 0 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.RAX]),
234234 1 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.RDX]),
235235 2 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.RCX]),
......@@ -247,7 +247,10 @@ pub fn regBytes(
247247 14 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.R14]),
248248 15 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.R15]),
249249 16 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.RIP]),
250 17...32 => |i| mem.asBytes(&ucontext_ptr.mcontext.fpregs.xmm[i - 17]),
250 17...32 => |i| if (builtin.os.tag.isSolarish())
251 mem.asBytes(&ucontext_ptr.mcontext.fpregs.chip_state.xmm[i - 17])
252 else
253 mem.asBytes(&ucontext_ptr.mcontext.fpregs.xmm[i - 17]),
251254 else => error.InvalidRegister,
252255 },
253256 .freebsd => switch (reg_number) {
lib/std/dynamic_library.zig+2-2
......@@ -10,7 +10,7 @@ const system = std.os.system;
1010pub const DynLib = switch (builtin.os.tag) {
1111 .linux => if (builtin.link_libc) DlDynlib else ElfDynLib,
1212 .windows => WindowsDynLib,
13 .macos, .tvos, .watchos, .ios, .freebsd, .netbsd, .openbsd, .dragonfly, .solaris => DlDynlib,
13 .macos, .tvos, .watchos, .ios, .freebsd, .netbsd, .openbsd, .dragonfly, .solaris, .illumos => DlDynlib,
1414 else => void,
1515};
1616
......@@ -388,7 +388,7 @@ pub const DlDynlib = struct {
388388
389389test "dynamic_library" {
390390 const libname = switch (builtin.os.tag) {
391 .linux, .freebsd, .openbsd => "invalid_so.so",
391 .linux, .freebsd, .openbsd, .solaris, .illumos => "invalid_so.so",
392392 .windows => "invalid_dll.dll",
393393 .macos, .tvos, .watchos, .ios => "invalid_dylib.dylib",
394394 else => return error.SkipZigTest,
lib/std/fs.zig+7-7
......@@ -39,7 +39,7 @@ pub const Watch = @import("fs/watch.zig").Watch;
3939/// fit into a UTF-8 encoded array of this length.
4040/// The byte count includes room for a null sentinel byte.
4141pub const MAX_PATH_BYTES = switch (builtin.os.tag) {
42 .linux, .macos, .ios, .freebsd, .openbsd, .netbsd, .dragonfly, .haiku, .solaris, .plan9 => os.PATH_MAX,
42 .linux, .macos, .ios, .freebsd, .openbsd, .netbsd, .dragonfly, .haiku, .solaris, .illumos, .plan9 => os.PATH_MAX,
4343 // Each UTF-16LE character may be expanded to 3 UTF-8 bytes.
4444 // If it would require 4 UTF-8 bytes, then there would be a surrogate
4545 // pair in the UTF-16LE, and we (over)account 3 bytes for it that way.
......@@ -59,10 +59,9 @@ pub const MAX_PATH_BYTES = switch (builtin.os.tag) {
5959/// (depending on the platform) this assumption may not hold for every configuration.
6060/// The byte count does not include a null sentinel byte.
6161pub const MAX_NAME_BYTES = switch (builtin.os.tag) {
62 .linux, .macos, .ios, .freebsd, .openbsd, .netbsd, .dragonfly => os.NAME_MAX,
62 .linux, .macos, .ios, .freebsd, .openbsd, .netbsd, .dragonfly, .solaris, .illumos => os.NAME_MAX,
6363 // Haiku's NAME_MAX includes the null terminator, so subtract one.
6464 .haiku => os.NAME_MAX - 1,
65 .solaris => os.system.MAXNAMLEN,
6665 // Each UTF-16LE character may be expanded to 3 UTF-8 bytes.
6766 // If it would require 4 UTF-8 bytes, then there would be a surrogate
6867 // pair in the UTF-16LE, and we (over)account 3 bytes for it that way.
......@@ -326,7 +325,7 @@ pub const IterableDir = struct {
326325 const IteratorError = error{ AccessDenied, SystemResources } || os.UnexpectedError;
327326
328327 pub const Iterator = switch (builtin.os.tag) {
329 .macos, .ios, .freebsd, .netbsd, .dragonfly, .openbsd, .solaris => struct {
328 .macos, .ios, .freebsd, .netbsd, .dragonfly, .openbsd, .solaris, .illumos => struct {
330329 dir: Dir,
331330 seek: i64,
332331 buf: [1024]u8, // TODO align(@alignOf(os.system.dirent)),
......@@ -344,7 +343,7 @@ pub const IterableDir = struct {
344343 switch (builtin.os.tag) {
345344 .macos, .ios => return self.nextDarwin(),
346345 .freebsd, .netbsd, .dragonfly, .openbsd => return self.nextBsd(),
347 .solaris => return self.nextSolaris(),
346 .solaris, .illumos => return self.nextSolaris(),
348347 else => @compileError("unimplemented"),
349348 }
350349 }
......@@ -898,6 +897,7 @@ pub const IterableDir = struct {
898897 .dragonfly,
899898 .openbsd,
900899 .solaris,
900 .illumos,
901901 => return Iterator{
902902 .dir = self.dir,
903903 .seek = 0,
......@@ -1841,7 +1841,7 @@ pub const Dir = struct {
18411841 error.AccessDenied => |e| switch (builtin.os.tag) {
18421842 // non-Linux POSIX systems return EPERM when trying to delete a directory, so
18431843 // we need to handle that case specifically and translate the error
1844 .macos, .ios, .freebsd, .netbsd, .dragonfly, .openbsd, .solaris => {
1844 .macos, .ios, .freebsd, .netbsd, .dragonfly, .openbsd, .solaris, .illumos => {
18451845 // Don't follow symlinks to match unlinkat (which acts on symlinks rather than follows them)
18461846 const fstat = os.fstatatZ(self.fd, sub_path_c, os.AT.SYMLINK_NOFOLLOW) catch return e;
18471847 const is_dir = fstat.mode & os.S.IFMT == os.S.IFDIR;
......@@ -3007,7 +3007,7 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {
30073007 }
30083008 switch (builtin.os.tag) {
30093009 .linux => return os.readlinkZ("/proc/self/exe", out_buffer),
3010 .solaris => return os.readlinkZ("/proc/self/path/a.out", out_buffer),
3010 .solaris, .illumos => return os.readlinkZ("/proc/self/path/a.out", out_buffer),
30113011 .freebsd, .dragonfly => {
30123012 var mib = [4]c_int{ os.CTL.KERN, os.KERN.PROC, os.KERN.PROC_PATHNAME, -1 };
30133013 var out_len: usize = out_buffer.len;
lib/std/fs/file.zig+2-2
......@@ -359,7 +359,7 @@ pub const File = struct {
359359 os.S.IFSOCK => break :blk .unix_domain_socket,
360360 else => {},
361361 }
362 if (builtin.os.tag == .solaris) switch (m) {
362 if (builtin.os.tag.isSolarish()) switch (m) {
363363 os.S.IFDOOR => break :blk .door,
364364 os.S.IFPORT => break :blk .event_port,
365365 else => {},
......@@ -685,7 +685,7 @@ pub const File = struct {
685685 else => {},
686686 }
687687
688 if (builtin.os.tag == .solaris) switch (m) {
688 if (builtin.os.tag.isSolarish()) switch (m) {
689689 os.S.IFDOOR => return .door,
690690 os.S.IFPORT => return .event_port,
691691 else => {},
lib/std/fs/get_app_data_dir.zig+1-1
......@@ -44,7 +44,7 @@ pub fn getAppDataDir(allocator: mem.Allocator, appname: []const u8) GetAppDataDi
4444 };
4545 return fs.path.join(allocator, &[_][]const u8{ home_dir, "Library", "Application Support", appname });
4646 },
47 .linux, .freebsd, .netbsd, .dragonfly, .openbsd, .solaris => {
47 .linux, .freebsd, .netbsd, .dragonfly, .openbsd, .solaris, .illumos => {
4848 if (os.getenv("XDG_DATA_HOME")) |xdg| {
4949 return fs.path.join(allocator, &[_][]const u8{ xdg, appname });
5050 }
lib/std/os.zig+4-2
......@@ -33,6 +33,7 @@ pub const haiku = std.c;
3333pub const netbsd = std.c;
3434pub const openbsd = std.c;
3535pub const solaris = std.c;
36pub const illumos = std.c;
3637pub const linux = @import("os/linux.zig");
3738pub const plan9 = @import("os/plan9.zig");
3839pub const uefi = @import("os/uefi.zig");
......@@ -1821,7 +1822,7 @@ pub fn execveZ(
18211822 .BADARCH => return error.InvalidExe,
18221823 else => return unexpectedErrno(err),
18231824 },
1824 .linux, .solaris => switch (err) {
1825 .linux => switch (err) {
18251826 .LIBBAD => return error.InvalidExe,
18261827 else => return unexpectedErrno(err),
18271828 },
......@@ -5226,6 +5227,7 @@ pub fn isGetFdPathSupportedOnTarget(os: std.Target.Os) bool {
52265227 .macos, .ios, .watchos, .tvos,
52275228 .linux,
52285229 .solaris,
5230 .illumos,
52295231 .freebsd,
52305232 => true,
52315233 // zig fmt: on
......@@ -5280,7 +5282,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {
52805282 };
52815283 return target;
52825284 },
5283 .solaris => {
5285 .solaris, .illumos => {
52845286 var procfs_buf: ["/proc/self/path/-2147483648\x00".len]u8 = undefined;
52855287 const proc_path = std.fmt.bufPrintZ(procfs_buf[0..], "/proc/self/path/{d}", .{fd}) catch unreachable;
52865288
lib/std/os/test.zig+5-5
......@@ -234,7 +234,7 @@ test "link with relative paths" {
234234 if (native_os == .wasi and builtin.link_libc) return error.SkipZigTest;
235235
236236 switch (native_os) {
237 .wasi, .linux, .solaris => {},
237 .wasi, .linux, .solaris, .illumos => {},
238238 else => return error.SkipZigTest,
239239 }
240240 if (true) {
......@@ -277,7 +277,7 @@ test "linkat with different directories" {
277277 if (native_os == .wasi and builtin.link_libc) return error.SkipZigTest;
278278
279279 switch (native_os) {
280 .wasi, .linux, .solaris => {},
280 .wasi, .linux, .solaris, .illumos => {},
281281 else => return error.SkipZigTest,
282282 }
283283 if (true) {
......@@ -706,7 +706,7 @@ test "fcntl" {
706706
707707test "signalfd" {
708708 switch (native_os) {
709 .linux, .solaris => {},
709 .linux, .solaris, .illumos => {},
710710 else => return error.SkipZigTest,
711711 }
712712 _ = &os.signalfd;
......@@ -732,7 +732,7 @@ test "sync" {
732732
733733test "fsync" {
734734 switch (native_os) {
735 .linux, .windows, .solaris => {},
735 .linux, .windows, .solaris, .illumos => {},
736736 else => return error.SkipZigTest,
737737 }
738738
......@@ -870,7 +870,7 @@ test "sigaction" {
870870
871871test "dup & dup2" {
872872 switch (native_os) {
873 .linux, .solaris => {},
873 .linux, .solaris, .illumos => {},
874874 else => return error.SkipZigTest,
875875 }
876876
lib/std/process.zig+12-1
......@@ -959,7 +959,18 @@ pub const UserInfo = struct {
959959/// POSIX function which gets a uid from username.
960960pub fn getUserInfo(name: []const u8) !UserInfo {
961961 return switch (builtin.os.tag) {
962 .linux, .macos, .watchos, .tvos, .ios, .freebsd, .netbsd, .openbsd, .haiku, .solaris => posixGetUserInfo(name),
962 .linux,
963 .macos,
964 .watchos,
965 .tvos,
966 .ios,
967 .freebsd,
968 .netbsd,
969 .openbsd,
970 .haiku,
971 .solaris,
972 .illumos,
973 => posixGetUserInfo(name),
963974 else => @compileError("Unsupported OS"),
964975 };
965976}
lib/std/target.zig+11-2
......@@ -58,6 +58,7 @@ pub const Target = struct {
5858 glsl450,
5959 vulkan,
6060 plan9,
61 illumos,
6162 other,
6263
6364 pub inline fn isDarwin(tag: Tag) bool {
......@@ -74,6 +75,10 @@ pub const Target = struct {
7475 };
7576 }
7677
78 pub inline fn isSolarish(tag: Tag) bool {
79 return tag == .solaris or tag == .illumos;
80 }
81
7782 pub fn dynamicLibSuffix(tag: Tag) [:0]const u8 {
7883 if (tag.isDarwin()) {
7984 return ".dylib";
......@@ -266,6 +271,7 @@ pub const Target = struct {
266271 .glsl450, // TODO: GLSL versions
267272 .vulkan,
268273 .plan9,
274 .illumos,
269275 .other,
270276 => return .{ .none = {} },
271277
......@@ -409,6 +415,7 @@ pub const Target = struct {
409415 .openbsd,
410416 .haiku,
411417 .solaris,
418 .illumos,
412419 => true,
413420
414421 .linux,
......@@ -526,7 +533,6 @@ pub const Target = struct {
526533 .cloudabi,
527534 .dragonfly,
528535 .lv2,
529 .solaris,
530536 .zos,
531537 .minix,
532538 .rtems,
......@@ -569,6 +575,8 @@ pub const Target = struct {
569575 .driverkit,
570576 .shadermodel,
571577 .liteos, // TODO: audit this
578 .solaris,
579 .illumos,
572580 => return .none,
573581 }
574582 }
......@@ -1575,7 +1583,7 @@ pub const Target = struct {
15751583 .netbsd => return copy(&result, "/libexec/ld.elf_so"),
15761584 .openbsd => return copy(&result, "/usr/libexec/ld.so"),
15771585 .dragonfly => return copy(&result, "/libexec/ld-elf.so.2"),
1578 .solaris => return copy(&result, "/lib/64/ld.so.1"),
1586 .solaris, .illumos => return copy(&result, "/lib/64/ld.so.1"),
15791587 .linux => switch (self.cpu.arch) {
15801588 .x86,
15811589 .sparc,
......@@ -2115,6 +2123,7 @@ pub const Target = struct {
21152123 .emscripten,
21162124 .plan9,
21172125 .solaris,
2126 .illumos,
21182127 .haiku,
21192128 .ananas,
21202129 .fuchsia,
lib/std/zig/CrossTarget.zig+2
......@@ -111,6 +111,7 @@ fn updateOsVersionRange(self: *CrossTarget, os: Target.Os) void {
111111 .kfreebsd,
112112 .lv2,
113113 .solaris,
114 .illumos,
114115 .zos,
115116 .haiku,
116117 .minix,
......@@ -709,6 +710,7 @@ fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const
709710 .kfreebsd,
710711 .lv2,
711712 .solaris,
713 .illumos,
712714 .zos,
713715 .haiku,
714716 .minix,
lib/std/zig/system/NativePaths.zig+1-1
......@@ -89,7 +89,7 @@ pub fn detect(arena: Allocator, native_info: NativeTargetInfo) !NativePaths {
8989 return self;
9090 }
9191
92 if (builtin.os.tag == .solaris) {
92 if (builtin.os.tag.isSolarish()) {
9393 try self.addLibDir("/usr/lib/64");
9494 try self.addLibDir("/usr/local/lib/64");
9595 try self.addLibDir("/lib/64");
lib/std/zig/system/NativeTargetInfo.zig+4-2
......@@ -51,7 +51,7 @@ pub fn detect(cross_target: CrossTarget) DetectError!NativeTargetInfo {
5151 error.InvalidVersion => {},
5252 }
5353 },
54 .solaris => {
54 .solaris, .illumos => {
5555 const uts = std.os.uname();
5656 const release = mem.sliceTo(&uts.release, 0);
5757 if (std.SemanticVersion.parse(release)) |ver| {
......@@ -257,10 +257,12 @@ fn detectAbiAndDynamicLinker(
257257) DetectError!NativeTargetInfo {
258258 const native_target_has_ld = comptime builtin.target.hasDynamicLinker();
259259 const is_linux = builtin.target.os.tag == .linux;
260 const is_solarish = builtin.target.os.tag.isSolarish();
260261 const have_all_info = cross_target.dynamic_linker.get() != null and
261262 cross_target.abi != null and (!is_linux or cross_target.abi.?.isGnu());
262263 const os_is_non_native = cross_target.os_tag != null;
263 if (!native_target_has_ld or have_all_info or os_is_non_native) {
264 // The Solaris/illumos environment is always the same.
265 if (!native_target_has_ld or have_all_info or os_is_non_native or is_solarish) {
264266 return defaultAbiAndDynamicLinker(cpu, os, cross_target);
265267 }
266268 if (cross_target.abi) |abi| {
src/codegen/llvm.zig+2-2
......@@ -120,7 +120,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
120120 .lv2 => "lv2",
121121 .netbsd => "netbsd",
122122 .openbsd => "openbsd",
123 .solaris => "solaris",
123 .solaris, .illumos => "solaris",
124124 .windows => "windows",
125125 .zos => "zos",
126126 .haiku => "haiku",
......@@ -231,7 +231,7 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {
231231 .macos => .MacOSX,
232232 .netbsd => .NetBSD,
233233 .openbsd => .OpenBSD,
234 .solaris => .Solaris,
234 .solaris, .illumos => .Solaris,
235235 .zos => .ZOS,
236236 .haiku => .Haiku,
237237 .minix => .Minix,
src/crash_report.zig+1-1
......@@ -190,7 +190,7 @@ fn handleSegfaultPosix(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const any
190190 .freebsd, .macos => @intFromPtr(info.addr),
191191 .netbsd => @intFromPtr(info.info.reason.fault.addr),
192192 .openbsd => @intFromPtr(info.data.fault.addr),
193 .solaris => @intFromPtr(info.reason.fault.addr),
193 .solaris, .illumos => @intFromPtr(info.reason.fault.addr),
194194 else => @compileError("TODO implement handleSegfaultPosix for new POSIX OS"),
195195 };
196196
src/libc_installation.zig+5-1
......@@ -213,11 +213,15 @@ pub const LibCInstallation = struct {
213213 try self.findNativeIncludeDirPosix(args);
214214 try self.findNativeCrtBeginDirHaiku(args);
215215 self.crt_dir = try args.allocator.dupeZ(u8, "/system/develop/lib");
216 } else if (builtin.target.os.tag.isSolarish()) {
217 // There is only one libc, and its headers/libraries are always in the same spot.
218 self.include_dir = try args.allocator.dupeZ(u8, "/usr/include");
219 self.sys_include_dir = try args.allocator.dupeZ(u8, "/usr/include");
220 self.crt_dir = try args.allocator.dupeZ(u8, "/usr/lib/64");
216221 } else if (std.process.can_spawn) {
217222 try self.findNativeIncludeDirPosix(args);
218223 switch (builtin.target.os.tag) {
219224 .freebsd, .netbsd, .openbsd, .dragonfly => self.crt_dir = try args.allocator.dupeZ(u8, "/usr/lib"),
220 .solaris => self.crt_dir = try args.allocator.dupeZ(u8, "/usr/lib/64"),
221225 .linux => try self.findNativeCrtDirPosix(args),
222226 else => {},
223227 }
src/libcxx.zig+1-1
......@@ -150,7 +150,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void {
150150
151151 if (std.mem.startsWith(u8, cxx_src, "src/support/win32/") and target.os.tag != .windows)
152152 continue;
153 if (std.mem.startsWith(u8, cxx_src, "src/support/solaris/") and target.os.tag != .solaris)
153 if (std.mem.startsWith(u8, cxx_src, "src/support/solaris/") and !target.os.tag.isSolarish())
154154 continue;
155155 if (std.mem.startsWith(u8, cxx_src, "src/support/ibm/") and target.os.tag != .zos)
156156 continue;
src/link/Elf.zig+1-1
......@@ -3818,7 +3818,7 @@ const CsuObjects = struct {
38183818 .static_pie => result.set( "start_dyn.o", "crti.o", "crtbeginS.o", "crtendS.o", "crtn.o" ),
38193819 // zig fmt: on
38203820 },
3821 .solaris => switch (mode) {
3821 .solaris, .illumos => switch (mode) {
38223822 // zig fmt: off
38233823 .dynamic_lib => result.set( null, "crti.o", null, null, "crtn.o" ),
38243824 .dynamic_exe,
src/target.zig+2-2
......@@ -218,7 +218,7 @@ pub fn hasValgrindSupport(target: std.Target) bool {
218218 .aarch64_32,
219219 .aarch64_be,
220220 => {
221 return target.os.tag == .linux or target.os.tag == .solaris or
221 return target.os.tag == .linux or target.os.tag == .solaris or target.os.tag == .illumos or
222222 (target.os.tag == .windows and target.abi != .msvc);
223223 },
224224 else => return false,
......@@ -493,7 +493,7 @@ pub fn libcFullLinkFlags(target: std.Target) []const []const u8 {
493493 "-lc",
494494 "-lutil",
495495 },
496 .solaris => &[_][]const u8{
496 .solaris, .illumos => &[_][]const u8{
497497 "-lm",
498498 "-lsocket",
499499 "-lnsl",