Independent tech intelligence, checked against primary sources.

TechPulseMind Useful technology.
No manufactured hype.

Cloudflare Adds Emscripten Target for Native Rust on Workers

Cloudflare has introduced an experimental Emscripten target for wasm-bindgen, significantly improving native Rust and Tokio compatibility for Workers.

Cloudflare Adds Emscripten Target for Native Rust on Workers

Before you start: versions, package names and storage identifiers change over time. Check the commands against the official documentation for your setup before running them, especially anything that creates, deletes or overwrites data.

New Experimental Emscripten Target Unlocks Native Rust in Workers

Cloudflare has announced the first public experimental preview of a compiler target that brings native Rust code and Tokio-based applications to its Workers platform. The update introduces first-class support for the Emscripten wasm32-unknown-emscripten Rust compiler target on the open-source wasm-bindgen toolchain.

This capability allows developers to run complex Rust applications that rely on system-level features directly within serverless edge environments and Node.js. According to early testing, the integration successfully supports low-level libraries and even enables running a Rust-native Minecraft server inside a Durable Object with TCP ingress.

Bridging Toolchains and Virtualizing System Features

The new architecture resolves a historical conflict between wasm-bindgen and Emscripten, both of which traditionally attempted to control JavaScript loading and Wasm output generation. Through collaborative efforts involving Google’s Portable Toolchains team and Cloudflare engineers, the two toolchains now feature seamless interoperability under the -sWASM_BINDGEN configuration.

Because Emscripten virtualizes platform features like timers, file systems, and sockets on top of Web Platform APIs and Node.js compatibility layers, Rust applications written for Unix target families can run with minimal changes. Cloudflare also contributed upstream patches for critical foundational libraries, including foundational support for the Tokio asynchronous runtime.

Running Async Runtimes at the Edge

Integrating Tokio required overcoming the architectural mismatch between blocking thread-parking semantics and single-threaded event loops. Cloudflare’s approach utilizes two models: WebAssembly JavaScript Promise Integration (JSPI) with reentrant thread-local handling, and a novel LocalEventLoop design that replaces traditional thread parking with host-driven wakeup signals.

Additionally, developers gain access to low-level networking features through a new -sNODERAWSOCKETS compilation option in Emscripten. This layer bridges epoll and socket operations into the underlying Node.js network compatibility implementations available on the Workers runtime.

Source

Official announcement or documentation

Some links on this page may be affiliate links. If you buy through them we may earn a commission at no extra cost to you. See our affiliate disclosure.