-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Always generate the same output structure with bindgen!
#8721
Always generate the same output structure with bindgen!
#8721
Conversation
Currently with the `bindgen!` macro when the `with` key is used then the generated bindings are different than if the `with` key was not used. Not only for replacement purposes but the generated bindings are missing two key pieces: * In the generated `add_to_linker` functions bounds and invocations of `with`-overridden interfaces are all missing. This means that the generated `add_to_linker` functions don't actually represent the full world. * The generated module hierarchy has "holes" for all the modules that are overridden. While it's mostly a minor inconvenience it's also easy enough to generate everything via `pub use` to have everything hooked up correctly. After this PR it means that each `bindgen!` macro should, in isolation, work for any other `bindgen!` macro invocation. It shouldn't be necessary to weave things together and remember how each macro was invoked along the way. This is primarily to unblock bytecodealliance#8715 which is running into a case where tcp/udp are generated as sync but their dependency, `wasi:sockets/network`, is used from an upstream async version. The generated `add_to_linker` does not compile because tcp/udp depend on `wasi:sockets/network` isn't added to the linker. After fixing that it then required more modules to be generated, hence this PR.
@@ -136,9 +136,10 @@ pub mod sync { | |||
async: false, | |||
with: { | |||
"wasi:http": crate::bindings::http, // http is in this crate | |||
"wasi:io": wasmtime_wasi::bindings::sync, // io is sync | |||
"wasi:io": wasmtime_wasi::bindings::sync::io, // io is sync |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a bug from before this PR and probably shouldn't have ever worked...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @MendyBerger can you see if this improves any of the code we looked at together earlier this week?
@pchickey I'm unable to get the code to compile when I rebase on top of this git rev. |
Currently with the
bindgen!
macro when thewith
key is used then the generated bindings are different than if thewith
key was not used. Not only for replacement purposes but the generated bindings are missing two key pieces:In the generated
add_to_linker
functions bounds and invocations ofwith
-overridden interfaces are all missing. This means that the generatedadd_to_linker
functions don't actually represent the full world.The generated module hierarchy has "holes" for all the modules that are overridden. While it's mostly a minor inconvenience it's also easy enough to generate everything via
pub use
to have everything hooked up correctly.After this PR it means that each
bindgen!
macro should, in isolation, work for any otherbindgen!
macro invocation. It shouldn't be necessary to weave things together and remember how each macro was invoked along the way. This is primarily to unblock #8715 which is running into a case where tcp/udp are generated as sync but their dependency,wasi:sockets/network
, is used from an upstream async version. The generatedadd_to_linker
does not compile because tcp/udp depend onwasi:sockets/network
isn't added to the linker. After fixing that it then required more modules to be generated, hence this PR.