From 7f86bf8d863622032b83e1514b9ffaa7b3497fcc Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 12 Jan 2025 16:44:26 +0100 Subject: [PATCH 1/8] hurd: Fix CMSG_DATA on 64bit systems This was fixed upstream glibc in https://sourceware.org/git/?p=glibc.git;a=patch;h=cf13f740a91b5bbf6bb60a30b45c2a3933ff1259 (backport ) (cherry picked from commit 3659a6d7de022d90fa20bbb67c10d4624d65a685) --- src/unix/hurd/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index bb5339d0a48bd..0c5f001202844 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -3449,7 +3449,7 @@ f! { } pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - cmsg.offset(1) as *mut c_uchar + (cmsg as *mut c_uchar).offset(CMSG_ALIGN(mem::size_of::()) as isize) } pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { From 8e728d7474f3448dfb69d9fae3ae914d75512f6c Mon Sep 17 00:00:00 2001 From: lvllvl <24905907+lvllvl@users.noreply.github.com> Date: Tue, 7 Jan 2025 23:40:08 +0000 Subject: [PATCH 2/8] chore: add labels for FIXMEs in repo (backport ) (cherry picked from commit 6c6674e2954c1189926f3c8112372263f8e6b730) --- libc-test/build.rs | 38 +++++++++++++++++++------------------- src/fuchsia/mod.rs | 36 ++++++++++++++++++------------------ src/lib.rs | 2 +- src/vxworks/mod.rs | 6 +++--- 4 files changed, 41 insertions(+), 41 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 5c5fd96df21c0..c5c7becebe718 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -268,7 +268,7 @@ fn test_apple(target: &str) { "os/clock.h", "os/lock.h", "os/signpost.h", - // FIXME: Requires the macOS 14.4 SDK. + // FIXME(macos): Requires the macOS 14.4 SDK. //"os/os_sync_wait_on_address.h", "poll.h", "pthread.h", @@ -338,15 +338,15 @@ fn test_apple(target: &str) { return true; } match ty { - // FIXME: actually a union + // FIXME(union): actually a union "sigval" => true, - // FIXME: The size is changed in recent macOSes. + // FIXME(macos): The size is changed in recent macOSes. "malloc_zone_t" => true, // it is a moving target, changing through versions // also contains bitfields members "tcp_connection_info" => true, - // FIXME: The size is changed in recent macOSes. + // FIXME(macos): The size is changed in recent macOSes. "malloc_introspection_t" => true, _ => false, @@ -358,10 +358,10 @@ fn test_apple(target: &str) { return true; } match ty { - // FIXME: Requires the macOS 14.4 SDK. + // FIXME(macos): Requires the macOS 14.4 SDK. "os_sync_wake_by_address_flags_t" | "os_sync_wait_on_address_flags_t" => true, - // FIXME: "'__uint128' undeclared" in C + // FIXME(macos): "'__uint128' undeclared" in C "__uint128" => true, _ => false, @@ -377,13 +377,13 @@ fn test_apple(target: &str) { // These OSX constants are removed in Sierra. // https://developer.apple.com/library/content/releasenotes/General/APIDiffsMacOS10_12/Swift/Darwin.html "KERN_KDENABLE_BG_TRACE" | "KERN_KDDISABLE_BG_TRACE" => true, - // FIXME: the value has been changed since Catalina (0xffff0000 -> 0x3fff0000). + // FIXME(macos): the value has been changed since Catalina (0xffff0000 -> 0x3fff0000). "SF_SETTABLE" => true, - // FIXME: XCode 13.1 doesn't have it. + // FIXME(macos): XCode 13.1 doesn't have it. "TIOCREMOTE" => true, - // FIXME: Requires the macOS 14.4 SDK. + // FIXME(macos): Requires the macOS 14.4 SDK. "OS_SYNC_WAKE_BY_ADDRESS_NONE" | "OS_SYNC_WAKE_BY_ADDRESS_SHARED" | "OS_SYNC_WAIT_ON_ADDRESS_NONE" @@ -402,19 +402,19 @@ fn test_apple(target: &str) { // close calls the close_nocancel system call "close" => true, - // FIXME: std removed libresolv support: https://github.com/rust-lang/rust/pull/102766 + // FIXME(1.0): std removed libresolv support: https://github.com/rust-lang/rust/pull/102766 "res_init" => true, - // FIXME: remove once the target in CI is updated + // FIXME(macos): remove once the target in CI is updated "pthread_jit_write_freeze_callbacks_np" => true, - // FIXME: ABI has been changed on recent macOSes. + // FIXME(macos): ABI has been changed on recent macOSes. "os_unfair_lock_assert_owner" | "os_unfair_lock_assert_not_owner" => true, - // FIXME: Once the SDK get updated to Ventura's level + // FIXME(macos): Once the SDK get updated to Ventura's level "freadlink" | "mknodat" | "mkfifoat" => true, - // FIXME: Requires the macOS 14.4 SDK. + // FIXME(macos): Requires the macOS 14.4 SDK. "os_sync_wake_by_address_any" | "os_sync_wake_by_address_all" | "os_sync_wake_by_address_flags_t" @@ -429,7 +429,7 @@ fn test_apple(target: &str) { cfg.skip_field(move |struct_, field| { match (struct_, field) { - // FIXME: the array size has been changed since macOS 10.15 ([8] -> [7]). + // FIXME(macos): the array size has been changed since macOS 10.15 ([8] -> [7]). ("statfs", "f_reserved") => true, ("__darwin_arm_neon_state64", "__v") => true, // MAXPATHLEN is too big for auto-derive traits on arrays. @@ -447,7 +447,7 @@ fn test_apple(target: &str) { cfg.skip_field_type(move |struct_, field| { match (struct_, field) { - // FIXME: actually a union + // FIXME(union): actually a union ("sigevent", "sigev_value") => true, _ => false, } @@ -481,7 +481,7 @@ fn test_apple(target: &str) { s if s.ends_with("_nsec") && struct_.starts_with("stat") => { s.replace("e_nsec", "espec.tv_nsec") } - // FIXME: sigaction actually contains a union with two variants: + // FIXME(macos): sigaction actually contains a union with two variants: // a sa_sigaction with type: (*)(int, struct __siginfo *, void *) // a sa_handler with type sig_t "sa_sigaction" if struct_ == "sigaction" => "sa_handler".to_string(), @@ -490,7 +490,7 @@ fn test_apple(target: &str) { }); cfg.skip_roundtrip(move |s| match s { - // FIXME: this type has the wrong ABI + // FIXME(macos): this type has the wrong ABI "max_align_t" if i686 => true, // Can't return an array from a C function. "uuid_t" | "vol_capabilities_set_t" => true, @@ -597,7 +597,7 @@ fn test_openbsd(target: &str) { return true; } match ty { - // FIXME: actually a union + // FIXME(union): actually a union "sigval" => true, _ => false, diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 8e56e3f62928d..f0559db9bee55 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -91,7 +91,7 @@ pub type rlim_t = c_ulonglong; pub type c_long = i64; pub type c_ulong = u64; -// FIXME: why are these uninhabited types? that seems... wrong? +// FIXME(fuchsia): why are these uninhabited types? that seems... wrong? // Presumably these should be `()` or an `extern type` (when that stabilizes). #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} @@ -111,7 +111,7 @@ impl Clone for DIR { } #[cfg_attr(feature = "extra_traits", derive(Debug))] -pub enum fpos64_t {} // FIXME: fill this out with a struct +pub enum fpos64_t {} // FIXME(fuchsia): fill this out with a struct impl Copy for fpos64_t {} impl Clone for fpos64_t { fn clone(&self) -> fpos64_t { @@ -144,7 +144,7 @@ s! { pub tv_nsec: c_long, } - // FIXME: the rlimit and rusage related functions and types don't exist + // FIXME(fuchsia): the rlimit and rusage related functions and types don't exist // within zircon. Are there reasons for keeping them around? pub struct rlimit { pub rlim_cur: rlim_t, @@ -478,7 +478,7 @@ s! { pub ifa_flags: c_uint, pub ifa_addr: *mut crate::sockaddr, pub ifa_netmask: *mut crate::sockaddr, - pub ifa_ifu: *mut crate::sockaddr, // FIXME This should be a union + pub ifa_ifu: *mut crate::sockaddr, // FIXME(union) This should be a union pub ifa_data: *mut c_void, } @@ -1097,7 +1097,7 @@ cfg_if! { .field("totalhigh", &self.totalhigh) .field("freehigh", &self.freehigh) .field("mem_unit", &self.mem_unit) - // FIXME: .field("__reserved", &self.__reserved) + // FIXME(debug): .field("__reserved", &self.__reserved) .finish() } } @@ -1135,7 +1135,7 @@ cfg_if! { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("sockaddr_un") .field("sun_family", &self.sun_family) - // FIXME: .field("sun_path", &self.sun_path) + // FIXME(debug): .field("sun_path", &self.sun_path) .finish() } } @@ -1163,7 +1163,7 @@ cfg_if! { f.debug_struct("sockaddr_storage") .field("ss_family", &self.ss_family) .field("__ss_align", &self.__ss_align) - // FIXME: .field("__ss_pad2", &self.__ss_pad2) + // FIXME(debug): .field("__ss_pad2", &self.__ss_pad2) .finish() } } @@ -1207,11 +1207,11 @@ cfg_if! { impl fmt::Debug for utsname { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("utsname") - // FIXME: .field("sysname", &self.sysname) - // FIXME: .field("nodename", &self.nodename) - // FIXME: .field("release", &self.release) - // FIXME: .field("version", &self.version) - // FIXME: .field("machine", &self.machine) + // FIXME(debug): .field("sysname", &self.sysname) + // FIXME(debug): .field("nodename", &self.nodename) + // FIXME(debug): .field("release", &self.release) + // FIXME(debug): .field("version", &self.version) + // FIXME(debug): .field("machine", &self.machine) .finish() } } @@ -1246,7 +1246,7 @@ cfg_if! { .field("d_off", &self.d_off) .field("d_reclen", &self.d_reclen) .field("d_type", &self.d_type) - // FIXME: .field("d_name", &self.d_name) + // FIXME(debug): .field("d_name", &self.d_name) .finish() } } @@ -1281,7 +1281,7 @@ cfg_if! { .field("d_off", &self.d_off) .field("d_reclen", &self.d_reclen) .field("d_type", &self.d_type) - // FIXME: .field("d_name", &self.d_name) + // FIXME(debug): .field("d_name", &self.d_name) .finish() } } @@ -1390,7 +1390,7 @@ cfg_if! { impl fmt::Debug for pthread_cond_t { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("pthread_cond_t") - // FIXME: .field("size", &self.size) + // FIXME(debug): .field("size", &self.size) .finish() } } @@ -1409,7 +1409,7 @@ cfg_if! { impl fmt::Debug for pthread_mutex_t { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("pthread_mutex_t") - // FIXME: .field("size", &self.size) + // FIXME(debug): .field("size", &self.size) .finish() } } @@ -1428,7 +1428,7 @@ cfg_if! { impl fmt::Debug for pthread_rwlock_t { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("pthread_rwlock_t") - // FIXME: .field("size", &self.size) + // FIXME(debug): .field("size", &self.size) .finish() } } @@ -3562,7 +3562,7 @@ impl Clone for FILE { } } #[cfg_attr(feature = "extra_traits", derive(Debug))] -pub enum fpos_t {} // FIXME: fill this out with a struct +pub enum fpos_t {} // FIXME(fuchsia): fill this out with a struct impl Copy for fpos_t {} impl Clone for fpos_t { fn clone(&self) -> fpos_t { diff --git a/src/lib.rs b/src/lib.rs index c1cdc7f1bc4eb..060c4c1b39cdd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,7 +12,7 @@ redundant_semicolons, unused_macros, unused_macro_rules, - // FIXME: temporarily allow dead_code to fix CI: + // FIXME(1.0): temporarily allow dead_code to fix CI: // - https://github.com/rust-lang/libc/issues/3740 // - https://github.com/rust-lang/rust/pull/126456 dead_code, diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index b8faf16e9aa13..e7ec43ab5e430 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -562,7 +562,7 @@ pub const EAI_SERVICE: c_int = 9; pub const EAI_SOCKTYPE: c_int = 10; pub const EAI_SYSTEM: c_int = 11; -// FIXME: This is not defined in vxWorks, but we have to define it here +// FIXME(vxworks): This is not defined in vxWorks, but we have to define it here // to make the building pass for getrandom and std pub const RTLD_DEFAULT: *mut c_void = 0i64 as *mut c_void; @@ -725,7 +725,7 @@ pub const S_taskLib_TASK_HOOK_TABLE_FULL: c_int = taskErrorBase + 0x0066; pub const S_taskLib_TASK_HOOK_NOT_FOUND: c_int = taskErrorBase + 0x0067; pub const S_taskLib_ILLEGAL_PRIORITY: c_int = taskErrorBase + 0x0068; -// FIXME: could also be useful for TASK_DESC type +// FIXME(vxworks): could also be useful for TASK_DESC type pub const VX_TASK_NAME_LENGTH: c_int = 31; // semLibCommon.h @@ -1066,7 +1066,7 @@ impl Clone for FILE { } } #[cfg_attr(feature = "extra_traits", derive(Debug))] -pub enum fpos_t {} // FIXME: fill this out with a struct +pub enum fpos_t {} // FIXME(vxworks): fill this out with a struct impl Copy for fpos_t {} impl Clone for fpos_t { fn clone(&self) -> fpos_t { From 608f947befc9a1194c0bcf03dca378abe4ab746c Mon Sep 17 00:00:00 2001 From: xd009642 Date: Thu, 6 Feb 2025 16:13:48 +0900 Subject: [PATCH 3/8] Adds in SI and TRAP signal codes Impacts linux and android adding in (when applicable): * SI_ASYNCIO * SI_ASYNCNL * SI_DETHREAD * SI_KERNEL * SI_MESGQ * SI_QUEUE * SI_SIGIO * SI_TIMER * SI_TKILL * SI_USER And also: * TRAP_BRANCH * TRAP_BRKPT * TRAP_HWBKPT * TRAP_PERF * TRAP_TRACE * TRAP_UNK (backport ) (cherry picked from commit a34697a1fde98a4898d88217144d2e68cecce57c) --- libc-test/build.rs | 6 ++++++ libc-test/semver/linux.txt | 16 ++++++++++++++++ src/unix/linux_like/android/mod.rs | 4 ++++ src/unix/linux_like/linux/mod.rs | 4 ++++ src/unix/linux_like/mod.rs | 18 ++++++++++++++++++ 5 files changed, 48 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index c5c7becebe718..447462569a55b 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3065,6 +3065,9 @@ fn test_emscripten(target: &str) { // https://github.com/emscripten-core/emscripten/pull/14883 "SIG_IGN" => true, + // Constants present in other linuxes but not emscripten + "SI_DETHREAD" | "TRAP_PERF" => true, + // LFS64 types have been removed in Emscripten 3.1.44 // https://github.com/emscripten-core/emscripten/pull/19812 n if n.starts_with("RLIM64") => true, @@ -4130,6 +4133,9 @@ fn test_linux(target: &str) { // FIXME: Not currently available in headers on ARM and musl. "NETLINK_GET_STRICT_CHK" if arm => true, + // Skip as this signal codes and trap reasons need newer headers + "SI_DETHREAD" | "TRAP_PERF" => true, + // kernel constants not available in uclibc 1.0.34 | "EXTPROC" | "IPPROTO_BEETPH" diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 175e2811e9649..d2193b870516f 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -2879,7 +2879,17 @@ SIOCSMIIREG SIOCSRARP SIOCWANDEV SIOGIFINDEX +SI_ASYNCIO +SI_ASYNCNL +SI_DETHREAD +SI_KERNEL SI_LOAD_SHIFT +SI_MESGQ +SI_QUEUE +SI_SIGIO +SI_TIMER +SI_TKILL +SI_USER SND_CNT SND_MAX SOCK_CLOEXEC @@ -3359,6 +3369,12 @@ TP_STATUS_USER TP_STATUS_VLAN_TPID_VALID TP_STATUS_VLAN_VALID TP_STATUS_WRONG_FORMAT +TRAP_BRANCH +TRAP_BRKPT +TRAP_HWBKPT +TRAP_PERF +TRAP_TRACE +TRAP_UNK TUNATTACHFILTER TUNDETACHFILTER TUNGETFEATURES diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index b12120bb564d4..0e1b05aa5cf72 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -3568,6 +3568,10 @@ pub const AT_RSEQ_ALIGN: c_ulong = 28; pub const AT_EXECFN: c_ulong = 31; pub const AT_MINSIGSTKSZ: c_ulong = 51; +// siginfo.h +pub const SI_DETHREAD: c_int = -7; +pub const TRAP_PERF: c_int = 6; + // Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the // following are only available on newer Linux versions than the versions // currently used in CI in some configurations, so we define them here. diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 0439493375949..88d39c6316a40 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -5725,6 +5725,10 @@ pub const EPIOCGPARAMS: Ioctl = 0x80088a02; const _IOC_NRBITS: u32 = 8; const _IOC_TYPEBITS: u32 = 8; +// siginfo.h +pub const SI_DETHREAD: c_int = -7; +pub const TRAP_PERF: c_int = 6; + // https://github.com/search?q=repo%3Atorvalds%2Flinux+%22%23define+_IOC_NONE%22&type=code cfg_if! { if #[cfg(any( diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 5b6325e8ca822..c7ff2aea96e79 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1289,6 +1289,17 @@ pub const PIPE_BUF: usize = 4096; pub const SI_LOAD_SHIFT: c_uint = 16; +// si_code values +pub const SI_USER: c_int = 0; +pub const SI_KERNEL: c_int = 0x80; +pub const SI_QUEUE: c_int = -1; +pub const SI_TIMER: c_int = -2; +pub const SI_MESGQ: c_int = -3; +pub const SI_ASYNCIO: c_int = -4; +pub const SI_SIGIO: c_int = -5; +pub const SI_TKILL: c_int = -6; +pub const SI_ASYNCNL: c_int = -60; + // si_code values for SIGBUS signal pub const BUS_ADRALN: c_int = 1; pub const BUS_ADRERR: c_int = 2; @@ -1297,6 +1308,13 @@ pub const BUS_OBJERR: c_int = 3; pub const BUS_MCEERR_AR: c_int = 4; pub const BUS_MCEERR_AO: c_int = 5; +// si_code values for SIGTRAP +pub const TRAP_BRKPT: c_int = 1; +pub const TRAP_TRACE: c_int = 2; +pub const TRAP_BRANCH: c_int = 3; +pub const TRAP_HWBKPT: c_int = 4; +pub const TRAP_UNK: c_int = 5; + // si_code values for SIGCHLD signal pub const CLD_EXITED: c_int = 1; pub const CLD_KILLED: c_int = 2; From e7a9c4a7bb28339f57ac519f8449394d79a0910a Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Tue, 14 Jan 2025 10:40:10 +0100 Subject: [PATCH 4/8] emscripten: Assume version is at least 3.1.42 This revises commit 63b0d673eaf2a177ff208c5c50999738bdd1bf0d to assume that Emscripten 3.1.42 or later is being used whenever `emcc` is not available. Since Emscripten 3.1.42 was released on June 23, 2023, the majority of users are expected to have upgraded to a more recent version. Resolves: https://github.com/rust-lang/rust/issues/131467. (backport ) (cherry picked from commit b511f66635f8d8060c5b4ed0eb605ac8973005c5) --- build.rs | 8 ++++---- src/unix/linux_like/emscripten/mod.rs | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build.rs b/build.rs index 90fbc0d7c5fda..5f401f9f1072e 100644 --- a/build.rs +++ b/build.rs @@ -5,7 +5,7 @@ use std::{env, str}; // need to know all the possible cfgs that this script will set. If you need to set another cfg // make sure to add it to this list as well. const ALLOWED_CFGS: &'static [&'static str] = &[ - "emscripten_new_stat_abi", + "emscripten_old_stat_abi", "espidf_time32", "freebsd10", "freebsd11", @@ -74,9 +74,9 @@ fn main() { } match emcc_version_code() { - Some(v) if (v >= 30142) => set_cfg("emscripten_new_stat_abi"), - // Non-Emscripten or version < 3.1.42. - Some(_) | None => (), + Some(v) if (v < 30142) => set_cfg("emscripten_old_stat_abi"), + // Non-Emscripten or version >= 3.1.42. + _ => (), } // On CI: deny all warnings diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 94b3776606a41..c1c5108c17eb4 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -227,16 +227,16 @@ s! { } pub struct stat { pub st_dev: crate::dev_t, - #[cfg(not(emscripten_new_stat_abi))] + #[cfg(emscripten_old_stat_abi)] __st_dev_padding: c_int, - #[cfg(not(emscripten_new_stat_abi))] + #[cfg(emscripten_old_stat_abi)] __st_ino_truncated: c_long, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - #[cfg(not(emscripten_new_stat_abi))] + #[cfg(emscripten_old_stat_abi)] __st_rdev_padding: c_int, pub st_size: off_t, pub st_blksize: crate::blksize_t, From 5e6b350a0daa450e1e6b580f8f59169879bc722d Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Mon, 27 Jan 2025 10:25:23 +0100 Subject: [PATCH 5/8] emscripten: Fix broken link (backport ) (cherry picked from commit 99515f2058400fbd07156f3b5907b9285c5b5f7a) --- ci/emscripten.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/emscripten.sh b/ci/emscripten.sh index 0a4112e7e205e..e2f41937ddfc0 100755 --- a/ci/emscripten.sh +++ b/ci/emscripten.sh @@ -3,7 +3,7 @@ set -eux # Note: keep in sync with: -# https://github.com/rust-lang/rust/blob/master/src/ci/docker/scripts/emscripten.sh +# https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support/wasm32-unknown-emscripten.md#requirements emsdk_version=3.1.68 git clone https://github.com/emscripten-core/emsdk.git /emsdk-portable From 81c931f950d48e72da8cbdd75e2bae6f7b9f9bb9 Mon Sep 17 00:00:00 2001 From: Mohamed Attia Date: Thu, 13 Feb 2025 23:58:08 +0100 Subject: [PATCH 6/8] Fix reference to build file with guaranteed build platforms. (backport ) (cherry picked from commit 728a5e2ba3ae519347145d206e8aff2de5c8751a) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 901a776e24f20..c616d8b29f52b 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ but this is not guaranteed. You can see the platform(target)-specific docs on [docs.rs], select a platform you want to see. -See [`ci/build.sh`](https://github.com/rust-lang/libc/blob/HEAD/ci/build.sh) for +See [`ci/verify-build.sh`](https://github.com/rust-lang/libc/blob/HEAD/ci/verify-build.sh) for the platforms on which `libc` is guaranteed to build for each Rust toolchain. The test-matrix at [GitHub Actions] and [Cirrus CI] show the platforms in which `libc` tests are run. From e943c9823fa5012a42b2dfd6510dbaa982492256 Mon Sep 17 00:00:00 2001 From: Rain Date: Tue, 11 Feb 2025 23:22:09 +0000 Subject: [PATCH 7/8] [solarish/illumos] add the posix_spawn family of functions Add definitions from `spawn.h` as present [in illumos-gate (blame view)][spawn-h]. I added definitions more than 15 years old to `solarish/mod.rs`, and others to `solarish/illumos.rs`. There are a lot of definitions here -- it's easiest to look at them in the blame view linked above. But here are the corresponding man pages: For solarish: * [`posix_spawn`, `posix_spawnp`](https://illumos.org/man/3C/posix_spawn) * [`posix_spawn_file_actions_{init,destroy}`](https://illumos.org/man/3C/posix_spawn_file_actions_init) * [`posix_spawn_file_actions_{addopen,addclose}`](https://illumos.org/man/3C/posix_spawn_file_actions_addopen) * [`posix_spawn_file_actions_adddup2`](https://illumos.org/man/3C/posix_spawn_file_actions_adddup2) * [`posix_spawn_file_actions_addclosefrom_np`](https://illumos.org/man/3C/posix_spawn_file_actions_addclosefrom_np) * [`posix_spawnattr_{init,destroy}`](https://illumos.org/man/3C/posix_spawnattr_init) * [`posix_spawnattr_{setflags,getflags}`](https://illumos.org/man/3C/posix_spawnattr_setflags) * [`posix_spawnattr_{setpgroup,getpgroup}`](https://illumos.org/man/3C/posix_spawnattr_setpgroup) * [`posix_spawnattr_{setschedparam,getschedparam}`](https://illumos.org/man/3C/posix_spawnattr_setschedparam) * [`posix_spawnattr_{setschedpolicy,getschedpolicy}`](https://illumos.org/man/3C/posix_spawnattr_setschedpolicy) * [`posix_spawnattr_{setsigdefault,getsigdefault}`](https://illumos.org/man/3C/posix_spawnattr_setsigdefault) * [`posix_spawnattr_{setsigignore,getsigignore}_np`](https://illumos.org/man/3C/posix_spawnattr_setsigignore_np) * [`posix_spawnattr_{setsigmask,getsigmask}`](https://illumos.org/man/3C/posix_spawnattr_setsigmask) Newer functions added independently to Solaris and illumos: * [`posix_spawn_file_actions_{addchdir,addchdir_np,addfchdir}` on Solaris](https://docs.oracle.com/cd/E88353_01/html/E37843/posix-spawn-file-actions-addchdir-np-3c.html) * The illumos-only functions are quite recent so the man pages haven't been uploaded to illumos.org yet. But [here's the one for `addchdir` and `addfchdir`](https://github.com/illumos/illumos-gate/blob/7633a05bff8c639f2df722d1fba7b889b2763d3d/usr/src/man/man3c/posix_spawn_file_actions_addchdir.3c). Note that the `_np` functions are not documented in the manual, but they are available for compatibility. The one function I skipped over was [`posix_spawn_pipe_np`](https://illumos.org/man/3C/posix_spawn_pipe_np) -- it seemed a bit niche and I wasn't quite sure how to model `boolean_t`. [spawn-h]: https://github.com/illumos/illumos-gate/blame/7633a05bff8c639f2df722d1fba7b889b2763d3d/usr/src/head/spawn.h#L1 (backport ) (cherry picked from commit 162e3064659bbcfa857e606f47cbe90874cb6001) --- libc-test/build.rs | 1 + libc-test/semver/illumos.txt | 2 + libc-test/semver/solarish.txt | 37 +++++++++++ src/unix/solarish/illumos.rs | 7 +++ src/unix/solarish/mod.rs | 114 ++++++++++++++++++++++++++++++++++ src/unix/solarish/solaris.rs | 2 + 6 files changed, 163 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 447462569a55b..eb41e2eaa7ac8 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -915,6 +915,7 @@ fn test_solarish(target: &str) { "sched.h", "semaphore.h", "signal.h", + "spawn.h", "stddef.h", "stdint.h", "stdio.h", diff --git a/libc-test/semver/illumos.txt b/libc-test/semver/illumos.txt index 433a6a1816240..b39aba51d1b5f 100644 --- a/libc-test/semver/illumos.txt +++ b/libc-test/semver/illumos.txt @@ -14,8 +14,10 @@ POSIX_FADV_NORMAL POSIX_FADV_RANDOM POSIX_FADV_SEQUENTIAL POSIX_FADV_WILLNEED +POSIX_SPAWN_SETSID posix_fadvise posix_fallocate +posix_spawn_file_actions_addfchdir_np pthread_attr_get_np pthread_attr_getstackaddr pthread_attr_setstack diff --git a/libc-test/semver/solarish.txt b/libc-test/semver/solarish.txt index f6bb5be4e5aca..f8380fd02936b 100644 --- a/libc-test/semver/solarish.txt +++ b/libc-test/semver/solarish.txt @@ -15,6 +15,16 @@ LIO_READ LIO_WAIT LIO_WRITE PIPE_BUF +POSIX_SPAWN_NOEXECERR_NP +POSIX_SPAWN_NOSIGCHLD_NP +POSIX_SPAWN_RESETIDS +POSIX_SPAWN_SETPGROUP +POSIX_SPAWN_SETSCHEDPARAM +POSIX_SPAWN_SETSCHEDULER +POSIX_SPAWN_SETSIGDEF +POSIX_SPAWN_SETSIGIGN_NP +POSIX_SPAWN_SETSIGMASK +POSIX_SPAWN_WAITPID_NP SIGEV_PORT SIGRTMAX SIGRTMIN @@ -34,5 +44,32 @@ bind in6_pktinfo in_pktinfo lio_listio +posix_spawn +posix_spawn_file_actions_addchdir +posix_spawn_file_actions_addchdir_np +posix_spawn_file_actions_addclose +posix_spawn_file_actions_addclosefrom_np +posix_spawn_file_actions_adddup2 +posix_spawn_file_actions_addfchdir +posix_spawn_file_actions_addopen +posix_spawn_file_actions_destroy +posix_spawn_file_actions_init +posix_spawnattr_destroy +posix_spawnattr_getflags +posix_spawnattr_getpgroup +posix_spawnattr_getschedparam +posix_spawnattr_getschedpolicy +posix_spawnattr_getsigdefault +posix_spawnattr_getsigignore_np +posix_spawnattr_getsigmask +posix_spawnattr_init +posix_spawnattr_setflags +posix_spawnattr_setpgroup +posix_spawnattr_setschedparam +posix_spawnattr_setschedpolicy +posix_spawnattr_setsigdefault +posix_spawnattr_setsigignore_np +posix_spawnattr_setsigmask +posix_spawnp recvmsg sendmsg diff --git a/src/unix/solarish/illumos.rs b/src/unix/solarish/illumos.rs index a1adae00dcc12..caa3f27b3cb35 100644 --- a/src/unix/solarish/illumos.rs +++ b/src/unix/solarish/illumos.rs @@ -205,6 +205,8 @@ pub const POSIX_FADV_WILLNEED: c_int = 3; pub const POSIX_FADV_DONTNEED: c_int = 4; pub const POSIX_FADV_NOREUSE: c_int = 5; +pub const POSIX_SPAWN_SETSID: c_short = 0x40; + pub const SIGINFO: c_int = 41; pub const O_DIRECT: c_int = 0x2000000; @@ -335,6 +337,11 @@ extern "C" { pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; pub fn getpagesizes2(pagesize: *mut size_t, nelem: c_int) -> c_int; + pub fn posix_spawn_file_actions_addfchdir_np( + file_actions: *mut crate::posix_spawn_file_actions_t, + fd: c_int, + ) -> c_int; + pub fn ptsname_r(fildes: c_int, name: *mut c_char, namelen: size_t) -> c_int; pub fn syncfs(fd: c_int) -> c_int; diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 9def117803e52..25913377e4a17 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -56,6 +56,9 @@ pub type lgrp_lat_between_t = c_uint; pub type lgrp_mem_size_flag_t = c_uint; pub type lgrp_view_t = c_uint; +pub type posix_spawnattr_t = *mut c_void; +pub type posix_spawn_file_actions_t = *mut c_void; + #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} impl Copy for timezone {} @@ -1543,6 +1546,17 @@ pub const POSIX_MADV_SEQUENTIAL: c_int = 2; pub const POSIX_MADV_WILLNEED: c_int = 3; pub const POSIX_MADV_DONTNEED: c_int = 4; +pub const POSIX_SPAWN_RESETIDS: c_short = 0x1; +pub const POSIX_SPAWN_SETPGROUP: c_short = 0x2; +pub const POSIX_SPAWN_SETSIGDEF: c_short = 0x4; +pub const POSIX_SPAWN_SETSIGMASK: c_short = 0x8; +pub const POSIX_SPAWN_SETSCHEDPARAM: c_short = 0x10; +pub const POSIX_SPAWN_SETSCHEDULER: c_short = 0x20; +pub const POSIX_SPAWN_SETSIGIGN_NP: c_short = 0x800; +pub const POSIX_SPAWN_NOSIGCHLD_NP: c_short = 0x1000; +pub const POSIX_SPAWN_WAITPID_NP: c_short = 0x2000; +pub const POSIX_SPAWN_NOEXECERR_NP: c_short = 0x4000; + pub const PTHREAD_CREATE_JOINABLE: c_int = 0; pub const PTHREAD_CREATE_DETACHED: c_int = 0x40; pub const PTHREAD_PROCESS_SHARED: c_int = 1; @@ -2688,6 +2702,106 @@ extern "C" { pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; + pub fn posix_spawn( + pid: *mut crate::pid_t, + path: *const c_char, + file_actions: *const posix_spawn_file_actions_t, + attrp: *const posix_spawnattr_t, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int; + pub fn posix_spawnp( + pid: *mut crate::pid_t, + file: *const c_char, + file_actions: *const posix_spawn_file_actions_t, + attrp: *const posix_spawnattr_t, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int; + + pub fn posix_spawn_file_actions_init(file_actions: *mut posix_spawn_file_actions_t) -> c_int; + pub fn posix_spawn_file_actions_destroy(file_actions: *mut posix_spawn_file_actions_t) + -> c_int; + pub fn posix_spawn_file_actions_addopen( + file_actions: *mut posix_spawn_file_actions_t, + fildes: c_int, + path: *const c_char, + oflag: c_int, + mode: crate::mode_t, + ) -> c_int; + pub fn posix_spawn_file_actions_addclose( + file_actions: *mut posix_spawn_file_actions_t, + fildes: c_int, + ) -> c_int; + pub fn posix_spawn_file_actions_adddup2( + file_actions: *mut posix_spawn_file_actions_t, + fildes: c_int, + newfildes: c_int, + ) -> c_int; + pub fn posix_spawn_file_actions_addclosefrom_np( + file_actions: *mut posix_spawn_file_actions_t, + lowfiledes: c_int, + ) -> c_int; + pub fn posix_spawn_file_actions_addchdir( + file_actions: *mut posix_spawn_file_actions_t, + path: *const c_char, + ) -> c_int; + pub fn posix_spawn_file_actions_addchdir_np( + file_actions: *mut posix_spawn_file_actions_t, + path: *const c_char, + ) -> c_int; + pub fn posix_spawn_file_actions_addfchdir( + file_actions: *mut posix_spawn_file_actions_t, + fd: c_int, + ) -> c_int; + + pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> c_int; + pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> c_int; + pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: c_short) -> c_int; + pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *mut c_short) -> c_int; + pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, pgroup: crate::pid_t) -> c_int; + pub fn posix_spawnattr_getpgroup( + attr: *const posix_spawnattr_t, + _pgroup: *mut crate::pid_t, + ) -> c_int; + pub fn posix_spawnattr_setschedparam( + attr: *mut posix_spawnattr_t, + param: *const crate::sched_param, + ) -> c_int; + pub fn posix_spawnattr_getschedparam( + attr: *const posix_spawnattr_t, + param: *mut crate::sched_param, + ) -> c_int; + pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, policy: c_int) -> c_int; + pub fn posix_spawnattr_getschedpolicy( + attr: *const posix_spawnattr_t, + _policy: *mut c_int, + ) -> c_int; + pub fn posix_spawnattr_setsigdefault( + attr: *mut posix_spawnattr_t, + sigdefault: *const sigset_t, + ) -> c_int; + pub fn posix_spawnattr_getsigdefault( + attr: *const posix_spawnattr_t, + sigdefault: *mut sigset_t, + ) -> c_int; + pub fn posix_spawnattr_setsigignore_np( + attr: *mut posix_spawnattr_t, + sigignore: *const sigset_t, + ) -> c_int; + pub fn posix_spawnattr_getsigignore_np( + attr: *const posix_spawnattr_t, + sigignore: *mut sigset_t, + ) -> c_int; + pub fn posix_spawnattr_setsigmask( + attr: *mut posix_spawnattr_t, + sigmask: *const sigset_t, + ) -> c_int; + pub fn posix_spawnattr_getsigmask( + attr: *const posix_spawnattr_t, + sigmask: *mut sigset_t, + ) -> c_int; + pub fn shmat(shmid: c_int, shmaddr: *const c_void, shmflg: c_int) -> *mut c_void; pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int; diff --git a/src/unix/solarish/solaris.rs b/src/unix/solarish/solaris.rs index d080e6ce8d7f6..d0304082dac8b 100644 --- a/src/unix/solarish/solaris.rs +++ b/src/unix/solarish/solaris.rs @@ -189,6 +189,8 @@ pub const PRIV_TPD_UNSAFE: c_uint = 0x0800; pub const PRIV_PROC_TPD_RESET: c_uint = 0x1000; pub const PRIV_TPD_KILLABLE: c_uint = 0x2000; +pub const POSIX_SPAWN_SETSID: c_short = 0x400; + pub const PRIV_USER: c_uint = PRIV_DEBUG | PRIV_PROC_SENSITIVE | NET_MAC_AWARE From 5553e180f295460a9aa6284fbef7b5321742be7b Mon Sep 17 00:00:00 2001 From: Thomas Klausner Date: Fri, 14 Feb 2025 11:34:50 +0100 Subject: [PATCH 8/8] NetBSD: fix getmntinfo for NetBSD (backport ) (cherry picked from commit e1e9d97c1340e037469fb2dc3ae1d3a309b1c9c7) --- 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 8e3507fc743a8..fe2b667a523fc 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -2849,7 +2849,7 @@ extern "C" { ntargets: size_t, hint: *const c_void, ) -> c_int; - + #[link_name = "__getmntinfo13"] pub fn getmntinfo(mntbufp: *mut *mut crate::statvfs, flags: c_int) -> c_int; pub fn getvfsstat(buf: *mut statvfs, bufsize: size_t, flags: c_int) -> c_int; }