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 @@...@@ -1,4 +1,5 @@
1cmake_minimum_required(VERSION 3.5)1cmake_minimum_required(VERSION 3.5)
2include(CheckSymbolExists)
23
3if(NOT CMAKE_BUILD_TYPE)4if(NOT CMAKE_BUILD_TYPE)
4 set(CMAKE_BUILD_TYPE "Debug" CACHE STRING5 set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
...@@ -706,9 +707,25 @@ target_link_libraries(zigcpp LINK_PUBLIC...@@ -706,9 +707,25 @@ target_link_libraries(zigcpp LINK_PUBLIC
706 ${CMAKE_THREAD_LIBS_INIT}707 ${CMAKE_THREAD_LIBS_INIT}
707)708)
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
709string(TOLOWER "${CMAKE_HOST_SYSTEM_PROCESSOR}" ZIG_HOST_TARGET_ARCH)722string(TOLOWER "${CMAKE_HOST_SYSTEM_PROCESSOR}" ZIG_HOST_TARGET_ARCH)
710if(ZIG_HOST_TARGET_ARCH MATCHES "^i[3-9]86$")723if(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()
712elseif(ZIG_HOST_TARGET_ARCH STREQUAL "amd64")729elseif(ZIG_HOST_TARGET_ARCH STREQUAL "amd64")
713 set(ZIG_HOST_TARGET_ARCH "x86_64")730 set(ZIG_HOST_TARGET_ARCH "x86_64")
714elseif(ZIG_HOST_TARGET_ARCH STREQUAL "arm64")731elseif(ZIG_HOST_TARGET_ARCH STREQUAL "arm64")
...@@ -720,7 +737,6 @@ elseif(ZIG_HOST_TARGET_ARCH STREQUAL "armv7b")...@@ -720,7 +737,6 @@ elseif(ZIG_HOST_TARGET_ARCH STREQUAL "armv7b")
720endif()737endif()
721string(REGEX REPLACE "^((arm|thumb)(hf?)?)el$" "\\1" ZIG_HOST_TARGET_ARCH "${ZIG_HOST_TARGET_ARCH}")738string(REGEX REPLACE "^((arm|thumb)(hf?)?)el$" "\\1" ZIG_HOST_TARGET_ARCH "${ZIG_HOST_TARGET_ARCH}")
722if(ZIG_HOST_TARGET_ARCH MATCHES "^arm(hf?)?(eb)?$")739if(ZIG_HOST_TARGET_ARCH MATCHES "^arm(hf?)?(eb)?$")
723 include(CheckSymbolExists)
724 check_symbol_exists(__thumb__ "" ZIG_HOST_TARGET_DEFAULTS_TO_THUMB)740 check_symbol_exists(__thumb__ "" ZIG_HOST_TARGET_DEFAULTS_TO_THUMB)
725 if(ZIG_HOST_TARGET_DEFAULTS_TO_THUMB)741 if(ZIG_HOST_TARGET_DEFAULTS_TO_THUMB)
726 string(REGEX REPLACE "^arm" "thumb" ZIG_HOST_TARGET_ARCH "${ZIG_HOST_TARGET_ARCH}")742 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)?$")...@@ -728,11 +744,6 @@ if(ZIG_HOST_TARGET_ARCH MATCHES "^arm(hf?)?(eb)?$")
728endif()744endif()
729string(REGEX REPLACE "^ppc((64)?(le)?)$" "powerpc\\1" ZIG_HOST_TARGET_ARCH "${ZIG_HOST_TARGET_ARCH}")745string(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
736if(MSVC)747if(MSVC)
737 set(ZIG_HOST_TARGET_ABI "-msvc")748 set(ZIG_HOST_TARGET_ABI "-msvc")
738elseif(MINGW)749elseif(MINGW)
...@@ -759,6 +770,9 @@ else()...@@ -759,6 +770,9 @@ else()
759 set(ZIG2_LINK_FLAGS "-Wl,-stack_size,0x10000000")770 set(ZIG2_LINK_FLAGS "-Wl,-stack_size,0x10000000")
760 elseif(MINGW)771 elseif(MINGW)
761 set(ZIG2_LINK_FLAGS "-Wl,--stack,0x10000000")772 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)
762 else()776 else()
763 set(ZIG2_LINK_FLAGS "-Wl,-z,stack-size=0x10000000")777 set(ZIG2_LINK_FLAGS "-Wl,-z,stack-size=0x10000000")
764 endif()778 endif()
...@@ -832,7 +846,7 @@ add_custom_command(...@@ -832,7 +846,7 @@ add_custom_command(
832add_executable(zig2 ${ZIG2_C_SOURCE} ${ZIG_COMPILER_RT_C_SOURCE})846add_executable(zig2 ${ZIG2_C_SOURCE} ${ZIG_COMPILER_RT_C_SOURCE})
833set_target_properties(zig2 PROPERTIES847set_target_properties(zig2 PROPERTIES
834 COMPILE_FLAGS ${ZIG2_COMPILE_FLAGS}848 COMPILE_FLAGS ${ZIG2_COMPILE_FLAGS}
835 LINK_FLAGS ${ZIG2_LINK_FLAGS}849 LINK_FLAGS "${ZIG2_LINK_FLAGS}"
836)850)
837target_include_directories(zig2 PUBLIC "${CMAKE_SOURCE_DIR}/stage1")851target_include_directories(zig2 PUBLIC "${CMAKE_SOURCE_DIR}/stage1")
838target_link_libraries(zig2 LINK_PUBLIC zigcpp)852target_link_libraries(zig2 LINK_PUBLIC zigcpp)
build.zig+4
...@@ -673,6 +673,10 @@ fn addCmakeCfgOptionsToExe(...@@ -673,6 +673,10 @@ fn addCmakeCfgOptionsToExe(
673 try addCxxKnownPath(b, cfg, exe, b.fmt("libstdc++.{s}", .{lib_suffix}), null, need_cpp_includes);673 try addCxxKnownPath(b, cfg, exe, b.fmt("libstdc++.{s}", .{lib_suffix}), null, need_cpp_includes);
674 }674 }
675 },675 },
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 },
676 else => {},680 else => {},
677 }681 }
678 }682 }
lib/std/Thread.zig+4-4
...@@ -43,7 +43,7 @@ pub const max_name_len = switch (target.os.tag) {...@@ -43,7 +43,7 @@ pub const max_name_len = switch (target.os.tag) {
43 .freebsd => 15,43 .freebsd => 15,
44 .openbsd => 23,44 .openbsd => 23,
45 .dragonfly => 1023,45 .dragonfly => 1023,
46 .solaris => 31,46 .solaris, .illumos => 31,
47 else => 0,47 else => 0,
48};48};
4949
...@@ -123,7 +123,7 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void {...@@ -123,7 +123,7 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void {
123 else => |e| return os.unexpectedErrno(e),123 else => |e| return os.unexpectedErrno(e),
124 }124 }
125 },125 },
126 .netbsd, .solaris => if (use_pthreads) {126 .netbsd, .solaris, .illumos => if (use_pthreads) {
127 const err = std.c.pthread_setname_np(self.getHandle(), name_with_terminator.ptr, null);127 const err = std.c.pthread_setname_np(self.getHandle(), name_with_terminator.ptr, null);
128 switch (err) {128 switch (err) {
129 .SUCCESS => return,129 .SUCCESS => return,
...@@ -229,7 +229,7 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co...@@ -229,7 +229,7 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co
229 else => |e| return os.unexpectedErrno(e),229 else => |e| return os.unexpectedErrno(e),
230 }230 }
231 },231 },
232 .netbsd, .solaris => if (use_pthreads) {232 .netbsd, .solaris, .illumos => if (use_pthreads) {
233 const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1);233 const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1);
234 switch (err) {234 switch (err) {
235 .SUCCESS => return std.mem.sliceTo(buffer, 0),235 .SUCCESS => return std.mem.sliceTo(buffer, 0),
...@@ -636,7 +636,7 @@ const PosixThreadImpl = struct {...@@ -636,7 +636,7 @@ const PosixThreadImpl = struct {
636 };636 };
637 return @as(usize, @intCast(count));637 return @as(usize, @intCast(count));
638 },638 },
639 .solaris => {639 .solaris, .illumos => {
640 // The "proper" way to get the cpu count would be to query640 // The "proper" way to get the cpu count would be to query
641 // /dev/kstat via ioctls, and traverse a linked list for each641 // /dev/kstat via ioctls, and traverse a linked list for each
642 // cpu.642 // cpu.
lib/std/c.zig+1-1
...@@ -49,7 +49,7 @@ pub usingnamespace switch (builtin.os.tag) {...@@ -49,7 +49,7 @@ pub usingnamespace switch (builtin.os.tag) {
49 .openbsd => @import("c/openbsd.zig"),49 .openbsd => @import("c/openbsd.zig"),
50 .haiku => @import("c/haiku.zig"),50 .haiku => @import("c/haiku.zig"),
51 .hermit => @import("c/hermit.zig"),51 .hermit => @import("c/hermit.zig"),
52 .solaris => @import("c/solaris.zig"),52 .solaris, .illumos => @import("c/solaris.zig"),
53 .fuchsia => @import("c/fuchsia.zig"),53 .fuchsia => @import("c/fuchsia.zig"),
54 .minix => @import("c/minix.zig"),54 .minix => @import("c/minix.zig"),
55 .emscripten => @import("c/emscripten.zig"),55 .emscripten => @import("c/emscripten.zig"),
lib/std/c/solaris.zig+15
...@@ -498,6 +498,7 @@ pub const NI = struct {...@@ -498,6 +498,7 @@ pub const NI = struct {
498 pub const MAXSERV = 32;498 pub const MAXSERV = 32;
499};499};
500500
501pub const NAME_MAX = 255;
501pub const PATH_MAX = 1024;502pub const PATH_MAX = 1024;
502pub const IOV_MAX = 1024;503pub const IOV_MAX = 1024;
503504
...@@ -1069,7 +1070,21 @@ pub const mcontext_t = extern struct {...@@ -1069,7 +1070,21 @@ pub const mcontext_t = extern struct {
1069};1070};
10701071
1071pub const REG = struct {1072pub 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;
1072 pub const RBP = 10;1083 pub const RBP = 10;
1084 pub const RBX = 11;
1085 pub const RDX = 12;
1086 pub const RCX = 13;
1087 pub const RAX = 14;
1073 pub const RIP = 17;1088 pub const RIP = 17;
1074 pub const RSP = 20;1089 pub const RSP = 20;
1075};1090};
lib/std/crypto/Certificate/Bundle.zig+10
...@@ -64,6 +64,7 @@ pub fn rescan(cb: *Bundle, gpa: Allocator) RescanError!void {...@@ -64,6 +64,7 @@ pub fn rescan(cb: *Bundle, gpa: Allocator) RescanError!void {
64 .netbsd => return rescanBSD(cb, gpa, "/etc/openssl/certs/ca-certificates.crt"),64 .netbsd => return rescanBSD(cb, gpa, "/etc/openssl/certs/ca-certificates.crt"),
65 .dragonfly => return rescanBSD(cb, gpa, "/usr/local/etc/ssl/cert.pem"),65 .dragonfly => return rescanBSD(cb, gpa, "/usr/local/etc/ssl/cert.pem"),
66 .windows => return rescanWindows(cb, gpa),66 .windows => return rescanWindows(cb, gpa),
67 .solaris, .illumos => return rescanSolaris(cb, gpa, "/etc/ssl/cacert.pem"),
67 else => {},68 else => {},
68 }69 }
69}70}
...@@ -151,6 +152,15 @@ fn rescanWindows(cb: *Bundle, gpa: Allocator) RescanWindowsError!void {...@@ -151,6 +152,15 @@ fn rescanWindows(cb: *Bundle, gpa: Allocator) RescanWindowsError!void {
151 cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len);152 cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len);
152}153}
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
154pub const AddCertsFromDirPathError = fs.File.OpenError || AddCertsFromDirError;164pub const AddCertsFromDirPathError = fs.File.OpenError || AddCertsFromDirError;
155165
156pub fn addCertsFromDirPath(166pub fn addCertsFromDirPath(
lib/std/crypto/tlcsprng.zig+1
...@@ -25,6 +25,7 @@ const os_has_fork = switch (builtin.os.tag) {...@@ -25,6 +25,7 @@ const os_has_fork = switch (builtin.os.tag) {
25 .netbsd,25 .netbsd,
26 .openbsd,26 .openbsd,
27 .solaris,27 .solaris,
28 .illumos,
28 .tvos,29 .tvos,
29 .watchos,30 .watchos,
30 .haiku,31 .haiku,
lib/std/debug.zig+4-2
...@@ -990,6 +990,7 @@ pub fn openSelfDebugInfo(allocator: mem.Allocator) OpenSelfDebugInfoError!DebugI...@@ -990,6 +990,7 @@ pub fn openSelfDebugInfo(allocator: mem.Allocator) OpenSelfDebugInfoError!DebugI
990 .openbsd,990 .openbsd,
991 .macos,991 .macos,
992 .solaris,992 .solaris,
993 .illumos,
993 .windows,994 .windows,
994 => return try DebugInfo.init(allocator),995 => return try DebugInfo.init(allocator),
995 else => return error.UnsupportedOperatingSystem,996 else => return error.UnsupportedOperatingSystem,
...@@ -2228,7 +2229,7 @@ pub const ModuleDebugInfo = switch (native_os) {...@@ -2228,7 +2229,7 @@ pub const ModuleDebugInfo = switch (native_os) {
2228 };2229 };
2229 }2230 }
2230 },2231 },
2231 .linux, .netbsd, .freebsd, .dragonfly, .openbsd, .haiku, .solaris => struct {2232 .linux, .netbsd, .freebsd, .dragonfly, .openbsd, .haiku, .solaris, .illumos => struct {
2232 base_address: usize,2233 base_address: usize,
2233 dwarf: DW.DwarfInfo,2234 dwarf: DW.DwarfInfo,
2234 mapped_memory: []align(mem.page_size) const u8,2235 mapped_memory: []align(mem.page_size) const u8,
...@@ -2313,6 +2314,7 @@ pub const have_segfault_handling_support = switch (native_os) {...@@ -2313,6 +2314,7 @@ pub const have_segfault_handling_support = switch (native_os) {
2313 .macos,2314 .macos,
2314 .netbsd,2315 .netbsd,
2315 .solaris,2316 .solaris,
2317 .illumos,
2316 .windows,2318 .windows,
2317 => true,2319 => true,
23182320
...@@ -2386,7 +2388,7 @@ fn handleSegfaultPosix(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const any...@@ -2386,7 +2388,7 @@ fn handleSegfaultPosix(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const any
2386 .freebsd, .macos => @intFromPtr(info.addr),2388 .freebsd, .macos => @intFromPtr(info.addr),
2387 .netbsd => @intFromPtr(info.info.reason.fault.addr),2389 .netbsd => @intFromPtr(info.info.reason.fault.addr),
2388 .openbsd => @intFromPtr(info.data.fault.addr),2390 .openbsd => @intFromPtr(info.data.fault.addr),
2389 .solaris => @intFromPtr(info.reason.fault.addr),2391 .solaris, .illumos => @intFromPtr(info.reason.fault.addr),
2390 else => unreachable,2392 else => unreachable,
2391 };2393 };
23922394
lib/std/dwarf/abi.zig+8-5
...@@ -6,11 +6,11 @@ const mem = std.mem;...@@ -6,11 +6,11 @@ const mem = std.mem;
6pub fn supportsUnwinding(target: std.Target) bool {6pub fn supportsUnwinding(target: std.Target) bool {
7 return switch (target.cpu.arch) {7 return switch (target.cpu.arch) {
8 .x86 => switch (target.os.tag) {8 .x86 => switch (target.os.tag) {
9 .linux, .netbsd, .solaris => true,9 .linux, .netbsd, .solaris, .illumos => true,
10 else => false,10 else => false,
11 },11 },
12 .x86_64 => switch (target.os.tag) {12 .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,
14 else => false,14 else => false,
15 },15 },
16 .arm => switch (target.os.tag) {16 .arm => switch (target.os.tag) {
...@@ -194,7 +194,7 @@ pub fn regBytes(...@@ -194,7 +194,7 @@ pub fn regBytes(
194 const ucontext_ptr = thread_context_ptr;194 const ucontext_ptr = thread_context_ptr;
195 return switch (builtin.cpu.arch) {195 return switch (builtin.cpu.arch) {
196 .x86 => switch (builtin.os.tag) {196 .x86 => switch (builtin.os.tag) {
197 .linux, .netbsd, .solaris => switch (reg_number) {197 .linux, .netbsd, .solaris, .illumos => switch (reg_number) {
198 0 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.EAX]),198 0 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.EAX]),
199 1 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.ECX]),199 1 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.ECX]),
200 2 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.EDX]),200 2 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.EDX]),
...@@ -229,7 +229,7 @@ pub fn regBytes(...@@ -229,7 +229,7 @@ pub fn regBytes(
229 else => error.UnimplementedOs,229 else => error.UnimplementedOs,
230 },230 },
231 .x86_64 => switch (builtin.os.tag) {231 .x86_64 => switch (builtin.os.tag) {
232 .linux, .solaris => switch (reg_number) {232 .linux, .solaris, .illumos => switch (reg_number) {
233 0 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.RAX]),233 0 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.RAX]),
234 1 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.RDX]),234 1 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.RDX]),
235 2 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.RCX]),235 2 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.RCX]),
...@@ -247,7 +247,10 @@ pub fn regBytes(...@@ -247,7 +247,10 @@ pub fn regBytes(
247 14 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.R14]),247 14 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.R14]),
248 15 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.R15]),248 15 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.R15]),
249 16 => mem.asBytes(&ucontext_ptr.mcontext.gregs[os.REG.RIP]),249 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]),
251 else => error.InvalidRegister,254 else => error.InvalidRegister,
252 },255 },
253 .freebsd => switch (reg_number) {256 .freebsd => switch (reg_number) {
lib/std/dynamic_library.zig+2-2
...@@ -10,7 +10,7 @@ const system = std.os.system;...@@ -10,7 +10,7 @@ const system = std.os.system;
10pub const DynLib = switch (builtin.os.tag) {10pub const DynLib = switch (builtin.os.tag) {
11 .linux => if (builtin.link_libc) DlDynlib else ElfDynLib,11 .linux => if (builtin.link_libc) DlDynlib else ElfDynLib,
12 .windows => WindowsDynLib,12 .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,
14 else => void,14 else => void,
15};15};
1616
...@@ -388,7 +388,7 @@ pub const DlDynlib = struct {...@@ -388,7 +388,7 @@ pub const DlDynlib = struct {
388388
389test "dynamic_library" {389test "dynamic_library" {
390 const libname = switch (builtin.os.tag) {390 const libname = switch (builtin.os.tag) {
391 .linux, .freebsd, .openbsd => "invalid_so.so",391 .linux, .freebsd, .openbsd, .solaris, .illumos => "invalid_so.so",
392 .windows => "invalid_dll.dll",392 .windows => "invalid_dll.dll",
393 .macos, .tvos, .watchos, .ios => "invalid_dylib.dylib",393 .macos, .tvos, .watchos, .ios => "invalid_dylib.dylib",
394 else => return error.SkipZigTest,394 else => return error.SkipZigTest,
lib/std/fs.zig+7-7
...@@ -39,7 +39,7 @@ pub const Watch = @import("fs/watch.zig").Watch;...@@ -39,7 +39,7 @@ pub const Watch = @import("fs/watch.zig").Watch;
39/// fit into a UTF-8 encoded array of this length.39/// fit into a UTF-8 encoded array of this length.
40/// The byte count includes room for a null sentinel byte.40/// The byte count includes room for a null sentinel byte.
41pub const MAX_PATH_BYTES = switch (builtin.os.tag) {41pub 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,
43 // Each UTF-16LE character may be expanded to 3 UTF-8 bytes.43 // Each UTF-16LE character may be expanded to 3 UTF-8 bytes.
44 // If it would require 4 UTF-8 bytes, then there would be a surrogate44 // If it would require 4 UTF-8 bytes, then there would be a surrogate
45 // pair in the UTF-16LE, and we (over)account 3 bytes for it that way.45 // 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) {...@@ -59,10 +59,9 @@ pub const MAX_PATH_BYTES = switch (builtin.os.tag) {
59/// (depending on the platform) this assumption may not hold for every configuration.59/// (depending on the platform) this assumption may not hold for every configuration.
60/// The byte count does not include a null sentinel byte.60/// The byte count does not include a null sentinel byte.
61pub const MAX_NAME_BYTES = switch (builtin.os.tag) {61pub 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,
63 // Haiku's NAME_MAX includes the null terminator, so subtract one.63 // Haiku's NAME_MAX includes the null terminator, so subtract one.
64 .haiku => os.NAME_MAX - 1,64 .haiku => os.NAME_MAX - 1,
65 .solaris => os.system.MAXNAMLEN,
66 // Each UTF-16LE character may be expanded to 3 UTF-8 bytes.65 // Each UTF-16LE character may be expanded to 3 UTF-8 bytes.
67 // If it would require 4 UTF-8 bytes, then there would be a surrogate66 // If it would require 4 UTF-8 bytes, then there would be a surrogate
68 // pair in the UTF-16LE, and we (over)account 3 bytes for it that way.67 // pair in the UTF-16LE, and we (over)account 3 bytes for it that way.
...@@ -326,7 +325,7 @@ pub const IterableDir = struct {...@@ -326,7 +325,7 @@ pub const IterableDir = struct {
326 const IteratorError = error{ AccessDenied, SystemResources } || os.UnexpectedError;325 const IteratorError = error{ AccessDenied, SystemResources } || os.UnexpectedError;
327326
328 pub const Iterator = switch (builtin.os.tag) {327 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 {
330 dir: Dir,329 dir: Dir,
331 seek: i64,330 seek: i64,
332 buf: [1024]u8, // TODO align(@alignOf(os.system.dirent)),331 buf: [1024]u8, // TODO align(@alignOf(os.system.dirent)),
...@@ -344,7 +343,7 @@ pub const IterableDir = struct {...@@ -344,7 +343,7 @@ pub const IterableDir = struct {
344 switch (builtin.os.tag) {343 switch (builtin.os.tag) {
345 .macos, .ios => return self.nextDarwin(),344 .macos, .ios => return self.nextDarwin(),
346 .freebsd, .netbsd, .dragonfly, .openbsd => return self.nextBsd(),345 .freebsd, .netbsd, .dragonfly, .openbsd => return self.nextBsd(),
347 .solaris => return self.nextSolaris(),346 .solaris, .illumos => return self.nextSolaris(),
348 else => @compileError("unimplemented"),347 else => @compileError("unimplemented"),
349 }348 }
350 }349 }
...@@ -898,6 +897,7 @@ pub const IterableDir = struct {...@@ -898,6 +897,7 @@ pub const IterableDir = struct {
898 .dragonfly,897 .dragonfly,
899 .openbsd,898 .openbsd,
900 .solaris,899 .solaris,
900 .illumos,
901 => return Iterator{901 => return Iterator{
902 .dir = self.dir,902 .dir = self.dir,
903 .seek = 0,903 .seek = 0,
...@@ -1841,7 +1841,7 @@ pub const Dir = struct {...@@ -1841,7 +1841,7 @@ pub const Dir = struct {
1841 error.AccessDenied => |e| switch (builtin.os.tag) {1841 error.AccessDenied => |e| switch (builtin.os.tag) {
1842 // non-Linux POSIX systems return EPERM when trying to delete a directory, so1842 // non-Linux POSIX systems return EPERM when trying to delete a directory, so
1843 // we need to handle that case specifically and translate the error1843 // 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 => {
1845 // Don't follow symlinks to match unlinkat (which acts on symlinks rather than follows them)1845 // Don't follow symlinks to match unlinkat (which acts on symlinks rather than follows them)
1846 const fstat = os.fstatatZ(self.fd, sub_path_c, os.AT.SYMLINK_NOFOLLOW) catch return e;1846 const fstat = os.fstatatZ(self.fd, sub_path_c, os.AT.SYMLINK_NOFOLLOW) catch return e;
1847 const is_dir = fstat.mode & os.S.IFMT == os.S.IFDIR;1847 const is_dir = fstat.mode & os.S.IFMT == os.S.IFDIR;
...@@ -3007,7 +3007,7 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {...@@ -3007,7 +3007,7 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {
3007 }3007 }
3008 switch (builtin.os.tag) {3008 switch (builtin.os.tag) {
3009 .linux => return os.readlinkZ("/proc/self/exe", out_buffer),3009 .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),
3011 .freebsd, .dragonfly => {3011 .freebsd, .dragonfly => {
3012 var mib = [4]c_int{ os.CTL.KERN, os.KERN.PROC, os.KERN.PROC_PATHNAME, -1 };3012 var mib = [4]c_int{ os.CTL.KERN, os.KERN.PROC, os.KERN.PROC_PATHNAME, -1 };
3013 var out_len: usize = out_buffer.len;3013 var out_len: usize = out_buffer.len;
lib/std/fs/file.zig+2-2
...@@ -359,7 +359,7 @@ pub const File = struct {...@@ -359,7 +359,7 @@ pub const File = struct {
359 os.S.IFSOCK => break :blk .unix_domain_socket,359 os.S.IFSOCK => break :blk .unix_domain_socket,
360 else => {},360 else => {},
361 }361 }
362 if (builtin.os.tag == .solaris) switch (m) {362 if (builtin.os.tag.isSolarish()) switch (m) {
363 os.S.IFDOOR => break :blk .door,363 os.S.IFDOOR => break :blk .door,
364 os.S.IFPORT => break :blk .event_port,364 os.S.IFPORT => break :blk .event_port,
365 else => {},365 else => {},
...@@ -685,7 +685,7 @@ pub const File = struct {...@@ -685,7 +685,7 @@ pub const File = struct {
685 else => {},685 else => {},
686 }686 }
687687
688 if (builtin.os.tag == .solaris) switch (m) {688 if (builtin.os.tag.isSolarish()) switch (m) {
689 os.S.IFDOOR => return .door,689 os.S.IFDOOR => return .door,
690 os.S.IFPORT => return .event_port,690 os.S.IFPORT => return .event_port,
691 else => {},691 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...@@ -44,7 +44,7 @@ pub fn getAppDataDir(allocator: mem.Allocator, appname: []const u8) GetAppDataDi
44 };44 };
45 return fs.path.join(allocator, &[_][]const u8{ home_dir, "Library", "Application Support", appname });45 return fs.path.join(allocator, &[_][]const u8{ home_dir, "Library", "Application Support", appname });
46 },46 },
47 .linux, .freebsd, .netbsd, .dragonfly, .openbsd, .solaris => {47 .linux, .freebsd, .netbsd, .dragonfly, .openbsd, .solaris, .illumos => {
48 if (os.getenv("XDG_DATA_HOME")) |xdg| {48 if (os.getenv("XDG_DATA_HOME")) |xdg| {
49 return fs.path.join(allocator, &[_][]const u8{ xdg, appname });49 return fs.path.join(allocator, &[_][]const u8{ xdg, appname });
50 }50 }
lib/std/os.zig+4-2
...@@ -33,6 +33,7 @@ pub const haiku = std.c;...@@ -33,6 +33,7 @@ pub const haiku = std.c;
33pub const netbsd = std.c;33pub const netbsd = std.c;
34pub const openbsd = std.c;34pub const openbsd = std.c;
35pub const solaris = std.c;35pub const solaris = std.c;
36pub const illumos = std.c;
36pub const linux = @import("os/linux.zig");37pub const linux = @import("os/linux.zig");
37pub const plan9 = @import("os/plan9.zig");38pub const plan9 = @import("os/plan9.zig");
38pub const uefi = @import("os/uefi.zig");39pub const uefi = @import("os/uefi.zig");
...@@ -1821,7 +1822,7 @@ pub fn execveZ(...@@ -1821,7 +1822,7 @@ pub fn execveZ(
1821 .BADARCH => return error.InvalidExe,1822 .BADARCH => return error.InvalidExe,
1822 else => return unexpectedErrno(err),1823 else => return unexpectedErrno(err),
1823 },1824 },
1824 .linux, .solaris => switch (err) {1825 .linux => switch (err) {
1825 .LIBBAD => return error.InvalidExe,1826 .LIBBAD => return error.InvalidExe,
1826 else => return unexpectedErrno(err),1827 else => return unexpectedErrno(err),
1827 },1828 },
...@@ -5226,6 +5227,7 @@ pub fn isGetFdPathSupportedOnTarget(os: std.Target.Os) bool {...@@ -5226,6 +5227,7 @@ pub fn isGetFdPathSupportedOnTarget(os: std.Target.Os) bool {
5226 .macos, .ios, .watchos, .tvos,5227 .macos, .ios, .watchos, .tvos,
5227 .linux,5228 .linux,
5228 .solaris,5229 .solaris,
5230 .illumos,
5229 .freebsd,5231 .freebsd,
5230 => true,5232 => true,
5231 // zig fmt: on5233 // zig fmt: on
...@@ -5280,7 +5282,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {...@@ -5280,7 +5282,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {
5280 };5282 };
5281 return target;5283 return target;
5282 },5284 },
5283 .solaris => {5285 .solaris, .illumos => {
5284 var procfs_buf: ["/proc/self/path/-2147483648\x00".len]u8 = undefined;5286 var procfs_buf: ["/proc/self/path/-2147483648\x00".len]u8 = undefined;
5285 const proc_path = std.fmt.bufPrintZ(procfs_buf[0..], "/proc/self/path/{d}", .{fd}) catch unreachable;5287 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" {...@@ -234,7 +234,7 @@ test "link with relative paths" {
234 if (native_os == .wasi and builtin.link_libc) return error.SkipZigTest;234 if (native_os == .wasi and builtin.link_libc) return error.SkipZigTest;
235235
236 switch (native_os) {236 switch (native_os) {
237 .wasi, .linux, .solaris => {},237 .wasi, .linux, .solaris, .illumos => {},
238 else => return error.SkipZigTest,238 else => return error.SkipZigTest,
239 }239 }
240 if (true) {240 if (true) {
...@@ -277,7 +277,7 @@ test "linkat with different directories" {...@@ -277,7 +277,7 @@ test "linkat with different directories" {
277 if (native_os == .wasi and builtin.link_libc) return error.SkipZigTest;277 if (native_os == .wasi and builtin.link_libc) return error.SkipZigTest;
278278
279 switch (native_os) {279 switch (native_os) {
280 .wasi, .linux, .solaris => {},280 .wasi, .linux, .solaris, .illumos => {},
281 else => return error.SkipZigTest,281 else => return error.SkipZigTest,
282 }282 }
283 if (true) {283 if (true) {
...@@ -706,7 +706,7 @@ test "fcntl" {...@@ -706,7 +706,7 @@ test "fcntl" {
706706
707test "signalfd" {707test "signalfd" {
708 switch (native_os) {708 switch (native_os) {
709 .linux, .solaris => {},709 .linux, .solaris, .illumos => {},
710 else => return error.SkipZigTest,710 else => return error.SkipZigTest,
711 }711 }
712 _ = &os.signalfd;712 _ = &os.signalfd;
...@@ -732,7 +732,7 @@ test "sync" {...@@ -732,7 +732,7 @@ test "sync" {
732732
733test "fsync" {733test "fsync" {
734 switch (native_os) {734 switch (native_os) {
735 .linux, .windows, .solaris => {},735 .linux, .windows, .solaris, .illumos => {},
736 else => return error.SkipZigTest,736 else => return error.SkipZigTest,
737 }737 }
738738
...@@ -870,7 +870,7 @@ test "sigaction" {...@@ -870,7 +870,7 @@ test "sigaction" {
870870
871test "dup & dup2" {871test "dup & dup2" {
872 switch (native_os) {872 switch (native_os) {
873 .linux, .solaris => {},873 .linux, .solaris, .illumos => {},
874 else => return error.SkipZigTest,874 else => return error.SkipZigTest,
875 }875 }
876876
lib/std/process.zig+12-1
...@@ -959,7 +959,18 @@ pub const UserInfo = struct {...@@ -959,7 +959,18 @@ pub const UserInfo = struct {
959/// POSIX function which gets a uid from username.959/// POSIX function which gets a uid from username.
960pub fn getUserInfo(name: []const u8) !UserInfo {960pub fn getUserInfo(name: []const u8) !UserInfo {
961 return switch (builtin.os.tag) {961 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),
963 else => @compileError("Unsupported OS"),974 else => @compileError("Unsupported OS"),
964 };975 };
965}976}
lib/std/target.zig+11-2
...@@ -58,6 +58,7 @@ pub const Target = struct {...@@ -58,6 +58,7 @@ pub const Target = struct {
58 glsl450,58 glsl450,
59 vulkan,59 vulkan,
60 plan9,60 plan9,
61 illumos,
61 other,62 other,
6263
63 pub inline fn isDarwin(tag: Tag) bool {64 pub inline fn isDarwin(tag: Tag) bool {
...@@ -74,6 +75,10 @@ pub const Target = struct {...@@ -74,6 +75,10 @@ pub const Target = struct {
74 };75 };
75 }76 }
7677
78 pub inline fn isSolarish(tag: Tag) bool {
79 return tag == .solaris or tag == .illumos;
80 }
81
77 pub fn dynamicLibSuffix(tag: Tag) [:0]const u8 {82 pub fn dynamicLibSuffix(tag: Tag) [:0]const u8 {
78 if (tag.isDarwin()) {83 if (tag.isDarwin()) {
79 return ".dylib";84 return ".dylib";
...@@ -266,6 +271,7 @@ pub const Target = struct {...@@ -266,6 +271,7 @@ pub const Target = struct {
266 .glsl450, // TODO: GLSL versions271 .glsl450, // TODO: GLSL versions
267 .vulkan,272 .vulkan,
268 .plan9,273 .plan9,
274 .illumos,
269 .other,275 .other,
270 => return .{ .none = {} },276 => return .{ .none = {} },
271277
...@@ -409,6 +415,7 @@ pub const Target = struct {...@@ -409,6 +415,7 @@ pub const Target = struct {
409 .openbsd,415 .openbsd,
410 .haiku,416 .haiku,
411 .solaris,417 .solaris,
418 .illumos,
412 => true,419 => true,
413420
414 .linux,421 .linux,
...@@ -526,7 +533,6 @@ pub const Target = struct {...@@ -526,7 +533,6 @@ pub const Target = struct {
526 .cloudabi,533 .cloudabi,
527 .dragonfly,534 .dragonfly,
528 .lv2,535 .lv2,
529 .solaris,
530 .zos,536 .zos,
531 .minix,537 .minix,
532 .rtems,538 .rtems,
...@@ -569,6 +575,8 @@ pub const Target = struct {...@@ -569,6 +575,8 @@ pub const Target = struct {
569 .driverkit,575 .driverkit,
570 .shadermodel,576 .shadermodel,
571 .liteos, // TODO: audit this577 .liteos, // TODO: audit this
578 .solaris,
579 .illumos,
572 => return .none,580 => return .none,
573 }581 }
574 }582 }
...@@ -1575,7 +1583,7 @@ pub const Target = struct {...@@ -1575,7 +1583,7 @@ pub const Target = struct {
1575 .netbsd => return copy(&result, "/libexec/ld.elf_so"),1583 .netbsd => return copy(&result, "/libexec/ld.elf_so"),
1576 .openbsd => return copy(&result, "/usr/libexec/ld.so"),1584 .openbsd => return copy(&result, "/usr/libexec/ld.so"),
1577 .dragonfly => return copy(&result, "/libexec/ld-elf.so.2"),1585 .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"),
1579 .linux => switch (self.cpu.arch) {1587 .linux => switch (self.cpu.arch) {
1580 .x86,1588 .x86,
1581 .sparc,1589 .sparc,
...@@ -2115,6 +2123,7 @@ pub const Target = struct {...@@ -2115,6 +2123,7 @@ pub const Target = struct {
2115 .emscripten,2123 .emscripten,
2116 .plan9,2124 .plan9,
2117 .solaris,2125 .solaris,
2126 .illumos,
2118 .haiku,2127 .haiku,
2119 .ananas,2128 .ananas,
2120 .fuchsia,2129 .fuchsia,
lib/std/zig/CrossTarget.zig+2
...@@ -111,6 +111,7 @@ fn updateOsVersionRange(self: *CrossTarget, os: Target.Os) void {...@@ -111,6 +111,7 @@ fn updateOsVersionRange(self: *CrossTarget, os: Target.Os) void {
111 .kfreebsd,111 .kfreebsd,
112 .lv2,112 .lv2,
113 .solaris,113 .solaris,
114 .illumos,
114 .zos,115 .zos,
115 .haiku,116 .haiku,
116 .minix,117 .minix,
...@@ -709,6 +710,7 @@ fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const...@@ -709,6 +710,7 @@ fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const
709 .kfreebsd,710 .kfreebsd,
710 .lv2,711 .lv2,
711 .solaris,712 .solaris,
713 .illumos,
712 .zos,714 .zos,
713 .haiku,715 .haiku,
714 .minix,716 .minix,
lib/std/zig/system/NativePaths.zig+1-1
...@@ -89,7 +89,7 @@ pub fn detect(arena: Allocator, native_info: NativeTargetInfo) !NativePaths {...@@ -89,7 +89,7 @@ pub fn detect(arena: Allocator, native_info: NativeTargetInfo) !NativePaths {
89 return self;89 return self;
90 }90 }
9191
92 if (builtin.os.tag == .solaris) {92 if (builtin.os.tag.isSolarish()) {
93 try self.addLibDir("/usr/lib/64");93 try self.addLibDir("/usr/lib/64");
94 try self.addLibDir("/usr/local/lib/64");94 try self.addLibDir("/usr/local/lib/64");
95 try self.addLibDir("/lib/64");95 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 {...@@ -51,7 +51,7 @@ pub fn detect(cross_target: CrossTarget) DetectError!NativeTargetInfo {
51 error.InvalidVersion => {},51 error.InvalidVersion => {},
52 }52 }
53 },53 },
54 .solaris => {54 .solaris, .illumos => {
55 const uts = std.os.uname();55 const uts = std.os.uname();
56 const release = mem.sliceTo(&uts.release, 0);56 const release = mem.sliceTo(&uts.release, 0);
57 if (std.SemanticVersion.parse(release)) |ver| {57 if (std.SemanticVersion.parse(release)) |ver| {
...@@ -257,10 +257,12 @@ fn detectAbiAndDynamicLinker(...@@ -257,10 +257,12 @@ fn detectAbiAndDynamicLinker(
257) DetectError!NativeTargetInfo {257) DetectError!NativeTargetInfo {
258 const native_target_has_ld = comptime builtin.target.hasDynamicLinker();258 const native_target_has_ld = comptime builtin.target.hasDynamicLinker();
259 const is_linux = builtin.target.os.tag == .linux;259 const is_linux = builtin.target.os.tag == .linux;
260 const is_solarish = builtin.target.os.tag.isSolarish();
260 const have_all_info = cross_target.dynamic_linker.get() != null and261 const have_all_info = cross_target.dynamic_linker.get() != null and
261 cross_target.abi != null and (!is_linux or cross_target.abi.?.isGnu());262 cross_target.abi != null and (!is_linux or cross_target.abi.?.isGnu());
262 const os_is_non_native = cross_target.os_tag != null;263 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) {
264 return defaultAbiAndDynamicLinker(cpu, os, cross_target);266 return defaultAbiAndDynamicLinker(cpu, os, cross_target);
265 }267 }
266 if (cross_target.abi) |abi| {268 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 {...@@ -120,7 +120,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
120 .lv2 => "lv2",120 .lv2 => "lv2",
121 .netbsd => "netbsd",121 .netbsd => "netbsd",
122 .openbsd => "openbsd",122 .openbsd => "openbsd",
123 .solaris => "solaris",123 .solaris, .illumos => "solaris",
124 .windows => "windows",124 .windows => "windows",
125 .zos => "zos",125 .zos => "zos",
126 .haiku => "haiku",126 .haiku => "haiku",
...@@ -231,7 +231,7 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {...@@ -231,7 +231,7 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {
231 .macos => .MacOSX,231 .macos => .MacOSX,
232 .netbsd => .NetBSD,232 .netbsd => .NetBSD,
233 .openbsd => .OpenBSD,233 .openbsd => .OpenBSD,
234 .solaris => .Solaris,234 .solaris, .illumos => .Solaris,
235 .zos => .ZOS,235 .zos => .ZOS,
236 .haiku => .Haiku,236 .haiku => .Haiku,
237 .minix => .Minix,237 .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...@@ -190,7 +190,7 @@ fn handleSegfaultPosix(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const any
190 .freebsd, .macos => @intFromPtr(info.addr),190 .freebsd, .macos => @intFromPtr(info.addr),
191 .netbsd => @intFromPtr(info.info.reason.fault.addr),191 .netbsd => @intFromPtr(info.info.reason.fault.addr),
192 .openbsd => @intFromPtr(info.data.fault.addr),192 .openbsd => @intFromPtr(info.data.fault.addr),
193 .solaris => @intFromPtr(info.reason.fault.addr),193 .solaris, .illumos => @intFromPtr(info.reason.fault.addr),
194 else => @compileError("TODO implement handleSegfaultPosix for new POSIX OS"),194 else => @compileError("TODO implement handleSegfaultPosix for new POSIX OS"),
195 };195 };
196196
src/libc_installation.zig+5-1
...@@ -213,11 +213,15 @@ pub const LibCInstallation = struct {...@@ -213,11 +213,15 @@ pub const LibCInstallation = struct {
213 try self.findNativeIncludeDirPosix(args);213 try self.findNativeIncludeDirPosix(args);
214 try self.findNativeCrtBeginDirHaiku(args);214 try self.findNativeCrtBeginDirHaiku(args);
215 self.crt_dir = try args.allocator.dupeZ(u8, "/system/develop/lib");215 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");
216 } else if (std.process.can_spawn) {221 } else if (std.process.can_spawn) {
217 try self.findNativeIncludeDirPosix(args);222 try self.findNativeIncludeDirPosix(args);
218 switch (builtin.target.os.tag) {223 switch (builtin.target.os.tag) {
219 .freebsd, .netbsd, .openbsd, .dragonfly => self.crt_dir = try args.allocator.dupeZ(u8, "/usr/lib"),224 .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"),
221 .linux => try self.findNativeCrtDirPosix(args),225 .linux => try self.findNativeCrtDirPosix(args),
222 else => {},226 else => {},
223 }227 }
src/libcxx.zig+1-1
...@@ -150,7 +150,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void {...@@ -150,7 +150,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void {
150150
151 if (std.mem.startsWith(u8, cxx_src, "src/support/win32/") and target.os.tag != .windows)151 if (std.mem.startsWith(u8, cxx_src, "src/support/win32/") and target.os.tag != .windows)
152 continue;152 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())
154 continue;154 continue;
155 if (std.mem.startsWith(u8, cxx_src, "src/support/ibm/") and target.os.tag != .zos)155 if (std.mem.startsWith(u8, cxx_src, "src/support/ibm/") and target.os.tag != .zos)
156 continue;156 continue;
src/link/Elf.zig+1-1
...@@ -3818,7 +3818,7 @@ const CsuObjects = struct {...@@ -3818,7 +3818,7 @@ const CsuObjects = struct {
3818 .static_pie => result.set( "start_dyn.o", "crti.o", "crtbeginS.o", "crtendS.o", "crtn.o" ),3818 .static_pie => result.set( "start_dyn.o", "crti.o", "crtbeginS.o", "crtendS.o", "crtn.o" ),
3819 // zig fmt: on3819 // zig fmt: on
3820 },3820 },
3821 .solaris => switch (mode) {3821 .solaris, .illumos => switch (mode) {
3822 // zig fmt: off3822 // zig fmt: off
3823 .dynamic_lib => result.set( null, "crti.o", null, null, "crtn.o" ),3823 .dynamic_lib => result.set( null, "crti.o", null, null, "crtn.o" ),
3824 .dynamic_exe,3824 .dynamic_exe,
src/target.zig+2-2
...@@ -218,7 +218,7 @@ pub fn hasValgrindSupport(target: std.Target) bool {...@@ -218,7 +218,7 @@ pub fn hasValgrindSupport(target: std.Target) bool {
218 .aarch64_32,218 .aarch64_32,
219 .aarch64_be,219 .aarch64_be,
220 => {220 => {
221 return target.os.tag == .linux or target.os.tag == .solaris or221 return target.os.tag == .linux or target.os.tag == .solaris or target.os.tag == .illumos or
222 (target.os.tag == .windows and target.abi != .msvc);222 (target.os.tag == .windows and target.abi != .msvc);
223 },223 },
224 else => return false,224 else => return false,
...@@ -493,7 +493,7 @@ pub fn libcFullLinkFlags(target: std.Target) []const []const u8 {...@@ -493,7 +493,7 @@ pub fn libcFullLinkFlags(target: std.Target) []const []const u8 {
493 "-lc",493 "-lc",
494 "-lutil",494 "-lutil",
495 },495 },
496 .solaris => &[_][]const u8{496 .solaris, .illumos => &[_][]const u8{
497 "-lm",497 "-lm",
498 "-lsocket",498 "-lsocket",
499 "-lnsl",499 "-lnsl",