[DRAFT] Add wasm32-unknown-emscripten build and test support#1059
Draft
[DRAFT] Add wasm32-unknown-emscripten build and test support#1059
wasm32-unknown-emscripten build and test support#1059Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1059 +/- ##
==========================================
- Coverage 95.80% 92.66% -3.14%
==========================================
Files 61 71 +10
Lines 8143 10149 +2006
Branches 0 10149 +10149
==========================================
+ Hits 7801 9405 +1604
- Misses 342 452 +110
- Partials 0 292 +292 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
c19c53b to
c03bdb0
Compare
a7a01fd to
735e9e5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes:
Adds support for building and testing aws-lc-rs targeting
wasm32-unknown-emscripten, following the addition of Emscripten build support in AWS-LC.Build fix (aws-lc-sys cc builder): Emscripten uses musl libc, which hides POSIX declarations (
sigaction,fileno, etc.) behind feature test macros when compiling with strict-std=c11. The cc builder already defined_XOPEN_SOURCE=700for Linux for the same reason; this PR extends that to Emscripten.Jitter entropy on WASM: CPU jitter entropy is meaningless in a WASM sandbox, so
disable_jitter_entropy()now defaults totrueforwasm*targets. This also fixes a pre-existing awkwardness where the function returnedOption<bool>and several call sites had subtly easy-to-misread conditions.WASM stack size: The default Emscripten stack size (64KB) causes a stack overflow during regex compilation in tests. Increased to 1MB via a target-specific
rustflagsentry in.cargo/config.toml.Thread-based tests: Three
*_thread_safenesstests unconditionally spawn OS threads, which isn't supported in this Emscripten environment. They are gated out with#[cfg(not(target_arch = "wasm32"))].Doctest with filesystem access: One doctest in
signature.rsreads.derfiles fromtests/data/, which aren't available in the Emscripten virtual filesystem. The file I/O is guarded with a hiddencfg!check so the doctest still compiles everywhere but only executes on non-WASM targets.Call-outs:
disable_jitter_entropy()fromOption<bool>toboolintroduced two inverted conditions (add_includesandcompile_intermediatesincc_builder.rs). These are fixed in this PR but reviewers should verify the before/after logic is correct — when jitter entropy is not disabled, both the include path and object file compilation must be active.docker/emscripten/Dockerfile): Builds on the cross-rs emscripten base image but replaces both the Emscripten SDK (upgraded to 3.1.74) and Node.js (upgraded to 20 LTS). The base image's Node.js is too old to support the WebAssembly Exception Handling proposal, which modern Rust compilers generate for this target. The/emsdkdirectory is made world-writable so the non-root cross-rs build user can write to the Emscripten cache.Testing:
Tested end-to-end using
cross test -p aws-lc-rs --target wasm32-unknown-emscriptenwith the new Dockerfile. Addedwasm32-unknown-emscriptento theaws-lc-rs-cross-testCI matrix.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.