Cloudflare Adds Emscripten Target to Rust Workers
Cloudflare has announced a first public experimental preview bringing first-class support for the Emscripten Rust compiler target to wasm-bindgen and Cloudflare's Rust Workers.

Emscripten Target Arrives for Rust Workers
Cloudflare announced the first public experimental preview of a feature designed to better support native Rust code and Tokio-based applications directly on Workers. The update delivers first-class support for the Emscripten wasm32-unknown-emscripten Rust compiler target on the wasm-bindgen open source toolchain and Cloudflare's Rust Workers.
The toolchain powers Rust-based WebAssembly applications on Cloudflare's V8-based Workers Runtime. Enabling this target has been a long-term initiative initially started by Google over a year ago and further reviewed and supported by Cloudflare engineers who maintain the toolchain.
While still in a pre-release state, the integration opens new workflow possibilities for running native applications with Emscripten on the web, Node.js, and Cloudflare's global platform. Testing has shown significantly improved library compatibility for Rust Workers.

Bridging C++ and Rust Ecosystems
The path to this release began when Mitch Foley on Google's Portable Toolchains team identified a need for Rust WebAssembly toolchains to interoperate seamlessly with C++. Another internal Google team wanted to use wasm-bindgen to interface with their JavaScript while allowing Emscripten's linker to handle C++ dependencies.
Internally, Google uses Emscripten in C++ codebases to generate JavaScript alongside applications. However, Emscripten previously lacked a robust binding system between Rust and JavaScript comparable to what was provided by the wasm-bindgen ecosystem.
Both tools historically assumed they were solely responsible for loading JavaScript and generating final outputs, creating a conflict that forced developers to choose one toolchain over the other. Foley and colleague Yifan Yang created a cooperative plan allowing Emscripten to drive the build while wasm-bindgen produces portable JavaScript bindings compatible with Emscripten's library system.

Interoperability and Configuration
With feedback from Google's Portable Toolchains team, the Wasm Tools team, and Cloudflare engineers, the required changes successfully landed in both projects. C++ code driven by Emscripten can now be built against static wasm-bindgen Rust code, supporting both binding layers simultaneously.
Similarly, Rust applications using wasm-bindgen can now target Emscripten. Developers can review the official wasm-bindgen Emscripten documentation page for comprehensive technical details on utilizing this target configuration.
The Emscripten toolchain, initially created by Mozilla and maintained by Google engineers, virtualizes platform features like timers, file system operations, and sockets. By leveraging Node.js compilation flags, Cloudflare Workers fully virtualize these native capabilities.

Library Compatibility and Tokio Support
Early prototypes by Cloudflare engineers demonstrated immediate success with low-level systems libraries because Emscripten already supports the target_family equal to unix environment in Rust. Libraries requiring minor patches primarily involved adding the Emscripten target to existing platform gates.
A critical foundational library requiring substantial work was Tokio. Because Cloudflare Workers are single-threaded and hosted within a JavaScript event loop, they do not inherently align with Tokio's threaded blocking operations.
To resolve this, Cloudflare contributed full Tokio support patchsets that are currently under upstream review, with the first target support patch already accepted. These advancements allowed engineers to run a Rust-native Minecraft server inside a Durable Object with TCP ingress using real TCP sockets via Tokio.
Cloudflare has made experimental patchsets and example applications available, including resources for building Emscripten Rust Workers and utilizing TCP Sockets on Workers with Emscripten and Tokio.
Sources
- Cloudflare BlogSupporting native Rust in Workers with the new Emscripten target for wasm-bindgen