Commit cb64cba
committed
Emscripten (wasm32-unknown-emscripten) support
Adds wasm32-unknown-emscripten as a target for nix, plus a CI job that runs the
full test suite under Node.
Source changes to compile on emscripten (which behaves like a Linux/musl libc):
* ioctl: use the Linux ioctl module and a c_int ioctl_num_type on emscripten
(src/sys/ioctl, src/sys/mod.rs).
* resource: enable getrlimit/setrlimit and the Resource enum via libc::rlimit.
* socket: include emscripten in the SockaddrStorage AF_UNIX (pathname/unnamed)
decode arms.
* unistd: sethostname is unavailable on emscripten, so gate it out.
The suite spawns OS threads (signal and socket-peer tests), so std is rebuilt
with atomics via -Zbuild-std and linked -pthread with -sPROXY_TO_PTHREAD so the
main thread can block; JSPI (-sJSPI) provides the return-to-host suspension for
blocking reads/writes, and NODERAWFS/NODERAWSOCKETS back the filesystem and
sockets with node's. This needs nightly + rust-src and a JSPI-capable Node
(26+, or 22 with --experimental-wasm-jspi). No custom target spec is required:
nightly now emits the __main_argc_argv entry point (rust-lang/rust#158937).
Genuinely-unsupported operations are ignored with
fork/wait, pty/termios, mkfifo, getpwnam/setgroups/acct, flock, if_nametoindex,
pipe2 FD_CLOEXEC, AF_UNIX SCM_RIGHTS/datagram, thread signal masking, and
setrlimit; a few tests are cfg'd out where the feature is entirely absent
(raw signal actions, socketpair) or the host differs (linkat symlink follow).
Temporary, until the dependencies land upstream:
* Cargo.toml patches libc to guybedford/libc#libc-0.2-emscripten for the
emscripten externs (rust-lang/libc#5270).
* the CI job builds against the guybedford/emscripten `cf` fork, which carries
the NODEFS/socket/blocking patches this target depends on
(emscripten-core/emscripten#27305, #27306).
Suite result: 148 passed, 0 failed, 35 ignored under Node - green on Linux CI.1 parent 23b6973 commit cb64cba
2 files changed
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
676 | 676 | | |
677 | 677 | | |
678 | 678 | | |
| 679 | + | |
679 | 680 | | |
680 | 681 | | |
681 | | - | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
682 | 685 | | |
683 | 686 | | |
684 | 687 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | 29 | | |
33 | 30 | | |
34 | 31 | | |
| |||
0 commit comments