Skip to content

Commit

Permalink
emscripten: Upgrade emsdk to 3.1.68
Browse files Browse the repository at this point in the history
In line with commit rust-lang/rust@2c38ecf.

Notable changes:
- `time_t` changed to 64-bit.
  emscripten-core/emscripten@c8857a6

(backport <rust-lang#3962>)
(cherry picked from commit 3e82531)
  • Loading branch information
kleisauke authored and tgross35 committed Nov 15, 2024
1 parent eb821a3 commit 4aa7cca
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 62 deletions.
6 changes: 3 additions & 3 deletions ci/emscripten.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
55 changes: 12 additions & 43 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2874,7 +2874,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(),

Expand All @@ -2898,7 +2898,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(),
}
Expand All @@ -2914,10 +2914,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"),
}
Expand All @@ -2926,30 +2923,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"),
}
Expand All @@ -2958,12 +2944,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,
}
});
Expand Down Expand Up @@ -2991,8 +2974,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
Expand All @@ -3001,19 +2984,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,

Expand All @@ -3023,23 +2998,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.
Expand All @@ -3051,7 +3021,6 @@ fn test_emscripten(target: &str) {
].contains(&field))
});

// FIXME: test linux like
cfg.generate("../src/lib.rs", "main.rs");
}

Expand Down
26 changes: 10 additions & 16 deletions src/unix/linux_like/emscripten/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -1048,11 +1042,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;
Expand All @@ -1067,7 +1061,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;
Expand Down Expand Up @@ -1169,14 +1163,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;
Expand Down Expand Up @@ -1227,7 +1221,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;

Expand All @@ -1244,8 +1238,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;
Expand Down Expand Up @@ -1347,7 +1341,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;
Expand Down

0 comments on commit 4aa7cca

Please sign in to comment.