From 2064b7a3d2290c294e8b4c4a034978cf67fc48b5 Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Mon, 14 Oct 2024 09:12:03 -0400 Subject: [PATCH 01/14] Configure NetBSD CI --- .github/workflows/full_ci.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.github/workflows/full_ci.yml b/.github/workflows/full_ci.yml index 662f3921ef502..fe796325da4b5 100644 --- a/.github/workflows/full_ci.yml +++ b/.github/workflows/full_ci.yml @@ -186,6 +186,34 @@ jobs: - name: Execute run-docker.sh run: sh ./ci/run-docker.sh ${{ matrix.target }} + build_channels_netbsd: + permissions: + contents: read # to fetch code (actions/checkout) + + name: Build Channels NetBSD + runs-on: ubuntu-latest + env: + OS: netbsd + strategy: + fail-fast: true + steps: + - uses: actions/checkout@v4 + - name: Run netbsd vm + id: netbsd-ci + uses: vmactions/netbsd-vm@v1 + with: + envs: 'OS' + usesh: true + prepare: | + /usr/sbin/pkg_add curl + curl https://sh.rustup.rs -sSf --output rustup.sh + sh rustup.sh -y --default-toolchain nightly --profile=minimal + . $HOME/.cargo/env + run: | + . $HOME/.cargo/env + LIBC_CI=1 sh ci/run.sh x86_64-unknown-netbsd + sh ci/run.sh x86_64-unknown-netbsd + check_cfg: name: "Check #[cfg]s" runs-on: ubuntu-22.04 From b2a4b96ca00ad23bfd3552deb3f6a9586537b643 Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Mon, 14 Oct 2024 10:18:46 -0400 Subject: [PATCH 02/14] Temporarily remove `esetfunc` from NetBSD --- libc-test/semver/netbsd.txt | 1 - src/unix/bsd/netbsdlike/netbsd/mod.rs | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index e07a7dbf08ae6..ec6852c04c525 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -1241,7 +1241,6 @@ emalloc erand48 erealloc ereallocarr -esetfunc estrdup estrndup estrlcat diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 318557daf52b8..2b80c6df51344 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -2950,9 +2950,12 @@ extern "C" { ) -> ::uintmax_t; pub fn easprintf(string: *mut *mut ::c_char, fmt: *const ::c_char, ...) -> ::c_int; pub fn evasprintf(string: *mut *mut ::c_char, fmt: *const ::c_char, ...) -> ::c_int; + // FIXME: re-add with semver once https://github.com/JohnTitor/ctest2/issues/58 is resolved + /* pub fn esetfunc( cb: ::Option, ) -> ::Option; + */ pub fn secure_path(path: *const ::c_char) -> ::c_int; pub fn snprintb( buf: *mut ::c_char, From 8afd362aa4707ea20a1b58ce1fd19344eb5d8990 Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Mon, 14 Oct 2024 08:33:45 -0600 Subject: [PATCH 03/14] Remove deprecated `vm_size_t` type --- libc-test/semver/netbsd.txt | 1 - src/unix/bsd/netbsdlike/netbsd/mod.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index ec6852c04c525..4696ae4f710c5 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -1593,7 +1593,6 @@ utmpxname utpname utrace uucred -vm_size_t wait4 waitid dirname diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 2b80c6df51344..47c1a0910e3f3 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -7,7 +7,6 @@ pub type fsfilcnt_t = u64; pub type idtype_t = ::c_int; pub type mqd_t = ::c_int; type __pthread_spin_t = __cpu_simple_lock_nv_t; -pub type vm_size_t = ::uintptr_t; // FIXME: deprecated since long time pub type lwpid_t = ::c_uint; pub type shmatt_t = ::c_uint; pub type cpuid_t = ::c_ulong; From bc3a36b4a233320b0b9235426898af8530ced4bf Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Mon, 14 Oct 2024 08:34:05 -0600 Subject: [PATCH 04/14] Add `spawn.h` header to NetBSD tests --- libc-test/build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 743f9f28404db..c03abae788693 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1035,6 +1035,7 @@ fn test_netbsd(target: &str) { "limits.h", "link.h", "locale.h", + "spawn.h", "stddef.h", "stdint.h", "stdio.h", From 0e24e15a35805f33484fb104127b5176b553fbc6 Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Mon, 14 Oct 2024 08:41:31 -0600 Subject: [PATCH 05/14] Fix `sendmmsg`/`recvmmsg` signatures for NetBSD --- src/unix/bsd/netbsdlike/mod.rs | 14 -------------- src/unix/bsd/netbsdlike/netbsd/mod.rs | 13 +++++++++++++ src/unix/bsd/netbsdlike/openbsd/mod.rs | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index 29f54b92cd48b..af38eec669d36 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -852,20 +852,6 @@ extern "C" { pub fn dirname(path: *mut ::c_char) -> *mut ::c_char; pub fn basename(path: *mut ::c_char) -> *mut ::c_char; pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int; - - pub fn sendmmsg( - sockfd: ::c_int, - mmsg: *mut ::mmsghdr, - vlen: ::c_uint, - flags: ::c_int, - ) -> ::c_int; - pub fn recvmmsg( - sockfd: ::c_int, - mmsg: *mut ::mmsghdr, - vlen: ::c_uint, - flags: ::c_int, - timeout: *mut ::timespec, - ) -> ::c_int; } cfg_if! { diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 47c1a0910e3f3..53ad5cde8ba51 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -2865,6 +2865,19 @@ extern "C" { ntargets: ::size_t, hint: *const ::c_void, ) -> ::c_int; + pub fn sendmmsg( + sockfd: ::c_int, + mmsg: *mut ::mmsghdr, + vlen: ::c_uint, + flags: ::c_uint, + ) -> ::c_int; + pub fn recvmmsg( + sockfd: ::c_int, + mmsg: *mut ::mmsghdr, + vlen: ::c_uint, + flags: ::c_uint, + timeout: *mut ::timespec, + ) -> ::c_int; } #[link(name = "rt")] diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 357662547b8e3..5957509aa789c 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -2110,6 +2110,20 @@ extern "C" { pub fn mimmutable(addr: *mut ::c_void, len: ::size_t) -> ::c_int; pub fn reboot(mode: ::c_int) -> ::c_int; + + pub fn sendmmsg( + sockfd: ::c_int, + mmsg: *mut ::mmsghdr, + vlen: ::c_uint, + flags: ::c_int, + ) -> ::c_int; + pub fn recvmmsg( + sockfd: ::c_int, + mmsg: *mut ::mmsghdr, + vlen: ::c_uint, + flags: ::c_int, + timeout: *mut ::timespec, + ) -> ::c_int; } #[link(name = "execinfo")] From f024512a8822726ad3757eccb8b1a53cb269b6ff Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Mon, 14 Oct 2024 08:51:24 -0600 Subject: [PATCH 06/14] Remove opaque _cpuset type --- src/unix/bsd/netbsdlike/netbsd/mod.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 53ad5cde8ba51..03a5ec5e855b5 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -10,7 +10,7 @@ type __pthread_spin_t = __cpu_simple_lock_nv_t; pub type lwpid_t = ::c_uint; pub type shmatt_t = ::c_uint; pub type cpuid_t = ::c_ulong; -pub type cpuset_t = _cpuset; +pub type cpuset_t = ::c_void; pub type pthread_spin_t = ::c_uchar; pub type timer_t = ::c_int; @@ -505,10 +505,6 @@ s! { pub dlpi_tls_data: *mut ::c_void, } - pub struct _cpuset { - bits: [u32; 0] - } - pub struct accept_filter_arg { pub af_name: [::c_char; 16], af_arg: [[::c_char; 10]; 24], From b9c997dec8bcda5d5b103949316c6d19c51f8ede Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Mon, 14 Oct 2024 08:55:40 -0600 Subject: [PATCH 07/14] Fix `kevent` struct for NetBSD 10.0 --- src/unix/bsd/netbsdlike/netbsd/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 03a5ec5e855b5..c7c8642e65f9b 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -285,7 +285,7 @@ s! { pub flags: u32, pub fflags: u32, pub data: i64, - pub udata: ::intptr_t, /* FIXME: NetBSD 10.0 will finally have same layout as other BSD */ + pub udata: *mut ::c_void, } pub struct dqblk { From 4ecd07b89a4de0d05d62068198770f544a705255 Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Mon, 14 Oct 2024 08:59:26 -0600 Subject: [PATCH 08/14] Fix `uucred` field `cr_ngroups` to correctly use short --- src/unix/bsd/netbsdlike/netbsd/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index c7c8642e65f9b..59642483e2450 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -379,7 +379,7 @@ s! { pub cr_unused: ::c_ushort, pub cr_uid: ::uid_t, pub cr_gid: ::gid_t, - pub cr_ngroups: ::c_int, + pub cr_ngroups: ::c_short, pub cr_groups: [::gid_t; NGROUPS_MAX as usize], } From 36e305c2c558f927cb2a21d245f63613a226e91b Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Mon, 14 Oct 2024 09:05:07 -0600 Subject: [PATCH 09/14] Fix `sockaddr_dl` fields to use `dl_addr` struct --- libc-test/semver/netbsd.txt | 1 + src/unix/bsd/netbsdlike/netbsd/mod.rs | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 4696ae4f710c5..423875dbf3f80 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -1229,6 +1229,7 @@ consttime_memequal daemon difftime dirfd +dl_addr dl_iterate_phdr dl_phdr_info dqblk diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 59642483e2450..386044a4ca5f2 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -393,11 +393,15 @@ s! { pub sdl_len: ::c_uchar, pub sdl_family: ::c_uchar, pub sdl_index: ::c_ushort, + pub sdl_addr: ::dl_addr, + } + + pub struct dl_addr { pub sdl_type: u8, pub sdl_nlen: u8, pub sdl_alen: u8, pub sdl_slen: u8, - pub sdl_data: [::c_char; 12], + pub sdl_data: [::c_char; 24], } pub struct __exit_status { From 700d9449286eeb42f152462b8b16b35ccbb450c4 Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Mon, 14 Oct 2024 09:11:34 -0600 Subject: [PATCH 10/14] Fix `utmpx` anonymous struct `ut_exit`; remove opaque `__exit_status` --- libc-test/semver/netbsd.txt | 1 - src/unix/bsd/netbsdlike/netbsd/mod.rs | 12 ++++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 423875dbf3f80..c15fe2eb7c9d2 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -1185,7 +1185,6 @@ _UTX_PADSIZE _UTX_USERSIZE __cpu_simple_lock_nv_t __errno -__exit_status _cpuset_clr _cpuset_create _cpuset_destroy diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 386044a4ca5f2..644f274f985bd 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -404,11 +404,6 @@ s! { pub sdl_data: [::c_char; 24], } - pub struct __exit_status { - pub e_termination: u16, - pub e_exit: u16, - } - pub struct shmid_ds { pub shm_perm: ::ipc_perm, pub shm_segsz: ::size_t, @@ -788,12 +783,17 @@ s_no_extra_traits! { pub ut_session: u16, pub ut_type: u16, pub ut_pid: ::pid_t, - pub ut_exit: __exit_status, // FIXME: when anonymous struct are supported + pub ut_exit: ::__c_anonymous_ut_exit, pub ut_ss: sockaddr_storage, pub ut_tv: ::timeval, pub ut_pad: [u8; _UTX_PADSIZE], } + pub struct __c_anonymous_ut_exit { + pub e_termination: u16, + pub e_exit: u16, + } + pub struct lastlogx { pub ll_tv: ::timeval, pub ll_line: [::c_char; _UTX_LINESIZE], From 1cb25b8d6249c2ad27006eff62ac56c5df9df13f Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Mon, 14 Oct 2024 09:16:13 -0600 Subject: [PATCH 11/14] Add `utmp.h` to NetBSD build --- libc-test/build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index c03abae788693..83bb0635e6165 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1104,6 +1104,7 @@ fn test_netbsd(target: &str) { "unistd.h", "util.h", "utime.h", + "utmp.h", "mqueue.h", "netinet/dccp.h", "sys/event.h", From 4ddff042ad5dfc6623ad3261e797f427e94c26d2 Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Mon, 14 Oct 2024 09:21:21 -0600 Subject: [PATCH 12/14] Remove cpuset_t from NetBSD tests --- libc-test/build.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 83bb0635e6165..28a22d61c8a29 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1152,6 +1152,8 @@ fn test_netbsd(target: &str) { return true; } match ty { + // cpuset_t is an incomplete/opaque type that is only used in the context of pointers + "cpuset_t" => true, // FIXME: sighandler_t is crazy across platforms "sighandler_t" => true, _ => false, From 93a56954fb9cf1c0e01a61a63425d8f87429483c Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Mon, 14 Oct 2024 09:25:23 -0600 Subject: [PATCH 13/14] Remove pthread_spin_t from NetBSD build tests --- libc-test/build.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 28a22d61c8a29..d521a6214e3ba 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1152,6 +1152,8 @@ fn test_netbsd(target: &str) { return true; } match ty { + // pthread_spin_t is a volatile uchar + "pthread_spin_t" => true, // cpuset_t is an incomplete/opaque type that is only used in the context of pointers "cpuset_t" => true, // FIXME: sighandler_t is crazy across platforms From d45bd45eec01bca2dd610c5cfac258c987a61ad3 Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Mon, 14 Oct 2024 09:26:23 -0600 Subject: [PATCH 14/14] Resolve dl_addr name mismatch --- src/unix/bsd/netbsdlike/netbsd/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 644f274f985bd..b3c66a56d577c 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -397,11 +397,11 @@ s! { } pub struct dl_addr { - pub sdl_type: u8, - pub sdl_nlen: u8, - pub sdl_alen: u8, - pub sdl_slen: u8, - pub sdl_data: [::c_char; 24], + pub dl_type: u8, + pub dl_nlen: u8, + pub dl_alen: u8, + pub dl_slen: u8, + pub dl_data: [::c_char; 24], } pub struct shmid_ds {