Skip to content

fix: resolve wasm build failure by updating burn deps and removing getrandom workaround#144

Merged
antimora merged 4 commits intotracel-ai:mainfrom
antimora:fix/wasm-getrandom-feature
Feb 11, 2026
Merged

fix: resolve wasm build failure by updating burn deps and removing getrandom workaround#144
antimora merged 4 commits intotracel-ai:mainfrom
antimora:fix/wasm-getrandom-feature

Conversation

@antimora
Copy link
Collaborator

@antimora antimora commented Feb 10, 2026

Summary

Fixes #135 - wasm build of image-classification-web fails because getrandom requires explicit backend configuration on wasm32-unknown-unknown.

Root cause

The getrandom crate was being pulled into the wasm build through a chain of unconditional std feature propagation: burn-wgpu -> cubecl/std -> cubek/std -> cubecl/std (circular) -> getrandom/std. On wasm32-unknown-unknown, getrandom requires either the wasm_js or wasm_wasi feature to be explicitly enabled.

Fix (3 repos)

  1. cubecl (tracel-ai/cubecl#1184, merged) - Stop unconditional std feature propagation
  2. cubek (tracel-ai/cubek#86, merged) - Decouple from cubecl/std
  3. burn (tracel-ai/burn#4500, merged) - Upgrade rand 0.9 to 0.10, update cubecl/cubek revs
  4. burn-onnx (this PR):
    • Remove getrandom dependency and burn-store/std feature from wasm example
    • Remove --cfg getrandom_backend="wasm_js" workaround from build-for-web.sh
    • Remove unused serde_json and js-sys dependencies from wasm example
    • Update burn deps to merged PR #4500 rev

Changes

  • examples/image-classification-web/Cargo.toml - removed getrandom dep, burn-store/std feature, unused serde_json and js-sys
  • examples/image-classification-web/build-for-web.sh - removed --cfg getrandom_backend="wasm_js" from RUSTFLAGS
  • Cargo.toml - updated burn git rev to tracel-ai/burn merged commit (PR #4500)
  • Cargo.lock - updated

Test plan

  • cargo test -p onnx-ir -p burn-onnx -p onnx-tests all pass
  • wasm-pack build succeeds for SIMD variant (wasm32-unknown-unknown)
  • wasm-pack build succeeds for non-SIMD variant (wasm32-unknown-unknown)
  • Full build-for-web.sh script passes
  • No --cfg getrandom_backend workaround needed
  • CI passes

Tested locally:

image

Copilot AI review requested due to automatic review settings February 10, 2026 20:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the wasm32-unknown-unknown build failure for the image-classification-web example caused by getrandom 0.3 requiring an explicit wasm backend configuration, by removing the local workaround/dependency and updating Burn/CubeCL-related deps so getrandom is no longer pulled in the problematic way.

Changes:

  • Removed the --cfg getrandom_backend="wasm_js" workaround from the web build script.
  • Removed the getrandom dependency and the burn-store/std feature override from the wasm example.
  • Updated Burn git dependencies (and Cargo.lock) to incorporate the rand/rand_core upgrade chain needed for the broader fix.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
examples/image-classification-web/build-for-web.sh Drops the getrandom_backend RUSTFLAGS workaround for wasm builds.
examples/image-classification-web/Cargo.toml Removes direct getrandom usage and avoids enabling burn-store’s std feature in the wasm example.
Cargo.toml Updates workspace Burn git dependencies to a revision containing the rand upgrade (currently via a fork).
Cargo.lock Locks updated dependency graph reflecting Burn/CubeCL/CubeK updates and rand/getrandom reshaping.

@antimora antimora force-pushed the fix/wasm-getrandom-feature branch from d6c8ec5 to c3430a0 Compare February 10, 2026 20:59
Remove the getrandom wasm_js dep and burn-store/std feature.
These are no longer needed after upstream fixes in cubecl
(tracel-ai/cubecl#1184) and cubek (tracel-ai/cubek#86) that
stop unconditional std feature propagation.

Fixes tracel-ai#135
Point burn deps at antimora/burn@6d0c9bd which includes the rand 0.9
to 0.10 upgrade. This resolves the getrandom 0.3 issue on
wasm32-unknown-unknown since the upstream cubecl/cubek fixes now
properly propagate through burn.

Also removes the --cfg getrandom_backend="wasm_js" workaround from
build-for-web.sh since it is no longer needed.
Update burn dependency from fork to tracel-ai/burn merged commit
(PR #4500) which includes the rand 0.10 upgrade. Also remove unused
serde_json and js-sys dependencies from image-classification-web.
@antimora antimora force-pushed the fix/wasm-getrandom-feature branch from 9059c7d to 8a7a9cb Compare February 11, 2026 01:11
@antimora
Copy link
Collaborator Author

@laggui , thank you for assistance with this matter!

@antimora antimora changed the title fix: resolve wasm build failure from getrandom 0.3 fix: resolve wasm build failure by updating burn deps and removing getrandom workaround Feb 11, 2026
@antimora antimora merged commit cee7b39 into tracel-ai:main Feb 11, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compiling "Image Classification Web Demo Using Burn and WebAssembly"

1 participant