zig: Update to 0.5.0. Unbreak.
This version of zig supports the current version of llvm in pkgsrc (9). Some patches from TheLemonMan were backported by me to fix NetBSD support. Release notes: https://ziglang.org/download/0.5.0/release-notes.html
This commit is contained in:
parent
8709e8f6ed
commit
31bc487979
12 changed files with 3294 additions and 380 deletions
|
@ -1,6 +1,6 @@
|
|||
# $NetBSD: Makefile,v 1.4 2020/03/20 11:42:38 tnn Exp $
|
||||
# $NetBSD: Makefile,v 1.5 2020/03/25 22:27:20 nia Exp $
|
||||
|
||||
DISTNAME= zig-0.4.0
|
||||
DISTNAME= zig-0.5.0
|
||||
CATEGORIES= lang
|
||||
MASTER_SITES= https://ziglang.org/download/${PKGVERSION_NOREV}/
|
||||
EXTRACT_SUFX= .tar.xz
|
||||
|
@ -12,14 +12,13 @@ LICENSE= mit
|
|||
|
||||
USE_CMAKE= yes
|
||||
USE_LANGUAGES= c c++
|
||||
|
||||
CMAKE_ARGS+= -DCMAKE_BUILD_TYPE=Release
|
||||
BROKEN= "expected LLVM 8.x but found 9.0.1"
|
||||
CMAKE_ARGS+= -DDESTDIR=${DESTDIR}
|
||||
|
||||
CHECK_PORTABILITY_SKIP+= ci/azure/macos_script
|
||||
BUILDLINK_TRANSFORM+= rm:-Werror
|
||||
|
||||
.include "../../lang/clang/buildlink3.mk"
|
||||
.include "../../lang/llvm/buildlink3.mk"
|
||||
# Using builtin lld
|
||||
#.include "../../devel/lld/buildlink3.mk"
|
||||
.include "../../mk/bsd.pkg.mk"
|
||||
|
|
2926
lang/zig/PLIST
2926
lang/zig/PLIST
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,15 @@
|
|||
$NetBSD: distinfo,v 1.3 2019/06/02 15:02:27 adam Exp $
|
||||
$NetBSD: distinfo,v 1.4 2020/03/25 22:27:20 nia Exp $
|
||||
|
||||
SHA1 (zig-0.4.0.tar.xz) = 2d3b2caaf83fd64888f32c125aca9497e7d5ac3d
|
||||
RMD160 (zig-0.4.0.tar.xz) = 6ce0d42c8d2a5608f4960722c004e83f97be2f42
|
||||
SHA512 (zig-0.4.0.tar.xz) = 4174234e05da6c13cd4fda59509ed3f35c4d4abdb34acc12d2027bbe584c86576489d473f1652eafd366cc86610487be02e671463e07043fd6763a40e65a962f
|
||||
Size (zig-0.4.0.tar.xz) = 5348776 bytes
|
||||
SHA1 (zig-0.5.0.tar.xz) = 1624885158323fee2b9e1c23b2affe82c8fefe3b
|
||||
RMD160 (zig-0.5.0.tar.xz) = 1a8619ed274cc1dc224ddd20b5a346d7eb8c1afe
|
||||
SHA512 (zig-0.5.0.tar.xz) = 1ce479077d2501c160bcac318b3d59e66921207855f56d900b9a59c44b14116639de10c5b578663b4963ccc8d49bb0d5aa75afb8987f5df1950037248561d1e2
|
||||
Size (zig-0.5.0.tar.xz) = 10956132 bytes
|
||||
SHA1 (patch-CMakeLists.txt) = f1fcb76f8a833c3afd047e6ab3ca6a3dd190e985
|
||||
SHA1 (patch-lib_std_c.zig) = 9a4e44bff7b9c108e5e6c2b8da262a63bd0c3bec
|
||||
SHA1 (patch-lib_std_c_netbsd.zig) = 1f960d80663335775a2b53aef93b642774389867
|
||||
SHA1 (patch-lib_std_fs.zig) = 6f2e72ba87d014c6d038d463ab8c72b20909dcb9
|
||||
SHA1 (patch-lib_std_fs_file.zig) = 98ec96cab2552b10e969833ec6a632dca9dee562
|
||||
SHA1 (patch-lib_std_os.zig) = dd11ca464e39b08cc38b0d2cca8d038413406258
|
||||
SHA1 (patch-lib_std_os_bits_netbsd.zig) = d9de9f5d55d99d798a102d544f8b57e05a8c6902
|
||||
SHA1 (patch-lib_std_thread.zig) = 4a18e20547dd9adf0dc6917fc33f0d895d7f7089
|
||||
SHA1 (patch-src_link.cpp) = 3a7e9af1e05b3455b74bc9ac4f37088228401299
|
||||
|
|
15
lang/zig/patches/patch-CMakeLists.txt
Normal file
15
lang/zig/patches/patch-CMakeLists.txt
Normal file
|
@ -0,0 +1,15 @@
|
|||
$NetBSD: patch-CMakeLists.txt,v 1.3 2020/03/25 22:27:20 nia Exp $
|
||||
|
||||
Use DESTDIR...
|
||||
|
||||
--- CMakeLists.txt.orig 2020-03-25 21:48:11.605064006 +0000
|
||||
+++ CMakeLists.txt
|
||||
@@ -612,7 +612,7 @@ add_custom_target(zig_build_libuserland
|
||||
"-Doutput-dir=${CMAKE_BINARY_DIR}"
|
||||
"-Drelease=${LIBUSERLAND_RELEASE_MODE}"
|
||||
"-Dlib-files-only"
|
||||
- --prefix "${CMAKE_INSTALL_PREFIX}"
|
||||
+ --prefix "${DESTDIR}${CMAKE_INSTALL_PREFIX}"
|
||||
DEPENDS zig0
|
||||
BYPRODUCTS "${LIBUSERLAND}"
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
12
lang/zig/patches/patch-lib_std_c.zig
Normal file
12
lang/zig/patches/patch-lib_std_c.zig
Normal file
|
@ -0,0 +1,12 @@
|
|||
$NetBSD: patch-lib_std_c.zig,v 1.1 2020/03/25 22:27:20 nia Exp $
|
||||
|
||||
--- lib/std/c.zig.orig 2019-09-30 15:40:00.000000000 +0000
|
||||
+++ lib/std/c.zig
|
||||
@@ -134,6 +134,7 @@ pub extern "c" fn futimens(fd: fd_t, tim
|
||||
pub extern "c" fn pthread_create(noalias newthread: *pthread_t, noalias attr: ?*const pthread_attr_t, start_routine: extern fn (?*c_void) ?*c_void, noalias arg: ?*c_void) c_int;
|
||||
pub extern "c" fn pthread_attr_init(attr: *pthread_attr_t) c_int;
|
||||
pub extern "c" fn pthread_attr_setstack(attr: *pthread_attr_t, stackaddr: *c_void, stacksize: usize) c_int;
|
||||
+pub extern "c" fn pthread_attr_setguardsize(attr: *pthread_attr_t, guardsize: usize) c_int;
|
||||
pub extern "c" fn pthread_attr_destroy(attr: *pthread_attr_t) c_int;
|
||||
pub extern "c" fn pthread_self() pthread_t;
|
||||
pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*c_void) c_int;
|
27
lang/zig/patches/patch-lib_std_c_netbsd.zig
Normal file
27
lang/zig/patches/patch-lib_std_c_netbsd.zig
Normal file
|
@ -0,0 +1,27 @@
|
|||
$NetBSD: patch-lib_std_c_netbsd.zig,v 1.1 2020/03/25 22:27:20 nia Exp $
|
||||
|
||||
NetBSD fixes. Based on:
|
||||
https://github.com/ziglang/zig/pull/4793
|
||||
|
||||
--- lib/std/c/netbsd.zig.orig 2019-09-30 15:40:00.000000000 +0000
|
||||
+++ lib/std/c/netbsd.zig
|
||||
@@ -1,8 +1,17 @@
|
||||
const std = @import("../std.zig");
|
||||
+const builtin = std.builtin;
|
||||
+
|
||||
usingnamespace std.c;
|
||||
|
||||
extern "c" fn __errno() *c_int;
|
||||
pub const _errno = __errno;
|
||||
|
||||
-pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) usize;
|
||||
-pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int;
|
||||
+pub const dl_iterate_phdr_callback = extern fn (info: *dl_phdr_info,
|
||||
+size: usize, data: ?*c_void) c_int;
|
||||
+pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int;
|
||||
+
|
||||
+pub extern "c" fn __fstat50(fd: fd_t, buf: *Stat) c_int;
|
||||
+pub extern "c" fn __clock_gettime50(clk_id: c_int, tp: *timespec) c_int;
|
||||
+pub extern "c" fn __clock_getres50(clk_id: c_int, tp: *timespec) c_int;
|
||||
+pub extern "c" fn __getdents30(fd: c_int, buf_ptr: [*]u8, nbytes: usize) c_int;
|
||||
+pub extern "c" fn __sigaltstack14(ss: ?*stack_t, old_ss: ?*stack_t) c_int;
|
24
lang/zig/patches/patch-lib_std_fs.zig
Normal file
24
lang/zig/patches/patch-lib_std_fs.zig
Normal file
|
@ -0,0 +1,24 @@
|
|||
$NetBSD: patch-lib_std_fs.zig,v 1.1 2020/03/25 22:27:20 nia Exp $
|
||||
|
||||
NetBSD fixes. Based on:
|
||||
https://github.com/ziglang/zig/pull/4793
|
||||
|
||||
--- lib/std/fs.zig.orig 2019-09-30 15:40:00.000000000 +0000
|
||||
+++ lib/std/fs.zig
|
||||
@@ -726,12 +726,10 @@ pub const Dir = struct {
|
||||
}
|
||||
|
||||
while (true) {
|
||||
- const rc = os.system.getdirentries(
|
||||
- self.handle.fd,
|
||||
- self.handle.buf.ptr,
|
||||
- self.handle.buf.len,
|
||||
- &self.handle.seek,
|
||||
- );
|
||||
+ const rc = switch (builtin.os) {
|
||||
+ .netbsd => os.system.__getdents30(self.handle.fd, self.handle.buf.ptr, self.handle.buf.len),
|
||||
+ else => os.system.getdents(self.handle.fd, self.handle.buf.ptr, self.handle.buf.len)
|
||||
+ };
|
||||
switch (os.errno(rc)) {
|
||||
0 => {},
|
||||
os.EBADF => unreachable,
|
33
lang/zig/patches/patch-lib_std_fs_file.zig
Normal file
33
lang/zig/patches/patch-lib_std_fs_file.zig
Normal file
|
@ -0,0 +1,33 @@
|
|||
$NetBSD: patch-lib_std_fs_file.zig,v 1.1 2020/03/25 22:27:20 nia Exp $
|
||||
|
||||
Portability.
|
||||
|
||||
--- lib/std/fs/file.zig.orig 2019-09-30 15:40:00.000000000 +0000
|
||||
+++ lib/std/fs/file.zig
|
||||
@@ -41,7 +41,7 @@ pub const File = struct {
|
||||
const path_w = try windows.cStrToPrefixedFileW(path);
|
||||
return openReadW(&path_w);
|
||||
}
|
||||
- const flags = os.O_LARGEFILE | os.O_RDONLY;
|
||||
+ const flags = os.O_RDONLY;
|
||||
const fd = try os.openC(path, flags, 0);
|
||||
return openHandle(fd);
|
||||
}
|
||||
@@ -83,7 +83,7 @@ pub const File = struct {
|
||||
const path_w = try windows.cStrToPrefixedFileW(path);
|
||||
return openWriteModeW(&path_w, file_mode);
|
||||
}
|
||||
- const flags = os.O_LARGEFILE | os.O_WRONLY | os.O_CREAT | os.O_CLOEXEC | os.O_TRUNC;
|
||||
+ const flags = os.O_WRONLY | os.O_CREAT | os.O_CLOEXEC | os.O_TRUNC;
|
||||
const fd = try os.openC(path, flags, file_mode);
|
||||
return openHandle(fd);
|
||||
}
|
||||
@@ -119,7 +119,7 @@ pub const File = struct {
|
||||
const path_w = try windows.cStrToPrefixedFileW(path);
|
||||
return openWriteNoClobberW(&path_w, file_mode);
|
||||
}
|
||||
- const flags = os.O_LARGEFILE | os.O_WRONLY | os.O_CREAT | os.O_CLOEXEC | os.O_EXCL;
|
||||
+ const flags = os.O_WRONLY | os.O_CREAT | os.O_CLOEXEC | os.O_EXCL;
|
||||
const fd = try os.openC(path, flags, file_mode);
|
||||
return openHandle(fd);
|
||||
}
|
72
lang/zig/patches/patch-lib_std_os.zig
Normal file
72
lang/zig/patches/patch-lib_std_os.zig
Normal file
|
@ -0,0 +1,72 @@
|
|||
$NetBSD: patch-lib_std_os.zig,v 1.1 2020/03/25 22:27:20 nia Exp $
|
||||
|
||||
NetBSD fixes. Based on:
|
||||
https://github.com/ziglang/zig/pull/4793
|
||||
|
||||
--- lib/std/os.zig.orig 2019-09-30 15:40:00.000000000 +0000
|
||||
+++ lib/std/os.zig
|
||||
@@ -1841,6 +1841,16 @@ pub fn fstat(fd: fd_t) FStatError!Stat {
|
||||
}
|
||||
}
|
||||
|
||||
+ if (netbsd.is_the_target) {
|
||||
+ switch (errno(system.__fstat50(fd, &stat))) {
|
||||
+ 0 => return stat,
|
||||
+ EINVAL => unreachable,
|
||||
+ EBADF => unreachable, // Always a race condition.
|
||||
+ ENOMEM => return error.SystemResources,
|
||||
+ else => |err| return unexpectedErrno(err),
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
switch (errno(system.fstat(fd, &stat))) {
|
||||
0 => return stat,
|
||||
EINVAL => unreachable,
|
||||
@@ -2554,6 +2564,14 @@ pub const ClockGetTimeError = error{
|
||||
};
|
||||
|
||||
pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void {
|
||||
+ if (netbsd.is_the_target) {
|
||||
+ switch (errno(system.__clock_gettime50(ss, old_ss))) {
|
||||
+ 0 => return,
|
||||
+ EFAULT => unreachable,
|
||||
+ EINVAL => return error.UnsupportedClock,
|
||||
+ else => |err| return unexpectedErrno(err),
|
||||
+ }
|
||||
+ }
|
||||
switch (errno(system.clock_gettime(clk_id, tp))) {
|
||||
0 => return,
|
||||
EFAULT => unreachable,
|
||||
@@ -2563,6 +2581,14 @@ pub fn clock_gettime(clk_id: i32, tp: *t
|
||||
}
|
||||
|
||||
pub fn clock_getres(clk_id: i32, res: *timespec) ClockGetTimeError!void {
|
||||
+ if (netbsd.is_the_target) {
|
||||
+ switch (errno(system.__clock_getres50(ss, old_ss))) {
|
||||
+ 0 => return,
|
||||
+ EFAULT => unreachable,
|
||||
+ EINVAL => return error.UnsupportedClock,
|
||||
+ else => |err| return unexpectedErrno(err),
|
||||
+ }
|
||||
+ }
|
||||
switch (errno(system.clock_getres(clk_id, res))) {
|
||||
0 => return,
|
||||
EFAULT => unreachable,
|
||||
@@ -2635,6 +2661,17 @@ pub fn sigaltstack(ss: ?*stack_t, old_ss
|
||||
if (windows.is_the_target or uefi.is_the_target or wasi.is_the_target)
|
||||
@compileError("std.os.sigaltstack not available for this target");
|
||||
|
||||
+ if (netbsd.is_the_target) {
|
||||
+ switch (errno(system.__sigaltstack14(ss, old_ss))) {
|
||||
+ 0 => return,
|
||||
+ EFAULT => unreachable,
|
||||
+ EINVAL => unreachable,
|
||||
+ ENOMEM => return error.SizeTooSmall,
|
||||
+ EPERM => return error.PermissionDenied,
|
||||
+ else => |err| return unexpectedErrno(err),
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
switch (errno(system.sigaltstack(ss, old_ss))) {
|
||||
0 => return,
|
||||
EFAULT => unreachable,
|
467
lang/zig/patches/patch-lib_std_os_bits_netbsd.zig
Normal file
467
lang/zig/patches/patch-lib_std_os_bits_netbsd.zig
Normal file
|
@ -0,0 +1,467 @@
|
|||
$NetBSD: patch-lib_std_os_bits_netbsd.zig,v 1.1 2020/03/25 22:27:20 nia Exp $
|
||||
|
||||
NetBSD fixes. Based on:
|
||||
https://github.com/ziglang/zig/pull/4793
|
||||
|
||||
--- lib/std/os/bits/netbsd.zig.orig 2019-09-30 15:40:00.000000000 +0000
|
||||
+++ lib/std/os/bits/netbsd.zig
|
||||
@@ -1,8 +1,12 @@
|
||||
const std = @import("../../std.zig");
|
||||
const maxInt = std.math.maxInt;
|
||||
|
||||
-pub const fd_t = c_int;
|
||||
-pub const pid_t = c_int;
|
||||
+pub const fd_t = i32;
|
||||
+pub const pid_t = i32;
|
||||
+pub const mode_t = u32;
|
||||
+pub const ino_t = u64;
|
||||
+pub const off_t = i64;
|
||||
+pub const socklen_t = u32;
|
||||
|
||||
/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
|
||||
pub const Kevent = extern struct {
|
||||
@@ -14,12 +18,6 @@ pub const Kevent = extern struct {
|
||||
udata: usize,
|
||||
};
|
||||
|
||||
-pub const pthread_attr_t = extern struct {
|
||||
- pta_magic: u32,
|
||||
- pta_flags: c_int,
|
||||
- pta_private: *c_void,
|
||||
-};
|
||||
-
|
||||
pub const dl_phdr_info = extern struct {
|
||||
dlpi_addr: usize,
|
||||
dlpi_name: ?[*]const u8,
|
||||
@@ -27,6 +25,65 @@ pub const dl_phdr_info = extern struct {
|
||||
dlpi_phnum: u16,
|
||||
};
|
||||
|
||||
+pub const addrinfo = extern struct {
|
||||
+ flags: i32,
|
||||
+ family: i32,
|
||||
+ socktype: i32,
|
||||
+ protocol: i32,
|
||||
+ addrlen: socklen_t,
|
||||
+ canonname: ?[*]u8,
|
||||
+ addr: ?*sockaddr,
|
||||
+ next: ?*addrinfo,
|
||||
+};
|
||||
+
|
||||
+pub const EAI = extern enum(c_int) {
|
||||
+ /// address family for hostname not supported
|
||||
+ ADDRFAMILY = 1,
|
||||
+
|
||||
+ /// name could not be resolved at this time
|
||||
+ AGAIN = 2,
|
||||
+
|
||||
+ /// flags parameter had an invalid value
|
||||
+ BADFLAGS = 3,
|
||||
+
|
||||
+ /// non-recoverable failure in name resolution
|
||||
+ FAIL = 4,
|
||||
+
|
||||
+ /// address family not recognized
|
||||
+ FAMILY = 5,
|
||||
+
|
||||
+ /// memory allocation failure
|
||||
+ MEMORY = 6,
|
||||
+
|
||||
+ /// no address associated with hostname
|
||||
+ NODATA = 7,
|
||||
+
|
||||
+ /// name does not resolve
|
||||
+ NONAME = 8,
|
||||
+
|
||||
+ /// service not recognized for socket type
|
||||
+ SERVICE = 9,
|
||||
+
|
||||
+ /// intended socket type was not recognized
|
||||
+ SOCKTYPE = 10,
|
||||
+
|
||||
+ /// system error returned in errno
|
||||
+ SYSTEM = 11,
|
||||
+
|
||||
+ /// invalid value for hints
|
||||
+ BADHINTS = 12,
|
||||
+
|
||||
+ /// resolved protocol is unknown
|
||||
+ PROTOCOL = 13,
|
||||
+
|
||||
+ /// argument buffer overflow
|
||||
+ OVERFLOW = 14,
|
||||
+
|
||||
+ _,
|
||||
+};
|
||||
+
|
||||
+pub const EAI_MAX = 15;
|
||||
+
|
||||
pub const msghdr = extern struct {
|
||||
/// optional address
|
||||
msg_name: ?*sockaddr,
|
||||
@@ -73,8 +130,6 @@ pub const msghdr_const = extern struct {
|
||||
msg_flags: i32,
|
||||
};
|
||||
|
||||
-pub const off_t = i64;
|
||||
-
|
||||
/// Renamed to Stat to not conflict with the stat function.
|
||||
/// atime, mtime, and ctime have functions to return `timespec`,
|
||||
/// because although this is a POSIX API, the layout and names of
|
||||
@@ -84,7 +139,7 @@ pub const off_t = i64;
|
||||
pub const Stat = extern struct {
|
||||
dev: u64,
|
||||
mode: u32,
|
||||
- ino: u64,
|
||||
+ ino: ino_t,
|
||||
nlink: usize,
|
||||
|
||||
uid: u32,
|
||||
@@ -126,35 +181,71 @@ pub const dirent = extern struct {
|
||||
d_reclen: u16,
|
||||
d_namlen: u16,
|
||||
d_type: u8,
|
||||
- d_off: i64,
|
||||
d_name: [512]u8,
|
||||
+
|
||||
+ pub fn reclen(self: dirent) u16 {
|
||||
+ return self.d_reclen;
|
||||
+ }
|
||||
};
|
||||
|
||||
pub const in_port_t = u16;
|
||||
pub const sa_family_t = u8;
|
||||
|
||||
-pub const sockaddr = extern union {
|
||||
- in: sockaddr_in,
|
||||
- in6: sockaddr_in6,
|
||||
+pub const sockaddr = extern struct {
|
||||
+ /// total length
|
||||
+ len: u8,
|
||||
+
|
||||
+ /// address family
|
||||
+ family: sa_family_t,
|
||||
+
|
||||
+ /// actually longer; address value
|
||||
+ data: [14]u8,
|
||||
};
|
||||
|
||||
pub const sockaddr_in = extern struct {
|
||||
- len: u8,
|
||||
- family: sa_family_t,
|
||||
+ len: u8 = @sizeOf(sockaddr_in),
|
||||
+ family: sa_family_t = AF_INET,
|
||||
port: in_port_t,
|
||||
addr: u32,
|
||||
- zero: [8]u8,
|
||||
+ zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
};
|
||||
|
||||
pub const sockaddr_in6 = extern struct {
|
||||
- len: u8,
|
||||
- family: sa_family_t,
|
||||
+ len: u8 = @sizeOf(sockaddr_in6),
|
||||
+ family: sa_family_t = AF_INET6,
|
||||
port: in_port_t,
|
||||
flowinfo: u32,
|
||||
addr: [16]u8,
|
||||
scope_id: u32,
|
||||
};
|
||||
|
||||
+/// Definitions for UNIX IPC domain.
|
||||
+pub const sockaddr_un = extern struct {
|
||||
+ /// total sockaddr length
|
||||
+ len: u8 = @sizeOf(sockaddr_un),
|
||||
+
|
||||
+ /// AF_LOCAL
|
||||
+ family: sa_family_t = AF_LOCAL,
|
||||
+
|
||||
+ /// path name
|
||||
+ path: [104]u8,
|
||||
+};
|
||||
+
|
||||
+/// get address to use bind()
|
||||
+pub const AI_PASSIVE = 0x00000001;
|
||||
+
|
||||
+/// fill ai_canonname
|
||||
+pub const AI_CANONNAME = 0x00000002;
|
||||
+
|
||||
+/// prevent host name resolution
|
||||
+pub const AI_NUMERICHOST = 0x00000004;
|
||||
+
|
||||
+/// prevent service name resolution
|
||||
+pub const AI_NUMERICSERV = 0x00000008;
|
||||
+
|
||||
+/// only if any address is assigned
|
||||
+pub const AI_ADDRCONFIG = 0x00000400;
|
||||
+
|
||||
pub const CTL_KERN = 1;
|
||||
pub const CTL_DEBUG = 5;
|
||||
|
||||
@@ -256,31 +347,71 @@ pub const X_OK = 1; // test for execute
|
||||
pub const W_OK = 2; // test for write permission
|
||||
pub const R_OK = 4; // test for read permission
|
||||
|
||||
-pub const O_RDONLY = 0x0000;
|
||||
-pub const O_WRONLY = 0x0001;
|
||||
-pub const O_RDWR = 0x0002;
|
||||
-pub const O_ACCMODE = 0x0003;
|
||||
-
|
||||
-pub const O_CREAT = 0x0200;
|
||||
-pub const O_EXCL = 0x0800;
|
||||
-pub const O_NOCTTY = 0x8000;
|
||||
-pub const O_TRUNC = 0x0400;
|
||||
-pub const O_APPEND = 0x0008;
|
||||
-pub const O_NONBLOCK = 0x0004;
|
||||
+/// open for reading only
|
||||
+pub const O_RDONLY = 0x00000000;
|
||||
+
|
||||
+/// open for writing only
|
||||
+pub const O_WRONLY = 0x00000001;
|
||||
+
|
||||
+/// open for reading and writing
|
||||
+pub const O_RDWR = 0x00000002;
|
||||
+
|
||||
+/// mask for above modes
|
||||
+pub const O_ACCMODE = 0x00000003;
|
||||
+
|
||||
+/// no delay
|
||||
+pub const O_NONBLOCK = 0x00000004;
|
||||
+
|
||||
+/// set append mode
|
||||
+pub const O_APPEND = 0x00000008;
|
||||
+
|
||||
+/// open with shared file lock
|
||||
+pub const O_SHLOCK = 0x00000010;
|
||||
+
|
||||
+/// open with exclusive file lock
|
||||
+pub const O_EXLOCK = 0x00000020;
|
||||
+
|
||||
+/// signal pgrp when data ready
|
||||
+pub const O_ASYNC = 0x00000040;
|
||||
+
|
||||
+/// synchronous writes
|
||||
+pub const O_SYNC = 0x00000080;
|
||||
+
|
||||
+/// don't follow symlinks on the last
|
||||
+pub const O_NOFOLLOW = 0x00000100;
|
||||
+
|
||||
+/// create if nonexistent
|
||||
+pub const O_CREAT = 0x00000200;
|
||||
+
|
||||
+/// truncate to zero length
|
||||
+pub const O_TRUNC = 0x00000400;
|
||||
+
|
||||
+/// error if already exists
|
||||
+pub const O_EXCL = 0x00000800;
|
||||
+
|
||||
+/// don't assign controlling terminal
|
||||
+pub const O_NOCTTY = 0x00008000;
|
||||
+
|
||||
+/// write: I/O data completion
|
||||
pub const O_DSYNC = 0x00010000;
|
||||
-pub const O_SYNC = 0x0080;
|
||||
+
|
||||
+/// read: I/O completion as for write
|
||||
pub const O_RSYNC = 0x00020000;
|
||||
-pub const O_DIRECTORY = 0x00080000;
|
||||
-pub const O_NOFOLLOW = 0x00000100;
|
||||
-pub const O_CLOEXEC = 0x00400000;
|
||||
|
||||
-pub const O_ASYNC = 0x0040;
|
||||
+/// use alternate i/o semantics
|
||||
+pub const O_ALT_IO = 0x00040000;
|
||||
+
|
||||
+/// direct I/O hint
|
||||
pub const O_DIRECT = 0x00080000;
|
||||
-pub const O_LARGEFILE = 0;
|
||||
-pub const O_NOATIME = 0;
|
||||
-pub const O_PATH = 0;
|
||||
-pub const O_TMPFILE = 0;
|
||||
-pub const O_NDELAY = O_NONBLOCK;
|
||||
+
|
||||
+/// fail if not a directory
|
||||
+pub const O_DIRECTORY = 0x00200000;
|
||||
+
|
||||
+/// set close on exec
|
||||
+pub const O_CLOEXEC = 0x00400000;
|
||||
+
|
||||
+/// skip search permission checks
|
||||
+pub const O_SEARCH = 0x00800000;
|
||||
|
||||
pub const F_DUPFD = 0;
|
||||
pub const F_GETFD = 1;
|
||||
@@ -295,6 +426,8 @@ pub const F_GETLK = 7;
|
||||
pub const F_SETLK = 8;
|
||||
pub const F_SETLKW = 9;
|
||||
|
||||
+pub const FD_CLOEXEC = 1;
|
||||
+
|
||||
pub const SEEK_SET = 0;
|
||||
pub const SEEK_CUR = 1;
|
||||
pub const SEEK_END = 2;
|
||||
@@ -312,31 +445,6 @@ pub const SOCK_SEQPACKET = 5;
|
||||
pub const SOCK_CLOEXEC = 0x10000000;
|
||||
pub const SOCK_NONBLOCK = 0x20000000;
|
||||
|
||||
-pub const PROTO_ip = 0;
|
||||
-pub const PROTO_icmp = 1;
|
||||
-pub const PROTO_igmp = 2;
|
||||
-pub const PROTO_ggp = 3;
|
||||
-pub const PROTO_ipencap = 4;
|
||||
-pub const PROTO_tcp = 6;
|
||||
-pub const PROTO_egp = 8;
|
||||
-pub const PROTO_pup = 12;
|
||||
-pub const PROTO_udp = 17;
|
||||
-pub const PROTO_xns_idp = 22;
|
||||
-pub const PROTO_iso_tp4 = 29;
|
||||
-pub const PROTO_ipv6 = 41;
|
||||
-pub const PROTO_ipv6_route = 43;
|
||||
-pub const PROTO_ipv6_frag = 44;
|
||||
-pub const PROTO_rsvp = 46;
|
||||
-pub const PROTO_gre = 47;
|
||||
-pub const PROTO_esp = 50;
|
||||
-pub const PROTO_ah = 51;
|
||||
-pub const PROTO_ipv6_icmp = 58;
|
||||
-pub const PROTO_ipv6_nonxt = 59;
|
||||
-pub const PROTO_ipv6_opts = 60;
|
||||
-pub const PROTO_encap = 98;
|
||||
-pub const PROTO_pim = 103;
|
||||
-pub const PROTO_raw = 255;
|
||||
-
|
||||
pub const PF_UNSPEC = 0;
|
||||
pub const PF_LOCAL = 1;
|
||||
pub const PF_UNIX = PF_LOCAL;
|
||||
@@ -822,4 +930,132 @@ pub fn S_IWHT(m: u32) bool {
|
||||
return m & S_IFMT == S_IFWHT;
|
||||
}
|
||||
|
||||
+/// Magic value that specify the use of the current working directory
|
||||
+/// to determine the target of relative file paths in the openat() and
|
||||
+/// similar syscalls.
|
||||
+pub const AT_FDCWD = -100;
|
||||
+
|
||||
+/// Check access using effective user and group ID
|
||||
+pub const AT_EACCESS = 0x0100;
|
||||
+
|
||||
+/// Do not follow symbolic links
|
||||
+pub const AT_SYMLINK_NOFOLLOW = 0x0200;
|
||||
+
|
||||
+/// Follow symbolic link
|
||||
+pub const AT_SYMLINK_FOLLOW = 0x0400;
|
||||
+
|
||||
+/// Remove directory instead of file
|
||||
+pub const AT_REMOVEDIR = 0x0800;
|
||||
+
|
||||
pub const HOST_NAME_MAX = 255;
|
||||
+
|
||||
+/// dummy for IP
|
||||
+pub const IPPROTO_IP = 0;
|
||||
+
|
||||
+/// IP6 hop-by-hop options
|
||||
+pub const IPPROTO_HOPOPTS = 0;
|
||||
+
|
||||
+/// control message protocol
|
||||
+pub const IPPROTO_ICMP = 1;
|
||||
+
|
||||
+/// group mgmt protocol
|
||||
+pub const IPPROTO_IGMP = 2;
|
||||
+
|
||||
+/// gateway^2 (deprecated)
|
||||
+pub const IPPROTO_GGP = 3;
|
||||
+
|
||||
+/// IP header
|
||||
+pub const IPPROTO_IPV4 = 4;
|
||||
+
|
||||
+/// IP inside IP
|
||||
+pub const IPPROTO_IPIP = 4;
|
||||
+
|
||||
+/// tcp
|
||||
+pub const IPPROTO_TCP = 6;
|
||||
+
|
||||
+/// exterior gateway protocol
|
||||
+pub const IPPROTO_EGP = 8;
|
||||
+
|
||||
+/// pup
|
||||
+pub const IPPROTO_PUP = 12;
|
||||
+
|
||||
+/// user datagram protocol
|
||||
+pub const IPPROTO_UDP = 17;
|
||||
+
|
||||
+/// xns idp
|
||||
+pub const IPPROTO_IDP = 22;
|
||||
+
|
||||
+/// tp-4 w/ class negotiation
|
||||
+pub const IPPROTO_TP = 29;
|
||||
+
|
||||
+/// DCCP
|
||||
+pub const IPPROTO_DCCP = 33;
|
||||
+
|
||||
+/// IP6 header
|
||||
+pub const IPPROTO_IPV6 = 41;
|
||||
+
|
||||
+/// IP6 routing header
|
||||
+pub const IPPROTO_ROUTING = 43;
|
||||
+
|
||||
+/// IP6 fragmentation header
|
||||
+pub const IPPROTO_FRAGMENT = 44;
|
||||
+
|
||||
+/// resource reservation
|
||||
+pub const IPPROTO_RSVP = 46;
|
||||
+
|
||||
+/// GRE encaps RFC 1701
|
||||
+pub const IPPROTO_GRE = 47;
|
||||
+
|
||||
+/// encap. security payload
|
||||
+pub const IPPROTO_ESP = 50;
|
||||
+
|
||||
+/// authentication header
|
||||
+pub const IPPROTO_AH = 51;
|
||||
+
|
||||
+/// IP Mobility RFC 2004
|
||||
+pub const IPPROTO_MOBILE = 55;
|
||||
+
|
||||
+/// IPv6 ICMP
|
||||
+pub const IPPROTO_IPV6_ICMP = 58;
|
||||
+
|
||||
+/// ICMP6
|
||||
+pub const IPPROTO_ICMPV6 = 58;
|
||||
+
|
||||
+/// IP6 no next header
|
||||
+pub const IPPROTO_NONE = 59;
|
||||
+
|
||||
+/// IP6 destination option
|
||||
+pub const IPPROTO_DSTOPTS = 60;
|
||||
+
|
||||
+/// ISO cnlp
|
||||
+pub const IPPROTO_EON = 80;
|
||||
+
|
||||
+/// Ethernet-in-IP
|
||||
+pub const IPPROTO_ETHERIP = 97;
|
||||
+
|
||||
+/// encapsulation header
|
||||
+pub const IPPROTO_ENCAP = 98;
|
||||
+
|
||||
+/// Protocol indep. multicast
|
||||
+pub const IPPROTO_PIM = 103;
|
||||
+
|
||||
+/// IP Payload Comp. Protocol
|
||||
+pub const IPPROTO_IPCOMP = 108;
|
||||
+
|
||||
+/// VRRP RFC 2338
|
||||
+pub const IPPROTO_VRRP = 112;
|
||||
+
|
||||
+/// Common Address Resolution Protocol
|
||||
+pub const IPPROTO_CARP = 112;
|
||||
+
|
||||
+/// L2TPv3
|
||||
+pub const IPPROTO_L2TP = 115;
|
||||
+
|
||||
+/// SCTP
|
||||
+pub const IPPROTO_SCTP = 132;
|
||||
+
|
||||
+/// PFSYNC
|
||||
+pub const IPPROTO_PFSYNC = 240;
|
||||
+
|
||||
+/// raw IP packet
|
||||
+pub const IPPROTO_RAW = 255;
|
52
lang/zig/patches/patch-lib_std_thread.zig
Normal file
52
lang/zig/patches/patch-lib_std_thread.zig
Normal file
|
@ -0,0 +1,52 @@
|
|||
$NetBSD: patch-lib_std_thread.zig,v 1.1 2020/03/25 22:27:20 nia Exp $
|
||||
|
||||
NetBSD fixes. Based on:
|
||||
https://github.com/ziglang/zig/pull/4793
|
||||
|
||||
--- lib/std/thread.zig.orig 2019-09-30 15:40:00.000000000 +0000
|
||||
+++ lib/std/thread.zig
|
||||
@@ -255,12 +255,13 @@ pub const Thread = struct {
|
||||
}
|
||||
break :blk l;
|
||||
};
|
||||
- // Map the whole stack with no rw permissions to avoid committing the
|
||||
- // whole region right away
|
||||
+ // NetBSD mprotect is very strict and doesn't allow to "upgrade"
|
||||
+ // a PROT_NONE mapping to a RW one so let's allocate everything
|
||||
+ // right away
|
||||
const mmap_slice = os.mmap(
|
||||
null,
|
||||
- mem.alignForward(mmap_len, mem.page_size),
|
||||
- os.PROT_NONE,
|
||||
+ mmap_len,
|
||||
+ os.PROT_READ | os.PROT_WRITE,
|
||||
os.MAP_PRIVATE | os.MAP_ANONYMOUS,
|
||||
-1,
|
||||
0,
|
||||
@@ -272,10 +273,10 @@ pub const Thread = struct {
|
||||
};
|
||||
errdefer os.munmap(mmap_slice);
|
||||
|
||||
- // Map everything but the guard page as rw
|
||||
+ // Remap the guard page with no permissions
|
||||
os.mprotect(
|
||||
- mmap_slice,
|
||||
- os.PROT_READ | os.PROT_WRITE,
|
||||
+ mmap_slice[0..guard_end_offset],
|
||||
+ os.PROT_NONE,
|
||||
) catch |err| switch (err) {
|
||||
error.AccessDenied => unreachable,
|
||||
else => |e| return e,
|
||||
@@ -301,6 +302,12 @@ pub const Thread = struct {
|
||||
|
||||
assert(c.pthread_attr_setstack(&attr, mmap_slice.ptr, stack_end_offset) == 0);
|
||||
|
||||
+ // Even though pthread's man pages state that the guard size is
|
||||
+ // ignored when the stack address is explicitly given, on some
|
||||
+ // plaforms such as NetBSD we still have to zero it to prevent
|
||||
+ // random crashes in pthread_join calls
|
||||
+ assert(c.pthread_attr_setguardsize(&attr, 0) == 0);
|
||||
+
|
||||
const err = c.pthread_create(&thread_ptr.data.handle, &attr, MainFuncs.posixThreadMain, @intToPtr(*c_void, arg));
|
||||
switch (err) {
|
||||
0 => return thread_ptr,
|
18
lang/zig/patches/patch-src_link.cpp
Normal file
18
lang/zig/patches/patch-src_link.cpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
$NetBSD: patch-src_link.cpp,v 1.3 2020/03/25 22:27:20 nia Exp $
|
||||
|
||||
NetBSD fixes. Based on:
|
||||
https://github.com/ziglang/zig/pull/4793
|
||||
|
||||
--- src/link.cpp.orig 2019-09-30 15:40:00.000000000 +0000
|
||||
+++ src/link.cpp
|
||||
@@ -1805,7 +1805,9 @@ static void construct_linker_job_elf(Lin
|
||||
}
|
||||
}
|
||||
|
||||
- if (g->zig_target->os == OsFreeBSD) {
|
||||
+ if (g->zig_target->os == OsFreeBSD ||
|
||||
+ g->zig_target->os == OsNetBSD)
|
||||
+ {
|
||||
lj->args.append("-lpthread");
|
||||
}
|
||||
} else if (target_is_glibc(g->zig_target)) {
|
Loading…
Reference in a new issue