Unknown placeholder import in wasm32-unknown-unknown #822
Labels
No labels
breaking
bug
dependencies
good first issue
help wanted
unstable
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-uuid-rs/uuid#822
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi,
When i am trying to build my project containing the following uuid dependency :
uuid = {version = "1.16.0", features = ["v4", "js"]}The .wat file contains these imports including the placeholder import that are creating issue in my usage of the wasm binary.
Is there something that i am missing here?
Thanks!
Steps to reproduce the issue :
Cargo.tomluuid::Uuid::new_v4()wasm32-unknown-unknown. Runcargo build --target wasm32-unknown-unknown --release.wasm-tools print target/wasm32-unknown-unknown/release/<library_name>.wasm -o <library_name>.watHi @dvn8weil 👋 I'm not entirely sure what the issue is here. It doesn't look especially
uuidspecific.uuiddoesn't usegetrandomby default anymore, do you still see the issue if you enable therng-getrandomorrng-randfeatures ofuuid? Keep in mind these are based ongetrandom0.3, and not0.2.Are you also building with the latest versions of
rustcandwasm-bindgen?Just coming back through some triage, I'm not quite sure what happened here, but if it's still an issue please feel free to re-open and we can try digging in deeper.
Hi, apologies for the late reply :
I removed the
get_randomdependency.Cargo.toml:but in the .wasm file , i get after
cargo build --target wasm32-unknown-unknown --release, and converting it to .wat file bywasm-tools print target/wasm32-unknown-unknown/release/uuid_test.wasm -o uuid_test1.watthere is still the placeholder import :
(import "__wbindgen_placeholder__" "__wbindgen_describe" (func $_ZN12wasm_bindgen19__wbindgen_describe17hd20bcaa9ef979b7fE (;2;) (type 3)))@dvn8weil What platform are you trying to use your wasm in? And what’s the issue you’re running in to with those imports?
@KodrAus Hi, I am just compiling the rust project with
cargo build --target wasm32-unknown-unknown --release. Therein when i convert the .wasm file into .wat for better readability, it contains (the .wat file) such placeholder imports.These imports shouldn't be present when using wasm32-unknonwn-unknown compatible dependencies.
I have updated my rustc with all its components, as well wasm-tools.
Hmm, do you know what the presence of these placeholders implies? Does it mean there’s a call somewhere to a function that isn’t being bindgen’d? It’s a bit tricky to tell exactly where the issue is here or how to fix it.
uuidis already used in wasm environments pretty heavily so there must be some missing piece here.I'm going to re-open this in case there's something we're doing/not doing here in
uuidthat's causing these imports to be added. I'm not sure yet whether these imports represent an issue withuuid, or an issue with the use-case. If they're always generated then doeswasm-bindgenproduce glue code that handles them?I think it should be then that these imports will be handled by the runtime environment/medium , such as browser or node.js.
So if uuid with the dependencies as this , is supported by those runtime environments, functions for these imports must be provided by those envs.
Ok, I've had a fresh look at this, and I believe the problem here is coming from the wasm RNG implementation used by
getrandom, which we've also inlined intouuidthrough itsjsfeature.Those bindings require a table to work, probably because of their use of
Uint8Array. Inuuid, we might be able to work around this, since we never need to fill more than 16 bytes of random values. Since we inlined that code I'm not 100% sure what the failure modes it's protecting against are.It doesn't look like removing the use of
Uint8Arrayremoves those references. You can get rid of them though by configuringuuidto usegetrandomvia therng-getrandomfeature, and configuringgetrandomto use a custom backend, which you can then implement based on whatever your target has available.