From 8fd42b507b42aed4f11827b6cd200d514a70be81 Mon Sep 17 00:00:00 2001 From: Benjamin Sieffert <109514252+benjamin-sieffert@users.noreply.github.com> Date: Fri, 21 Jul 2023 07:07:23 +0200 Subject: [PATCH 1/5] widen emscripten time_t to 64-bit --- src/unix/linux_like/emscripten/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index c0d7071840847..90cee75da0f51 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -20,7 +20,8 @@ pub type loff_t = i64; pub type pthread_key_t = ::c_uint; pub type clock_t = c_long; -pub type time_t = c_long; +// https://github.com/emscripten-core/emscripten/pull/17401 +pub type time_t = i64; pub type suseconds_t = c_long; pub type ino_t = u64; pub type off_t = i64; From 79959077185e8cc4b91dd092af9e8ead07e8242d Mon Sep 17 00:00:00 2001 From: Benjamin Sieffert <109514252+benjamin-sieffert@users.noreply.github.com> Date: Fri, 21 Jul 2023 08:34:16 +0200 Subject: [PATCH 2/5] docker emscripten tests passing --- ci/emscripten-entry.sh | 2 +- ci/emscripten.sh | 6 +- libc-test/build.rs | 84 ++++++++++++++++++++------- src/unix/linux_like/emscripten/mod.rs | 6 -- 4 files changed, 66 insertions(+), 32 deletions(-) diff --git a/ci/emscripten-entry.sh b/ci/emscripten-entry.sh index 80b091903b1fc..879226fb0e515 100755 --- a/ci/emscripten-entry.sh +++ b/ci/emscripten-entry.sh @@ -7,6 +7,6 @@ source /emsdk-portable/emsdk_env.sh &> /dev/null # emsdk-portable provides a node binary, but we need version 8 to run wasm # NOTE: Do not forget to sync Node.js version with `emscripten.sh`! -export PATH="/node-v14.17.0-linux-x64/bin:$PATH" +export PATH="/node-v16.20.0-linux-x64/bin:$PATH" exec "$@" diff --git a/ci/emscripten.sh b/ci/emscripten.sh index 967b586b5f199..a0b94676f86c1 100644 --- a/ci/emscripten.sh +++ b/ci/emscripten.sh @@ -2,9 +2,7 @@ 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 +EMSDK_VERSION=3.1.41 git clone https://github.com/emscripten-core/emsdk.git /emsdk-portable cd /emsdk-portable @@ -24,5 +22,5 @@ chmod a+rxw -R /emsdk-portable # node 8 is required to run wasm # NOTE: Do not forget to sync Node.js version with `emscripten-entry.sh`! cd / -curl --retry 5 -L https://nodejs.org/dist/v14.17.0/node-v14.17.0-linux-x64.tar.xz | \ +curl --retry 5 -L https://nodejs.org/dist/v16.20.0/node-v16.20.0-linux-x64.tar.xz | \ tar -xJ diff --git a/libc-test/build.rs b/libc-test/build.rs index 276efb481486c..8e11adb90261e 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2532,7 +2532,6 @@ fn test_emscripten(target: &str) { cfg.define("_GNU_SOURCE", None); // FIXME: ?? headers! { cfg: - "aio.h", "ctype.h", "dirent.h", "dlfcn.h", @@ -2572,32 +2571,21 @@ fn test_emscripten(target: &str) { "stdio.h", "stdlib.h", "string.h", - "sys/epoll.h", - "sys/eventfd.h", "sys/file.h", "sys/ioctl.h", "sys/ipc.h", "sys/mman.h", "sys/mount.h", "sys/msg.h", - "sys/personality.h", - "sys/prctl.h", - "sys/ptrace.h", - "sys/quota.h", - "sys/reboot.h", "sys/resource.h", "sys/sem.h", "sys/shm.h", - "sys/signalfd.h", "sys/socket.h", "sys/stat.h", "sys/statvfs.h", - "sys/swap.h", "sys/syscall.h", - "sys/sysctl.h", "sys/sysinfo.h", "sys/time.h", - "sys/timerfd.h", "sys/times.h", "sys/types.h", "sys/uio.h", @@ -2655,8 +2643,9 @@ fn test_emscripten(target: &str) { // FIXME: is this necessary? "sighandler_t" => true, - // FIXME: The size has been changed due to musl's time64 - "time_t" => true, + // No epoll support + // https://github.com/emscripten-core/emscripten/issues/5033 + ty if ty.starts_with("epoll") => true, _ => false, } @@ -2683,9 +2672,16 @@ fn test_emscripten(target: &str) { // llvm/llvm-project@d1a96e9 "max_align_t" => true, - // FIXME: The size has been changed due to time64 - "utimbuf" | "timeval" | "timespec" | "rusage" | "itimerval" | "sched_param" - | "stat" | "stat64" | "shmid_ds" | "msqid_ds" => true, + // No quota.h + "dqblk" => true, + + // No aio.h + "aiocb" => 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, _ => false, } @@ -2697,9 +2693,6 @@ fn test_emscripten(target: &str) { // https://github.com/emscripten-core/emscripten/blob/3.1.30/tools/system_libs.py#L973 "execv" | "execve" | "execvp" | "execvpe" | "fexecve" | "wait4" => true, - // FIXME: Remove after emscripten-core/emscripten#18492 is released (> 3.1.30). - "clearenv" => true, - _ => false, } }); @@ -2713,10 +2706,59 @@ fn test_emscripten(target: &str) { // FIXME: emscripten uses different constants to constructs these n if n.contains("__SIZEOF_PTHREAD") => true, + // No epoll support + // https://github.com/emscripten-core/emscripten/issues/5033 + n if n.starts_with("EPOLL") => true, + n if n.starts_with("EFD_") => true, + n if n.starts_with("SFD_") => true, + + // No reboot.h + n if n.starts_with("RB_") => true, + + // No aio.h + n if n.starts_with("AIO_") => true, + n if n.starts_with("LIO_") => true, + + // No prctrl.h + n if n.starts_with("PR_") => true, + + // No quota.h + n if n.starts_with("QFMT_") => true, + // FIXME: `SYS_gettid` was removed in // emscripten-core/emscripten@6d6474e "SYS_gettid" => true, + // No personality.h etc.: https://github.com/emscripten-core/emscripten/pull/17704 + // No sysctl.h: https://github.com/emscripten-core/emscripten/pull/18863 + n if n.starts_with("PTRACE_") => true, + n if n.starts_with("QIF_") => true, + + | "ADDR_NO_RANDOMIZE" + | "MMAP_PAGE_ZERO" + | "ADDR_COMPAT_LAYOUT" + | "READ_IMPLIES_EXEC" + | "ADDR_LIMIT_32BIT" + | "SHORT_INODE" + | "WHOLE_SECONDS" + | "STICKY_TIMEOUTS" + | "ADDR_LIMIT_3GB" + => true, + + | "USRQUOTA" + | "GRPQUOTA" + => true, + + | "Q_GETFMT" + | "Q_GETINFO" + | "Q_SETINFO" + | "Q_SYNC" + | "Q_QUOTAON" + | "Q_QUOTAOFF" + | "Q_GETQUOTA" + | "Q_SETQUOTA" + => true, + // FIXME: These values have been changed | "POSIX_MADV_DONTNEED" // to 4 | "RLIMIT_NLIMITS" // to 16 @@ -3700,7 +3742,7 @@ fn test_linux(target: &str) { "PR_SET_VMA" | "PR_SET_VMA_ANON_NAME" => true, // present in recent kernels only - "PR_SCHED_CORE" | "PR_SCHED_CORE_CREATE" | "PR_SCHED_CORE_GET" | "PR_SCHED_CORE_MAX" | "PR_SCHED_CORE_SCOPE_PROCESS_GROUP" | "PR_SCHED_CORE_SCOPE_THREAD" | "PR_SCHED_CORE_SCOPE_THREAD_GROUP" | "PR_SCHED_CORE_SHARE_FROM" | "PR_SCHED_CORE_SHARE_TO" => true, + "PR_SCHED_CORE" | "PR_SCHED_CORE_CREATE" | "PR_SCHED_CORE_GET" | "PR_SCHED_CORE_MAX" | "PR_SCHED_CORE_SCOPE_PROCESS_GROUP" | "PR_SCHED_CORE_SCOPE_THREAD" | "PR_SCHED_CORE_SCOPE_THREAD_GROUP" | "PR_SCHED_CORE_SHARE_FROM" | "PR_SCHED_CORE_SHARE_TO" => true, // present in recent kernels only >= 5.13 "PR_PAC_SET_ENABLED_KEYS" | "PR_PAC_GET_ENABLED_KEYS" => true, diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 90cee75da0f51..fa4a98d5937dc 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -319,11 +319,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, @@ -334,11 +331,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, From 2a6a0dc9ae3e654903d62778f954ade2602b78a6 Mon Sep 17 00:00:00 2001 From: Benjamin Sieffert <109514252+benjamin-sieffert@users.noreply.github.com> Date: Fri, 21 Jul 2023 09:09:43 +0200 Subject: [PATCH 3/5] update all outdated emscripten consts --- libc-test/build.rs | 13 ++----------- libc-test/semver/emscripten.txt | 1 + src/unix/linux_like/emscripten/mod.rs | 16 ++++++++-------- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 8e11adb90261e..8b38698f9f3ba 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2759,17 +2759,8 @@ fn test_emscripten(target: &str) { | "Q_SETQUOTA" => 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, + // FIXME: https://github.com/emscripten-core/emscripten/pull/14883 + "SIG_IGN" => true, _ => false, } diff --git a/libc-test/semver/emscripten.txt b/libc-test/semver/emscripten.txt index 48882791e7c8d..0a8fbdef3ef1d 100644 --- a/libc-test/semver/emscripten.txt +++ b/libc-test/semver/emscripten.txt @@ -1 +1,2 @@ getentropy +clock_gettime diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index fa4a98d5937dc..b7d957c4904a0 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -20,7 +20,7 @@ pub type loff_t = i64; pub type pthread_key_t = ::c_uint; pub type clock_t = c_long; -// https://github.com/emscripten-core/emscripten/pull/17401 +// 64-bit time_t since July 2022: https://github.com/emscripten-core/emscripten/pull/17401 pub type time_t = i64; pub type suseconds_t = c_long; pub type ino_t = u64; @@ -1326,10 +1326,10 @@ 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; -pub const RLIMIT_NLIMITS: ::c_int = 15; +pub const RLIMIT_NLIMITS: ::c_int = 16; pub const RLIM_NLIMITS: ::c_int = RLIMIT_NLIMITS; pub const MAP_ANONYMOUS: ::c_int = MAP_ANON; @@ -1539,7 +1539,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; @@ -1595,10 +1595,10 @@ pub const EXTPROC: ::tcflag_t = 0x00010000; pub const MAP_HUGETLB: ::c_int = 0x040000; -pub const F_GETLK: ::c_int = 12; +pub const F_GETLK: ::c_int = 5; pub const F_GETOWN: ::c_int = 9; -pub const F_SETLK: ::c_int = 13; -pub const F_SETLKW: ::c_int = 14; +pub const F_SETLK: ::c_int = 6; +pub const F_SETLKW: ::c_int = 7; pub const F_SETOWN: ::c_int = 8; pub const F_OFD_GETLK: ::c_int = 36; pub const F_OFD_SETLK: ::c_int = 37; @@ -1659,7 +1659,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; From a2f18790be72c3798e2cb634079d4542641b66b2 Mon Sep 17 00:00:00 2001 From: Benjamin Sieffert <109514252+benjamin-sieffert@users.noreply.github.com> Date: Fri, 21 Jul 2023 09:18:59 +0200 Subject: [PATCH 4/5] cleanup --- libc-test/build.rs | 2 +- libc-test/semver/emscripten.txt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 8b38698f9f3ba..2d761dbf5012f 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3733,7 +3733,7 @@ fn test_linux(target: &str) { "PR_SET_VMA" | "PR_SET_VMA_ANON_NAME" => true, // present in recent kernels only - "PR_SCHED_CORE" | "PR_SCHED_CORE_CREATE" | "PR_SCHED_CORE_GET" | "PR_SCHED_CORE_MAX" | "PR_SCHED_CORE_SCOPE_PROCESS_GROUP" | "PR_SCHED_CORE_SCOPE_THREAD" | "PR_SCHED_CORE_SCOPE_THREAD_GROUP" | "PR_SCHED_CORE_SHARE_FROM" | "PR_SCHED_CORE_SHARE_TO" => true, + "PR_SCHED_CORE" | "PR_SCHED_CORE_CREATE" | "PR_SCHED_CORE_GET" | "PR_SCHED_CORE_MAX" | "PR_SCHED_CORE_SCOPE_PROCESS_GROUP" | "PR_SCHED_CORE_SCOPE_THREAD" | "PR_SCHED_CORE_SCOPE_THREAD_GROUP" | "PR_SCHED_CORE_SHARE_FROM" | "PR_SCHED_CORE_SHARE_TO" => true, // present in recent kernels only >= 5.13 "PR_PAC_SET_ENABLED_KEYS" | "PR_PAC_GET_ENABLED_KEYS" => true, diff --git a/libc-test/semver/emscripten.txt b/libc-test/semver/emscripten.txt index 0a8fbdef3ef1d..48882791e7c8d 100644 --- a/libc-test/semver/emscripten.txt +++ b/libc-test/semver/emscripten.txt @@ -1,2 +1 @@ getentropy -clock_gettime From 225eead6147f108cd9193df22b76ba793449f67d Mon Sep 17 00:00:00 2001 From: Benjamin Sieffert <109514252+benjamin-sieffert@users.noreply.github.com> Date: Fri, 21 Jul 2023 09:25:47 +0200 Subject: [PATCH 5/5] run cargo fmt in libc-test after all --- libc-test/build.rs | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 2d761dbf5012f..50ba6af6b5d55 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2734,30 +2734,14 @@ fn test_emscripten(target: &str) { n if n.starts_with("PTRACE_") => true, n if n.starts_with("QIF_") => true, - | "ADDR_NO_RANDOMIZE" - | "MMAP_PAGE_ZERO" - | "ADDR_COMPAT_LAYOUT" - | "READ_IMPLIES_EXEC" - | "ADDR_LIMIT_32BIT" - | "SHORT_INODE" - | "WHOLE_SECONDS" - | "STICKY_TIMEOUTS" - | "ADDR_LIMIT_3GB" - => true, + "ADDR_NO_RANDOMIZE" | "MMAP_PAGE_ZERO" | "ADDR_COMPAT_LAYOUT" | "READ_IMPLIES_EXEC" + | "ADDR_LIMIT_32BIT" | "SHORT_INODE" | "WHOLE_SECONDS" | "STICKY_TIMEOUTS" + | "ADDR_LIMIT_3GB" => true, - | "USRQUOTA" - | "GRPQUOTA" - => true, + "USRQUOTA" | "GRPQUOTA" => true, - | "Q_GETFMT" - | "Q_GETINFO" - | "Q_SETINFO" - | "Q_SYNC" - | "Q_QUOTAON" - | "Q_QUOTAOFF" - | "Q_GETQUOTA" - | "Q_SETQUOTA" - => true, + "Q_GETFMT" | "Q_GETINFO" | "Q_SETINFO" | "Q_SYNC" | "Q_QUOTAON" | "Q_QUOTAOFF" + | "Q_GETQUOTA" | "Q_SETQUOTA" => true, // FIXME: https://github.com/emscripten-core/emscripten/pull/14883 "SIG_IGN" => true,