#10274·wgpu

wasm32-unknown-emscripten: unresolved __wbindgen_placeholder__ import prevents WebAssembly.instantiate()

Author: GuYeyingCreated Sep 7, 2026Updated Oct 1, 2026

Description

When compiling a Rust project for the wasm32-unknown-emscripten target (using emsdk 6.0.9 with emcc + Ninja), the resulting .wasm module contains unresolved __wbindgen_* and __wbg_* imports that prevent WebAssembly.instantiate() from succeeding, even when all feature flags for web backends (webgpu / webgl) are disabled.

This makes it impossible to use wgpu as a dependency in any project that targets Emscripten (e.g. SDL3-based engines that compile via cargo build --target wasm32-unknown-emscripten).

Environment

  • wgpu: 30.0.0
  • rustc: 1.85+ (edition 2024)
  • target: wasm32-unknown-emscripten
  • emsdk: 6.0.9 (emcc 6.0.9, Ninja, node 24.19.0)
  • SDL3: 3.4.12 (static, built from source via sdl3-sys)

Steps to reproduce

  1. Create a minimal lib with wgpu = "30.0.0" in [dependencies]
  2. Run: cargo check --target wasm32-unknown-emscripten
  3. The check passes at compile time (with ERROR_ON_UNDEFINED_SYMBOLS=0 tolerating unresolved symbols at link time)
  4. Deploy the .js + .wasm to a browser with an HTML shell
  5. Browser fails at instantiation:
    LinkError: WebAssembly.instantiate(): Import #19 "__wbindgen_placeholder__":
    module is not an object or function

Root cause analysis

wgpu 30.0.0's Cargo.toml declares wasm-bindgen, web-sys, and js-sys as unconditional dependencies for cfg(target_arch = "wasm32") (which includes emscripten). The compiled code references wasm-bindgen runtime symbols (__wbindgen_placeholder__, __wbg_*) that require wasm-bindgen CLI post-processing — which is only available for wasm32-unknown-unknown (not emscripten).

On the emscripten target, these symbols cannot be resolved because:

  1. wasm-bindgen CLI does not support emscripten-built wasm output
  2. Emscripten's JS glue does not provide the wasm-bindgen runtime

Impact

Any project that uses both SDL3 (via emscripten) and wgpu cannot target Web — the emscripten build is blocked at instantiation by the unresolved wasm-bindgen imports.