From 3e825311dc999a3f2da67ca1afe47309d3d73950 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Thu, 7 Nov 2024 10:48:06 +0100 Subject: [PATCH] emscripten: Upgrade emsdk to 3.1.68 In line with commit rust-lang/rust@2c38ecfc9077000db7de14bf501fa5294eeecedd. Notable changes: - `time_t` changed to 64-bit. emscripten-core/emscripten@c8857a6152c3954014d2aefb706471ee4c80fe30 --- ci/emscripten.sh | 6 +-- libc-test/build.rs | 55 ++++++--------------------- src/unix/linux_like/emscripten/mod.rs | 26 +++++-------- 3 files changed, 25 insertions(+), 62 deletions(-) diff --git a/ci/emscripten.sh b/ci/emscripten.sh index 44da97c93ee68..b99d2cfbe5397 100644 --- a/ci/emscripten.sh +++ b/ci/emscripten.sh @@ -2,9 +2,9 @@ set -ex -# FIXME: 3.1.21 removed a lot of header files (https://github.com/emscripten-core/emscripten/pull/17704). -# We have to tweak libc-test (and deprecate unsupported items, maybe) when updating emsdk. -EMSDK_VERSION=3.1.20 +# Note: keep in sync with: +# https://github.com/rust-lang/rust/blob/master/src/ci/docker/scripts/emscripten.sh +EMSDK_VERSION=3.1.68 git clone https://github.com/emscripten-core/emsdk.git /emsdk-portable cd /emsdk-portable diff --git a/libc-test/build.rs b/libc-test/build.rs index 6efbbf2bb2ce9..48f952f9f7c83 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2819,7 +2819,7 @@ fn test_emscripten(target: &str) { // Just pass all these through, no need for a "struct" prefix "FILE" | "fd_set" | "Dl_info" | "DIR" => ty.to_string(), - // LFS64 types have been removed in Emscripten 3.1.44+ + // LFS64 types have been removed in Emscripten 3.1.44 // https://github.com/emscripten-core/emscripten/pull/19812 "off64_t" => "off_t".to_string(), @@ -2843,7 +2843,7 @@ fn test_emscripten(target: &str) { s if s.ends_with("_nsec") && struct_.starts_with("stat") => { s.replace("e_nsec", ".tv_nsec") } - // FIXME: appears that `epoll_event.data` is an union + // Rust struct uses raw u64, rather than union "u64" if struct_ == "epoll_event" => "data.u64".to_string(), s => s.to_string(), } @@ -2859,10 +2859,7 @@ fn test_emscripten(target: &str) { // https://github.com/emscripten-core/emscripten/issues/5033 ty if ty.starts_with("epoll") => true, - // FIXME: The size has been changed due to musl's time64 - "time_t" => true, - - // LFS64 types have been removed in Emscripten 3.1.44+ + // LFS64 types have been removed in Emscripten 3.1.44 // https://github.com/emscripten-core/emscripten/pull/19812 t => t.ends_with("64") || t.ends_with("64_t"), } @@ -2871,30 +2868,19 @@ fn test_emscripten(target: &str) { cfg.skip_struct(move |ty| { match ty { // This is actually a union, not a struct - // FIXME: is this necessary? "sigval" => true, - // FIXME: It was removed in - // emscripten-core/emscripten@953e414 - "pthread_mutexattr_t" => true, - // FIXME: Investigate why the test fails. // Skip for now to unblock CI. "pthread_condattr_t" => true, - - // FIXME: The size has been changed when upgraded to musl 1.2.2 - "pthread_mutex_t" => true, + "pthread_mutexattr_t" => true, // No epoll support // https://github.com/emscripten-core/emscripten/issues/5033 ty if ty.starts_with("epoll") => true, ty if ty.starts_with("signalfd") => true, - // FIXME: The size has been changed due to time64 - "utimbuf" | "timeval" | "timespec" | "rusage" | "itimerval" | "sched_param" - | "stat" | "stat64" | "shmid_ds" | "msqid_ds" => true, - - // LFS64 types have been removed in Emscripten 3.1.44+ + // LFS64 types have been removed in Emscripten 3.1.44 // https://github.com/emscripten-core/emscripten/pull/19812 ty => ty.ends_with("64") || ty.ends_with("64_t"), } @@ -2903,12 +2889,9 @@ fn test_emscripten(target: &str) { cfg.skip_fn(move |name| { match name { // Emscripten does not support fork/exec/wait or any kind of multi-process support - // https://github.com/emscripten-core/emscripten/blob/3.1.30/tools/system_libs.py#L973 + // https://github.com/emscripten-core/emscripten/blob/3.1.68/tools/system_libs.py#L1100 "execv" | "execve" | "execvp" | "execvpe" | "fexecve" | "wait4" => true, - // FIXME: Remove after emscripten-core/emscripten#18492 is released (> 3.1.30). - "clearenv" => true, - _ => false, } }); @@ -2936,8 +2919,8 @@ fn test_emscripten(target: &str) { "USRQUOTA" | "GRPQUOTA" | "Q_GETFMT" | "Q_GETINFO" | "Q_SETINFO" | "Q_SYNC" | "Q_QUOTAON" | "Q_QUOTAOFF" | "Q_GETQUOTA" | "Q_SETQUOTA" => true, - // FIXME: `SYS_gettid` was removed in - // emscripten-core/emscripten@6d6474e + // `SYS_gettid` was removed in Emscripten v1.39.9 + // https://github.com/emscripten-core/emscripten/pull/10439 "SYS_gettid" => true, // No personality.h @@ -2946,19 +2929,11 @@ fn test_emscripten(target: &str) { | "ADDR_LIMIT_32BIT" | "SHORT_INODE" | "WHOLE_SECONDS" | "STICKY_TIMEOUTS" | "ADDR_LIMIT_3GB" => true, - // FIXME: These values have been changed - | "POSIX_MADV_DONTNEED" // to 4 - | "RLIMIT_NLIMITS" // to 16 - | "RLIM_NLIMITS" // to 16 - | "IPPROTO_MAX" // to 263 - | "F_GETLK" // to 5 - | "F_SETLK" // to 6 - | "F_SETLKW" // to 7 - | "O_TMPFILE" // to 65 - | "SIG_IGN" // -1 - => true, + // `SIG_IGN` has been changed to -2 since 1 is a valid function address + // https://github.com/emscripten-core/emscripten/pull/14883 + "SIG_IGN" => true, - // LFS64 types have been removed in Emscripten 3.1.44+ + // 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, @@ -2968,23 +2943,18 @@ fn test_emscripten(target: &str) { cfg.skip_field_type(move |struct_, field| { // This is a weird union, don't check the type. - // FIXME: is this necessary? (struct_ == "ifaddrs" && field == "ifa_ifu") || // sighandler_t type is super weird - // FIXME: is this necessary? (struct_ == "sigaction" && field == "sa_sigaction") || // sigval is actually a union, but we pretend it's a struct - // FIXME: is this necessary? (struct_ == "sigevent" && field == "sigev_value") }); cfg.skip_field(move |struct_, field| { // this is actually a union on linux, so we can't represent it well and // just insert some padding. - // FIXME: is this necessary? (struct_ == "siginfo_t" && field == "_pad") || // musl names this __dummy1 but it's still there - // FIXME: is this necessary? (struct_ == "glob_t" && field == "gl_flags") || // FIXME: After musl 1.1.24, it have only one field `sched_priority`, // while other fields become reserved. @@ -2996,7 +2966,6 @@ fn test_emscripten(target: &str) { ].contains(&field)) }); - // FIXME: test linux like cfg.generate("../src/lib.rs", "main.rs"); } diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index f3821f7052b73..9207999b6b1e1 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -16,7 +16,7 @@ pub type loff_t = i64; pub type pthread_key_t = ::c_uint; pub type clock_t = c_long; -pub type time_t = c_long; +pub type time_t = i64; pub type suseconds_t = c_long; pub type ino_t = u64; pub type off_t = i64; @@ -259,11 +259,8 @@ s! { pub shm_perm: ::ipc_perm, pub shm_segsz: ::size_t, pub shm_atime: ::time_t, - __unused1: ::c_int, pub shm_dtime: ::time_t, - __unused2: ::c_int, pub shm_ctime: ::time_t, - __unused3: ::c_int, pub shm_cpid: ::pid_t, pub shm_lpid: ::pid_t, pub shm_nattch: ::c_ulong, @@ -274,11 +271,8 @@ s! { pub struct msqid_ds { pub msg_perm: ::ipc_perm, pub msg_stime: ::time_t, - __unused1: ::c_int, pub msg_rtime: ::time_t, - __unused2: ::c_int, pub msg_ctime: ::time_t, - __unused3: ::c_int, __msg_cbytes: ::c_ulong, pub msg_qnum: ::msgqnum_t, pub msg_qbytes: ::msglen_t, @@ -1046,11 +1040,11 @@ pub const PTHREAD_STACK_MIN: ::size_t = 2048; pub const POSIX_FADV_DONTNEED: ::c_int = 4; pub const POSIX_FADV_NOREUSE: ::c_int = 5; -pub const POSIX_MADV_DONTNEED: ::c_int = 0; +pub const POSIX_MADV_DONTNEED: ::c_int = 4; pub const RLIM_INFINITY: ::rlim_t = !0; #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] -pub const RLIMIT_NLIMITS: ::c_int = 15; +pub const RLIMIT_NLIMITS: ::c_int = 16; #[allow(deprecated)] #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] pub const RLIM_NLIMITS: ::c_int = RLIMIT_NLIMITS; @@ -1065,7 +1059,7 @@ pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; -pub const CPU_SETSIZE: ::c_int = 128; +pub const CPU_SETSIZE: ::c_int = 1024; pub const TCSANOW: ::c_int = 0; pub const TCSADRAIN: ::c_int = 1; @@ -1167,14 +1161,14 @@ pub const B3500000: ::speed_t = 0o010016; pub const B4000000: ::speed_t = 0o010017; pub const SO_BINDTODEVICE: ::c_int = 25; -pub const SO_TIMESTAMP: ::c_int = 29; +pub const SO_TIMESTAMP: ::c_int = 63; pub const SO_MARK: ::c_int = 36; pub const SO_RXQ_OVFL: ::c_int = 40; pub const SO_PEEK_OFF: ::c_int = 42; pub const SO_BUSY_POLL: ::c_int = 46; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; -pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 28; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; pub const O_DIRECT: ::c_int = 0x4000; pub const O_DIRECTORY: ::c_int = 0x10000; @@ -1225,7 +1219,7 @@ pub const SOCK_STREAM: ::c_int = 1; pub const SOCK_DGRAM: ::c_int = 2; pub const SOCK_SEQPACKET: ::c_int = 5; -pub const IPPROTO_MAX: ::c_int = 256; +pub const IPPROTO_MAX: ::c_int = 263; pub const SOL_SOCKET: ::c_int = 1; @@ -1242,8 +1236,8 @@ pub const SO_LINGER: ::c_int = 13; pub const SO_REUSEPORT: ::c_int = 15; pub const SO_RCVLOWAT: ::c_int = 18; pub const SO_SNDLOWAT: ::c_int = 19; -pub const SO_RCVTIMEO: ::c_int = 20; -pub const SO_SNDTIMEO: ::c_int = 21; +pub const SO_RCVTIMEO: ::c_int = 66; +pub const SO_SNDTIMEO: ::c_int = 67; pub const SO_ACCEPTCONN: ::c_int = 30; pub const IPV6_RTHDR_LOOSE: ::c_int = 0; @@ -1345,7 +1339,7 @@ pub const TIOCM_RNG: ::c_int = 0x080; pub const TIOCM_DSR: ::c_int = 0x100; pub const TIOCM_CD: ::c_int = TIOCM_CAR; pub const TIOCM_RI: ::c_int = TIOCM_RNG; -pub const O_TMPFILE: ::c_int = 0x400000; +pub const O_TMPFILE: ::c_int = 0x410000; pub const MAX_ADDR_LEN: usize = 7; pub const ARPD_UPDATE: ::c_ushort = 0x01;