Skip to content

Commit 839239d

Browse files
committed
emscripten: Upgrade emsdk to 3.1.68
In line with commit rust-lang/rust@2c38ecf. While we're here, make the changes in commit 63b0d67 unconditional, which means that Emscripten 3.1.42 (released at 2023/06/23) is the minimum required version for Rust, assuming no breaking ABI changes occurred after that version.
1 parent a31cb99 commit 839239d

File tree

5 files changed

+109
-157
lines changed

5 files changed

+109
-157
lines changed

build.rs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use std::str;
66
// need to know all the possible cfgs that this script will set. If you need to set another cfg
77
// make sure to add it to this list as well.
88
const ALLOWED_CFGS: &'static [&'static str] = &[
9-
"emscripten_new_stat_abi",
109
"espidf_time64",
1110
"freebsd10",
1211
"freebsd11",
@@ -67,12 +66,6 @@ fn main() {
6766
_ => set_cfg("freebsd15"),
6867
}
6968

70-
match emcc_version_code() {
71-
Some(v) if (v >= 30142) => set_cfg("emscripten_new_stat_abi"),
72-
// Non-Emscripten or version < 3.1.42.
73-
Some(_) | None => (),
74-
}
75-
7669
// On CI: deny all warnings
7770
if libc_ci {
7871
set_cfg("libc_deny_warnings");
@@ -212,28 +205,6 @@ fn which_freebsd() -> Option<i32> {
212205
}
213206
}
214207

215-
fn emcc_version_code() -> Option<u64> {
216-
let output = std::process::Command::new("emcc")
217-
.arg("-dumpversion")
218-
.output()
219-
.ok()?;
220-
if !output.status.success() {
221-
return None;
222-
}
223-
224-
let version = String::from_utf8(output.stdout).ok()?;
225-
226-
// Some Emscripten versions come with `-git` attached, so split the
227-
// version string also on the `-` char.
228-
let mut pieces = version.trim().split(['.', '-']);
229-
230-
let major = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0);
231-
let minor = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0);
232-
let patch = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0);
233-
234-
Some(major * 10000 + minor * 100 + patch)
235-
}
236-
237208
fn set_cfg(cfg: &str) {
238209
if !ALLOWED_CFGS.contains(&cfg) {
239210
panic!("trying to set cfg {}, but it is not in ALLOWED_CFGS", cfg);

ci/emscripten.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
set -ex
44

5-
# FIXME: 3.1.21 removed a lot of header files (https://github.com/emscripten-core/emscripten/pull/17704).
6-
# We have to tweak libc-test (and deprecate unsupported items, maybe) when updating emsdk.
7-
EMSDK_VERSION=3.1.20
5+
# Note: keep in sync with:
6+
# https://github.com/rust-lang/rust/blob/master/src/ci/docker/scripts/emscripten.sh
7+
EMSDK_VERSION=3.1.68
88

99
git clone https://github.com/emscripten-core/emsdk.git /emsdk-portable
1010
cd /emsdk-portable

libc-test/build.rs

Lines changed: 40 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2703,7 +2703,6 @@ fn test_emscripten(target: &str) {
27032703
cfg.define("_GNU_SOURCE", None); // FIXME: ??
27042704

27052705
headers! { cfg:
2706-
"aio.h",
27072706
"ctype.h",
27082707
"dirent.h",
27092708
"dlfcn.h",
@@ -2743,32 +2742,21 @@ fn test_emscripten(target: &str) {
27432742
"stdio.h",
27442743
"stdlib.h",
27452744
"string.h",
2746-
"sys/epoll.h",
2747-
"sys/eventfd.h",
27482745
"sys/file.h",
27492746
"sys/ioctl.h",
27502747
"sys/ipc.h",
27512748
"sys/mman.h",
27522749
"sys/mount.h",
27532750
"sys/msg.h",
2754-
"sys/personality.h",
2755-
"sys/prctl.h",
2756-
"sys/ptrace.h",
2757-
"sys/quota.h",
2758-
"sys/reboot.h",
27592751
"sys/resource.h",
27602752
"sys/sem.h",
27612753
"sys/shm.h",
2762-
"sys/signalfd.h",
27632754
"sys/socket.h",
27642755
"sys/stat.h",
27652756
"sys/statvfs.h",
2766-
"sys/swap.h",
27672757
"sys/syscall.h",
2768-
"sys/sysctl.h",
27692758
"sys/sysinfo.h",
27702759
"sys/time.h",
2771-
"sys/timerfd.h",
27722760
"sys/times.h",
27732761
"sys/types.h",
27742762
"sys/uio.h",
@@ -2794,9 +2782,7 @@ fn test_emscripten(target: &str) {
27942782
// Just pass all these through, no need for a "struct" prefix
27952783
"FILE" | "fd_set" | "Dl_info" | "DIR" => ty.to_string(),
27962784

2797-
"os_unfair_lock" => "struct os_unfair_lock_s".to_string(),
2798-
2799-
// LFS64 types have been removed in Emscripten 3.1.44+
2785+
// LFS64 types have been removed in Emscripten 3.1.44
28002786
// https://github.com/emscripten-core/emscripten/pull/19812
28012787
"off64_t" => "off_t".to_string(),
28022788

@@ -2820,7 +2806,7 @@ fn test_emscripten(target: &str) {
28202806
s if s.ends_with("_nsec") && struct_.starts_with("stat") => {
28212807
s.replace("e_nsec", ".tv_nsec")
28222808
}
2823-
// FIXME: appears that `epoll_event.data` is an union
2809+
// Rust struct uses raw u64, rather than union
28242810
"u64" if struct_ == "epoll_event" => "data.u64".to_string(),
28252811
s => s.to_string(),
28262812
}
@@ -2832,10 +2818,11 @@ fn test_emscripten(target: &str) {
28322818
// FIXME: is this necessary?
28332819
"sighandler_t" => true,
28342820

2835-
// FIXME: The size has been changed due to musl's time64
2836-
"time_t" => true,
2821+
// No epoll support
2822+
// https://github.com/emscripten-core/emscripten/issues/5033
2823+
ty if ty.starts_with("epoll") => true,
28372824

2838-
// LFS64 types have been removed in Emscripten 3.1.44+
2825+
// LFS64 types have been removed in Emscripten 3.1.44
28392826
// https://github.com/emscripten-core/emscripten/pull/19812
28402827
t => t.ends_with("64") || t.ends_with("64_t"),
28412828
}
@@ -2844,29 +2831,19 @@ fn test_emscripten(target: &str) {
28442831
cfg.skip_struct(move |ty| {
28452832
match ty {
28462833
// This is actually a union, not a struct
2847-
// FIXME: is this necessary?
28482834
"sigval" => true,
28492835

2850-
// FIXME: It was removed in
2851-
// emscripten-core/emscripten@953e414
2852-
"pthread_mutexattr_t" => true,
2853-
28542836
// FIXME: Investigate why the test fails.
28552837
// Skip for now to unblock CI.
28562838
"pthread_condattr_t" => true,
2839+
"pthread_mutexattr_t" => true,
28572840

2858-
// FIXME: The size has been changed when upgraded to musl 1.2.2
2859-
"pthread_mutex_t" => true,
2860-
2861-
// FIXME: Lowered from 16 to 8 bytes in
2862-
// llvm/llvm-project@d1a96e9
2863-
"max_align_t" => true,
2864-
2865-
// FIXME: The size has been changed due to time64
2866-
"utimbuf" | "timeval" | "timespec" | "rusage" | "itimerval" | "sched_param"
2867-
| "stat" | "stat64" | "shmid_ds" | "msqid_ds" => true,
2841+
// No epoll support
2842+
// https://github.com/emscripten-core/emscripten/issues/5033
2843+
ty if ty.starts_with("epoll") => true,
2844+
ty if ty.starts_with("signalfd") => true,
28682845

2869-
// LFS64 types have been removed in Emscripten 3.1.44+
2846+
// LFS64 types have been removed in Emscripten 3.1.44
28702847
// https://github.com/emscripten-core/emscripten/pull/19812
28712848
ty => ty.ends_with("64") || ty.ends_with("64_t"),
28722849
}
@@ -2875,12 +2852,9 @@ fn test_emscripten(target: &str) {
28752852
cfg.skip_fn(move |name| {
28762853
match name {
28772854
// Emscripten does not support fork/exec/wait or any kind of multi-process support
2878-
// https://github.com/emscripten-core/emscripten/blob/3.1.30/tools/system_libs.py#L973
2855+
// https://github.com/emscripten-core/emscripten/blob/3.1.68/tools/system_libs.py#L1100
28792856
"execv" | "execve" | "execvp" | "execvpe" | "fexecve" | "wait4" => true,
28802857

2881-
// FIXME: Remove after emscripten-core/emscripten#18492 is released (> 3.1.30).
2882-
"clearenv" => true,
2883-
28842858
_ => false,
28852859
}
28862860
});
@@ -2894,23 +2868,35 @@ fn test_emscripten(target: &str) {
28942868
// FIXME: emscripten uses different constants to constructs these
28952869
n if n.contains("__SIZEOF_PTHREAD") => true,
28962870

2897-
// FIXME: `SYS_gettid` was removed in
2898-
// emscripten-core/emscripten@6d6474e
2871+
// No epoll support
2872+
// https://github.com/emscripten-core/emscripten/issues/5033
2873+
n if n.starts_with("EPOLL") => true,
2874+
2875+
// No ptrace.h
2876+
// https://github.com/emscripten-core/emscripten/pull/17704
2877+
n if n.starts_with("PTRACE_") => true,
2878+
2879+
// No quota.h
2880+
// https://github.com/emscripten-core/emscripten/pull/17704
2881+
n if n.starts_with("QIF_") => true,
2882+
2883+
// `SYS_gettid` was removed in Emscripten v1.39.9
2884+
// https://github.com/emscripten-core/emscripten/pull/10439
28992885
"SYS_gettid" => true,
29002886

2901-
// FIXME: These values have been changed
2902-
| "POSIX_MADV_DONTNEED" // to 4
2903-
| "RLIMIT_NLIMITS" // to 16
2904-
| "RLIM_NLIMITS" // to 16
2905-
| "IPPROTO_MAX" // to 263
2906-
| "F_GETLK" // to 5
2907-
| "F_SETLK" // to 6
2908-
| "F_SETLKW" // to 7
2909-
| "O_TMPFILE" // to 65
2910-
| "SIG_IGN" // -1
2911-
=> true,
2887+
"ADDR_NO_RANDOMIZE" | "MMAP_PAGE_ZERO" | "ADDR_COMPAT_LAYOUT" | "READ_IMPLIES_EXEC"
2888+
| "ADDR_LIMIT_32BIT" | "SHORT_INODE" | "WHOLE_SECONDS" | "STICKY_TIMEOUTS"
2889+
| "ADDR_LIMIT_3GB" => true,
2890+
2891+
"USRQUOTA" | "GRPQUOTA" => true,
29122892

2913-
// LFS64 types have been removed in Emscripten 3.1.44+
2893+
"Q_GETFMT" | "Q_GETINFO" | "Q_SETINFO" | "Q_SYNC" | "Q_QUOTAON" | "Q_QUOTAOFF"
2894+
| "Q_GETQUOTA" | "Q_SETQUOTA" => true,
2895+
2896+
// FIXME: https://github.com/emscripten-core/emscripten/pull/14883
2897+
"SIG_IGN" => true,
2898+
2899+
// LFS64 types have been removed in Emscripten 3.1.44
29142900
// https://github.com/emscripten-core/emscripten/pull/19812
29152901
n if n.starts_with("RLIM64") => true,
29162902

@@ -2920,38 +2906,19 @@ fn test_emscripten(target: &str) {
29202906

29212907
cfg.skip_field_type(move |struct_, field| {
29222908
// This is a weird union, don't check the type.
2923-
// FIXME: is this necessary?
29242909
(struct_ == "ifaddrs" && field == "ifa_ifu") ||
29252910
// sighandler_t type is super weird
2926-
// FIXME: is this necessary?
29272911
(struct_ == "sigaction" && field == "sa_sigaction") ||
29282912
// sigval is actually a union, but we pretend it's a struct
2929-
// FIXME: is this necessary?
2930-
(struct_ == "sigevent" && field == "sigev_value") ||
2931-
// aio_buf is "volatile void*" and Rust doesn't understand volatile
2932-
// FIXME: is this necessary?
2933-
(struct_ == "aiocb" && field == "aio_buf")
2913+
(struct_ == "sigevent" && field == "sigev_value")
29342914
});
29352915

29362916
cfg.skip_field(move |struct_, field| {
29372917
// this is actually a union on linux, so we can't represent it well and
29382918
// just insert some padding.
2939-
// FIXME: is this necessary?
29402919
(struct_ == "siginfo_t" && field == "_pad") ||
29412920
// musl names this __dummy1 but it's still there
2942-
// FIXME: is this necessary?
29432921
(struct_ == "glob_t" && field == "gl_flags") ||
2944-
// musl seems to define this as an *anonymous* bitfield
2945-
// FIXME: is this necessary?
2946-
(struct_ == "statvfs" && field == "__f_unused") ||
2947-
// sigev_notify_thread_id is actually part of a sigev_un union
2948-
(struct_ == "sigevent" && field == "sigev_notify_thread_id") ||
2949-
// signalfd had SIGSYS fields added in Linux 4.18, but no libc release has them yet.
2950-
(struct_ == "signalfd_siginfo" && (field == "ssi_addr_lsb" ||
2951-
field == "_pad2" ||
2952-
field == "ssi_syscall" ||
2953-
field == "ssi_call_addr" ||
2954-
field == "ssi_arch")) ||
29552922
// FIXME: After musl 1.1.24, it have only one field `sched_priority`,
29562923
// while other fields become reserved.
29572924
(struct_ == "sched_param" && [
@@ -2962,7 +2929,6 @@ fn test_emscripten(target: &str) {
29622929
].contains(&field))
29632930
});
29642931

2965-
// FIXME: test linux like
29662932
cfg.generate("../src/lib.rs", "main.rs");
29672933
}
29682934

src/unix/linux_like/emscripten/align.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ macro_rules! expand_align {
3737
size: [u8; ::__SIZEOF_PTHREAD_COND_T],
3838
}
3939

40+
// Lowered from 16 to 8 bytes in
41+
// https://github.com/llvm/llvm-project/commit/d1a96e906cc03a95cfd41a1f22bdda92651250c7
4042
#[allow(missing_debug_implementations)]
41-
#[repr(align(16))]
43+
#[repr(align(8))]
4244
pub struct max_align_t {
43-
priv_: [f64; 4]
45+
priv_: [f64; 3]
4446
}
4547

4648
}

0 commit comments

Comments
 (0)