Skip to content

Use manual bindings for WASIp2/3#830

Open
newpavlov wants to merge 5 commits intomasterfrom
wasi_manual_bindings
Open

Use manual bindings for WASIp2/3#830
newpavlov wants to merge 5 commits intomasterfrom
wasi_manual_bindings

Conversation

@newpavlov
Copy link
Member

Closes #827

#[cfg_attr(target_env = "p3", link(wasm_import_module = "wasi:random/random@0.3.0-rc-2026-01-06"))]
unsafe extern "C" {
#[link_name = "get-random-u64"]
safe fn get_random_u64() -> u64;
Copy link
Member Author

@newpavlov newpavlov Mar 12, 2026

Choose a reason for hiding this comment

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

@alexcrichton
Is it fine to use u64 here instead of i64 used by the auto-generated bindings? Otherwise it looks somewhat weird to get i64 from a function named get_random_u64.

Copy link
Member Author

@newpavlov newpavlov Mar 12, 2026

Choose a reason for hiding this comment

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

Also, would random@0.3.0-rc-2026-01-06 continue to work after WASI v0.3.0 is released in the same way as was explained by you here? (obviously assuming that get-random-u64 is not changed)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it fine to use u64 here instead of i64 used by the auto-generated bindings?

yep!

Also, would random@0.3.0-rc-2026-01-06 continue to work after WASI v0.3.0 is released in the same way as was explained by you here?

Alas, no, for all future rcs it'll require an update here to change the version string. Once WASIp3 is officially released as 0.3.0 this can be updated to 0.3.0 and that'll be it.

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.

Why do we depend on wit-bindgen as a regular dependency

2 participants