diff --git a/ci/emscripten.sh b/ci/emscripten.sh index 44da97c93ee68..5aa75654d1f1c 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 diff --git a/libc-test/build.rs b/libc-test/build.rs index 2f7c469d7cf6a..538ce5c53a70c 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2553,7 +2553,6 @@ fn test_emscripten(target: &str) { cfg.define("_GNU_SOURCE", None); // FIXME: ?? headers! { cfg: - "aio.h", "ctype.h", "dirent.h", "dlfcn.h", @@ -2593,32 +2592,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", @@ -2682,8 +2670,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, // LFS64 types have been removed in Emscripten 3.1.44+ // https://github.com/emscripten-core/emscripten/pull/19812 @@ -2712,9 +2701,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, // LFS64 types have been removed in Emscripten 3.1.44+ // https://github.com/emscripten-core/emscripten/pull/19812 @@ -2728,9 +2724,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, } }); @@ -2744,21 +2737,45 @@ 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, - // 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, + // 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: https://github.com/emscripten-core/emscripten/pull/14883 + "SIG_IGN" => true, // LFS64 types have been removed in Emscripten 3.1.44+ // https://github.com/emscripten-core/emscripten/pull/19812 diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 1c9e4e6f5b178..b35780f0f1b93 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -16,7 +16,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; +// 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; pub type off_t = i64; @@ -288,11 +289,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, @@ -303,11 +301,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, @@ -1227,11 +1222,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; @@ -1443,7 +1438,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; @@ -1499,10 +1494,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; @@ -1563,7 +1558,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;