-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
emscripten: Upgrade emsdk to 3.1.68 #3962
Conversation
r? @JohnTitor rustbot has assigned @JohnTitor. Use |
Thanks @kleisauke it would be nice to see time_t finally get fixed... |
Could/should this PR keep the emcc version check to give a nice error at build time if a now-no-longer supported Emscripten is used? |
I wouldn't want rust to generate an error when building with Emscripten 3.1.58 since that is the version that Pyodide is using with Python 3.12 and it would prevent us from upgrading. Though I suppose that it would just require us to use a patched |
But having a version check would be fine as long as there is an override. |
I was thinking about the previous check for 3.1.42 when the ABI change happened, which previous libc versions still supported (now there would be an ABI break in the opposite direction). I definitely agree that other than that pretty much any emcc version has to be allowed since there is no current indicator which versions are ABI compatible and which aren’t |
How backwards compatible is emsdk? I think putting this on the 0.2 stable branch should be okay, but would like to know if there is any expected breakage here. |
63bbd45
to
839239d
Compare
Updated now that PR rust-lang/rust#131533 was landed. This is ready for review.
AFAIK, there were no ABI-breaking changes after Emscripten 3.1.42 (released at 2023/06/23), which was addressed in libc by commit 63b0d67 (but only when building with |
I could address this within a follow-up PR, but perhaps its severity should be a warning instead? Simple programs that don't use filesystem operations will likely still work with Emscripten versions prior to 3.1.42. On the other hand, Emscripten 3.1.42 is already more than a year old. |
@kleisauke it would be really great if we could make some sort of tool to do ABI compatibility checks. For a static test, we could compare the contents of This probably wouldn't be perfect, but it would be a lot better than the current method where we don't really know anything. |
Agreed, we need to improve this. Note that a similar tool for this already exists in the repo. For example, when reverting the change in $ TARGET=wasm32-unknown-emscripten sh ./ci/install-rust.sh
$ ./ci/run-docker.sh wasm32-unknown-emscripten
[...]
bad max_align_t size: rust: 32 (0x20) != c 24 (0x18)
bad max_align_t align: rust: 16 (0x10) != c 8 (0x8)
size of max_align_t is 24 in C and 32 in Rust
thread 'main' panicked at /checkout/target/wasm32-unknown-emscripten/debug/build/libc-test-3c1238c857576107/out/main.rs:12:21:
some tests failed However, that would only cover the types/functions/structs defined in Thinking about this further, how about changing
Note that wasm-vips regularly updates Rust and Emscripten to the latest versions, which is why the underlying issue in commit 63b0d67 and 7c952dc was resolved quickly. Based on that, I assumed there were no ABI-breaking changes after Emscripten 3.1.42, but I could be wrong. |
☔ The latest upstream changes (presumably #3993) made this pull request unmergeable. Please resolve the merge conflicts. |
839239d
to
073dbdf
Compare
I don't have any major concerns here but I'll defer to @hoodmane's review (I'll merge once you give it the checkmark) |
073dbdf
to
a35f212
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @kleisauke generally looks good to me.
build.rs
Outdated
fn emcc_version_code() -> Option<u64> { | ||
let output = std::process::Command::new("emcc") | ||
.arg("-dumpversion") | ||
.output() | ||
.ok()?; | ||
if !output.status.success() { | ||
return None; | ||
} | ||
|
||
let version = String::from_utf8(output.stdout).ok()?; | ||
|
||
// Some Emscripten versions come with `-git` attached, so split the | ||
// version string also on the `-` char. | ||
let mut pieces = version.trim().split(['.', '-']); | ||
|
||
let major = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0); | ||
let minor = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0); | ||
let patch = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0); | ||
|
||
Some(major * 10000 + minor * 100 + patch) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to drop this entirely? Maybe we could adjust this to fail if Emscripten is below the minimum supported version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change was made based on the assumption that Rust requires Emscripten 3.1.42 or later. However, upon review, it appears that the compatibility note in rust-lang/rust#131689 indicates that versions prior 3.1.42 are still supported.
Let me drop commit a35f212 for now.
#[allow(missing_debug_implementations)] | ||
#[repr(align(16))] | ||
#[repr(align(8))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Irrelevant remark.) The stack still has to be aligned to 16 bytes when you call a function even though maxalign is only 8. Discovering this wasted a lot of my time.
libc-test/build.rs
Outdated
// FIXME: https://github.com/emscripten-core/emscripten/pull/14883 | ||
"SIG_IGN" => true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this FIXME mean? Did that PR break this test? Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That PR did break the libc test, see e.g.:
RUNNING ALL TESTS
bad SIG_IGN value at byte 0: rust: 1 (0x1) != c 254 (0xfe)
bad SIG_IGN value at byte 1: rust: 0 (0x0) != c 255 (0xff)
bad SIG_IGN value at byte 2: rust: 0 (0x0) != c 255 (0xff)
bad SIG_IGN value at byte 3: rust: 0 (0x0) != c 255 (0xff)
thread 'main' panicked at /checkout/target/wasm32-unknown-emscripten/debug/build/libc-test-890b1e2d4768b06a/out/main.rs:12:21:
some tests failed
However, this FIXME
can probably not fixed according to
https://github.com/emscripten-core/emscripten/pull/14883/files#r892912370.
I'll change this to:
// FIXME: https://github.com/emscripten-core/emscripten/pull/14883 | |
"SIG_IGN" => 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, |
Note that other implementations have a similar issue, see e.g:
Line 1198 in e4c7acc
"SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe there should be a constant somewhere that indicates what the value of SIG_IGN is on the platform... But that would be best dealt with in a followup.
a35f212
to
b6a957f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple small nits before merge. Thanks @hoodmane for taking a look.
// Lowered from 16 to 8 bytes in | ||
// https://github.com/llvm/llvm-project/commit/d1a96e906cc03a95cfd41a1f22bdda92651250c7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just go in the commit message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split into commit 52fa133 and moved the time_t
description to the commit message as well.
https://github.com/rust-lang/libc/compare/b6a957f2ec9f24a843d04ec4313f3a4634944072..a37fa9d267ddb3c7cbc9504ac730a7ed6fc11f59
pub const S_IEXEC: mode_t = 0o0100; | ||
pub const S_IWRITE: mode_t = 0o0200; | ||
pub const S_IREAD: mode_t = 0o0400; | ||
pub const S_IEXEC: mode_t = 64; | ||
pub const S_IWRITE: mode_t = 128; | ||
pub const S_IREAD: mode_t = 256; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These look like they are octal in the C source, could they stay that way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reverted this part, I can't remember why I did this in the first place.
In line with commit rust-lang/rust@2c38ecf. Notable changes: - `time_t` changed to 64-bit. emscripten-core/emscripten@c8857a6
a37fa9d
to
3e82531
Compare
See: emscripten-core/emscripten@6416c35. (backport <rust-lang#3962>) (cherry picked from commit 01c72ee)
See: emscripten-core/emscripten@15f7632. (backport <rust-lang#3962>) (cherry picked from commit 6670ab2)
See: emscripten-core/emscripten@655ad88. (backport <rust-lang#3962>) (cherry picked from commit 0df7c93)
See: llvm/llvm-project@d1a96e9. (backport <rust-lang#3962>) (cherry picked from commit 99035d7)
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)
In line with commit rust-lang/rust@2c38ecf.
Resolves: #3306.
Supersedes: #3569.
Cherry-picks a couple of changes from: #3307.