Skip to content

__getrandom_v03_custom Not Preventing wasm-bindgen Import on wasm32-unknown-unknown with Internet Computer #633

@e274426380

Description

@e274426380

Description
Hi, I'm encountering an issue where defining __getrandom_v03_custom as per the documentation (https://docs.rs/getrandom/0.3.2/getrandom/#opt-in-backends) does not prevent wasm-bindgen from being imported when targeting wasm32-unknown-unknown for deployment on the Internet Computer (IC). Despite disabling default features and enabling the custom backend via --cfg getrandom_backend="custom", the resulting WASM file still contains __wbindgen_describe imports, causing deployment failures on IC.

Expected Behavior
According to the documentation, defining __getrandom_v03_custom and enabling the custom backend should override the default wasm_js backend, avoiding the dependency on wasm-bindgen and its associated imports (e.g., __wbindgen_describe).

Actual Behavior
Even with the custom function defined and the configuration applied, wasm-bindgen is still linked into the final WASM binary, as verified by wasm-objdump -x. This leads to deployment errors on the Internet Computer, which does not support wasm-bindgen imports.

According to my query, the dependency chain is: burn -> rand -> getrandom

[package]
name = "burn_price_backend"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
candid = "0.10"
ic-cdk = "0.16"
ic-cdk-macros = "0.13"
bincode = "1.3.3"
burn = { git = "https://github.com/burn-rs/burn", default-features = false, features = ["std", "ndarray", "autodiff"] }
serde = { version = "1.0", features = ["derive"] }
getrandom = { version = "0.3.2", default-features = false }

.cargo/config.toml

[build]
rustflags = ["--cfg", "getrandom_backend=\"custom\""]
target = "wasm32-unknown-unknown"

This is my code repository:
https://github.com/e274426380/burn_price

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions