Skip to content

Commit 073dbdf

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 b63bf71 commit 073dbdf

File tree

5 files changed

+109
-157
lines changed

5 files changed

+109
-157
lines changed

build.rs

-29
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_time32",
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

+3-3
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

+40-74
Original file line numberDiff line numberDiff line change
@@ -2719,7 +2719,6 @@ fn test_emscripten(target: &str) {
27192719
cfg.define("_GNU_SOURCE", None); // FIXME: ??
27202720

27212721
headers! { cfg:
2722-
"aio.h",
27232722
"ctype.h",
27242723
"dirent.h",
27252724
"dlfcn.h",
@@ -2760,32 +2759,21 @@ fn test_emscripten(target: &str) {
27602759
"stdio.h",
27612760
"stdlib.h",
27622761
"string.h",
2763-
"sys/epoll.h",
2764-
"sys/eventfd.h",
27652762
"sys/file.h",
27662763
"sys/ioctl.h",
27672764
"sys/ipc.h",
27682765
"sys/mman.h",
27692766
"sys/mount.h",
27702767
"sys/msg.h",
2771-
"sys/personality.h",
2772-
"sys/prctl.h",
2773-
"sys/ptrace.h",
2774-
"sys/quota.h",
2775-
"sys/reboot.h",
27762768
"sys/resource.h",
27772769
"sys/sem.h",
27782770
"sys/shm.h",
2779-
"sys/signalfd.h",
27802771
"sys/socket.h",
27812772
"sys/stat.h",
27822773
"sys/statvfs.h",
2783-
"sys/swap.h",
27842774
"sys/syscall.h",
2785-
"sys/sysctl.h",
27862775
"sys/sysinfo.h",
27872776
"sys/time.h",
2788-
"sys/timerfd.h",
27892777
"sys/times.h",
27902778
"sys/types.h",
27912779
"sys/uio.h",
@@ -2811,9 +2799,7 @@ fn test_emscripten(target: &str) {
28112799
// Just pass all these through, no need for a "struct" prefix
28122800
"FILE" | "fd_set" | "Dl_info" | "DIR" => ty.to_string(),
28132801

2814-
"os_unfair_lock" => "struct os_unfair_lock_s".to_string(),
2815-
2816-
// LFS64 types have been removed in Emscripten 3.1.44+
2802+
// LFS64 types have been removed in Emscripten 3.1.44
28172803
// https://github.com/emscripten-core/emscripten/pull/19812
28182804
"off64_t" => "off_t".to_string(),
28192805

@@ -2837,7 +2823,7 @@ fn test_emscripten(target: &str) {
28372823
s if s.ends_with("_nsec") && struct_.starts_with("stat") => {
28382824
s.replace("e_nsec", ".tv_nsec")
28392825
}
2840-
// FIXME: appears that `epoll_event.data` is an union
2826+
// Rust struct uses raw u64, rather than union
28412827
"u64" if struct_ == "epoll_event" => "data.u64".to_string(),
28422828
s => s.to_string(),
28432829
}
@@ -2849,10 +2835,11 @@ fn test_emscripten(target: &str) {
28492835
// FIXME: is this necessary?
28502836
"sighandler_t" => true,
28512837

2852-
// FIXME: The size has been changed due to musl's time64
2853-
"time_t" => true,
2838+
// No epoll support
2839+
// https://github.com/emscripten-core/emscripten/issues/5033
2840+
ty if ty.starts_with("epoll") => true,
28542841

2855-
// LFS64 types have been removed in Emscripten 3.1.44+
2842+
// LFS64 types have been removed in Emscripten 3.1.44
28562843
// https://github.com/emscripten-core/emscripten/pull/19812
28572844
t => t.ends_with("64") || t.ends_with("64_t"),
28582845
}
@@ -2861,29 +2848,19 @@ fn test_emscripten(target: &str) {
28612848
cfg.skip_struct(move |ty| {
28622849
match ty {
28632850
// This is actually a union, not a struct
2864-
// FIXME: is this necessary?
28652851
"sigval" => true,
28662852

2867-
// FIXME: It was removed in
2868-
// emscripten-core/emscripten@953e414
2869-
"pthread_mutexattr_t" => true,
2870-
28712853
// FIXME: Investigate why the test fails.
28722854
// Skip for now to unblock CI.
28732855
"pthread_condattr_t" => true,
2856+
"pthread_mutexattr_t" => true,
28742857

2875-
// FIXME: The size has been changed when upgraded to musl 1.2.2
2876-
"pthread_mutex_t" => true,
2877-
2878-
// FIXME: Lowered from 16 to 8 bytes in
2879-
// llvm/llvm-project@d1a96e9
2880-
"max_align_t" => true,
2881-
2882-
// FIXME: The size has been changed due to time64
2883-
"utimbuf" | "timeval" | "timespec" | "rusage" | "itimerval" | "sched_param"
2884-
| "stat" | "stat64" | "shmid_ds" | "msqid_ds" => true,
2858+
// No epoll support
2859+
// https://github.com/emscripten-core/emscripten/issues/5033
2860+
ty if ty.starts_with("epoll") => true,
2861+
ty if ty.starts_with("signalfd") => true,
28852862

2886-
// LFS64 types have been removed in Emscripten 3.1.44+
2863+
// LFS64 types have been removed in Emscripten 3.1.44
28872864
// https://github.com/emscripten-core/emscripten/pull/19812
28882865
ty => ty.ends_with("64") || ty.ends_with("64_t"),
28892866
}
@@ -2892,12 +2869,9 @@ fn test_emscripten(target: &str) {
28922869
cfg.skip_fn(move |name| {
28932870
match name {
28942871
// Emscripten does not support fork/exec/wait or any kind of multi-process support
2895-
// https://github.com/emscripten-core/emscripten/blob/3.1.30/tools/system_libs.py#L973
2872+
// https://github.com/emscripten-core/emscripten/blob/3.1.68/tools/system_libs.py#L1100
28962873
"execv" | "execve" | "execvp" | "execvpe" | "fexecve" | "wait4" => true,
28972874

2898-
// FIXME: Remove after emscripten-core/emscripten#18492 is released (> 3.1.30).
2899-
"clearenv" => true,
2900-
29012875
_ => false,
29022876
}
29032877
});
@@ -2911,23 +2885,35 @@ fn test_emscripten(target: &str) {
29112885
// FIXME: emscripten uses different constants to constructs these
29122886
n if n.contains("__SIZEOF_PTHREAD") => true,
29132887

2914-
// FIXME: `SYS_gettid` was removed in
2915-
// emscripten-core/emscripten@6d6474e
2888+
// No epoll support
2889+
// https://github.com/emscripten-core/emscripten/issues/5033
2890+
n if n.starts_with("EPOLL") => true,
2891+
2892+
// No ptrace.h
2893+
// https://github.com/emscripten-core/emscripten/pull/17704
2894+
n if n.starts_with("PTRACE_") => true,
2895+
2896+
// No quota.h
2897+
// https://github.com/emscripten-core/emscripten/pull/17704
2898+
n if n.starts_with("QIF_") => true,
2899+
2900+
// `SYS_gettid` was removed in Emscripten v1.39.9
2901+
// https://github.com/emscripten-core/emscripten/pull/10439
29162902
"SYS_gettid" => true,
29172903

2918-
// FIXME: These values have been changed
2919-
| "POSIX_MADV_DONTNEED" // to 4
2920-
| "RLIMIT_NLIMITS" // to 16
2921-
| "RLIM_NLIMITS" // to 16
2922-
| "IPPROTO_MAX" // to 263
2923-
| "F_GETLK" // to 5
2924-
| "F_SETLK" // to 6
2925-
| "F_SETLKW" // to 7
2926-
| "O_TMPFILE" // to 65
2927-
| "SIG_IGN" // -1
2928-
=> true,
2904+
"ADDR_NO_RANDOMIZE" | "MMAP_PAGE_ZERO" | "ADDR_COMPAT_LAYOUT" | "READ_IMPLIES_EXEC"
2905+
| "ADDR_LIMIT_32BIT" | "SHORT_INODE" | "WHOLE_SECONDS" | "STICKY_TIMEOUTS"
2906+
| "ADDR_LIMIT_3GB" => true,
2907+
2908+
"USRQUOTA" | "GRPQUOTA" => true,
29292909

2930-
// LFS64 types have been removed in Emscripten 3.1.44+
2910+
"Q_GETFMT" | "Q_GETINFO" | "Q_SETINFO" | "Q_SYNC" | "Q_QUOTAON" | "Q_QUOTAOFF"
2911+
| "Q_GETQUOTA" | "Q_SETQUOTA" => true,
2912+
2913+
// FIXME: https://github.com/emscripten-core/emscripten/pull/14883
2914+
"SIG_IGN" => true,
2915+
2916+
// LFS64 types have been removed in Emscripten 3.1.44
29312917
// https://github.com/emscripten-core/emscripten/pull/19812
29322918
n if n.starts_with("RLIM64") => true,
29332919

@@ -2937,38 +2923,19 @@ fn test_emscripten(target: &str) {
29372923

29382924
cfg.skip_field_type(move |struct_, field| {
29392925
// This is a weird union, don't check the type.
2940-
// FIXME: is this necessary?
29412926
(struct_ == "ifaddrs" && field == "ifa_ifu") ||
29422927
// sighandler_t type is super weird
2943-
// FIXME: is this necessary?
29442928
(struct_ == "sigaction" && field == "sa_sigaction") ||
29452929
// sigval is actually a union, but we pretend it's a struct
2946-
// FIXME: is this necessary?
2947-
(struct_ == "sigevent" && field == "sigev_value") ||
2948-
// aio_buf is "volatile void*" and Rust doesn't understand volatile
2949-
// FIXME: is this necessary?
2950-
(struct_ == "aiocb" && field == "aio_buf")
2930+
(struct_ == "sigevent" && field == "sigev_value")
29512931
});
29522932

29532933
cfg.skip_field(move |struct_, field| {
29542934
// this is actually a union on linux, so we can't represent it well and
29552935
// just insert some padding.
2956-
// FIXME: is this necessary?
29572936
(struct_ == "siginfo_t" && field == "_pad") ||
29582937
// musl names this __dummy1 but it's still there
2959-
// FIXME: is this necessary?
29602938
(struct_ == "glob_t" && field == "gl_flags") ||
2961-
// musl seems to define this as an *anonymous* bitfield
2962-
// FIXME: is this necessary?
2963-
(struct_ == "statvfs" && field == "__f_unused") ||
2964-
// sigev_notify_thread_id is actually part of a sigev_un union
2965-
(struct_ == "sigevent" && field == "sigev_notify_thread_id") ||
2966-
// signalfd had SIGSYS fields added in Linux 4.18, but no libc release has them yet.
2967-
(struct_ == "signalfd_siginfo" && (field == "ssi_addr_lsb" ||
2968-
field == "_pad2" ||
2969-
field == "ssi_syscall" ||
2970-
field == "ssi_call_addr" ||
2971-
field == "ssi_arch")) ||
29722939
// FIXME: After musl 1.1.24, it have only one field `sched_priority`,
29732940
// while other fields become reserved.
29742941
(struct_ == "sched_param" && [
@@ -2979,7 +2946,6 @@ fn test_emscripten(target: &str) {
29792946
].contains(&field))
29802947
});
29812948

2982-
// FIXME: test linux like
29832949
cfg.generate("../src/lib.rs", "main.rs");
29842950
}
29852951

src/unix/linux_like/emscripten/align.rs

+4-2
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)