Just a heads up that I will be publishing 0.9.0 of cargo-component
shortly, which will include a breaking change introduced with wit-bindgen
0.20.0.
It was decided that we'd return to using a generated export!
macro that accepts the name of the type implementing the world (typically Component
in cargo-component
projects).
This was done for good reason: now the generated code does not refer to any user-defined types directly and it also moves naming the implementing types out of Cargo.toml
into type-checked Rust source.
Besides adding this macro invocation to your cargo-component
projects, there are additional steps to take if you're implementing worlds that export resources: a trait-associated type now names the type implementing the resource.
I'll have detailed instructions in the release notes.
Apologies again for the whiplash here on generated bindings and effort in cargo component
to adapt to this, but my hope is that this is well worth the change!
@Alex Crichton now that we have most of what was in the rt
module of wit-bindgen
now generated, do you think it might be possible to refactor the realloc
feature out as a separate crate that we could reexport from wit-bindgen
(and also perhaps the reexport of bitflags
), like a wit-bindgen-rt
crate?
The reason I ask is that currently cargo-component
user projects add a wit-bindgen
dependency with no-default-features
and features = ["realloc"]
; this happens via an implicit cargo add
when cargo component new
is run.
However, if a user specifies the dependency at the workspace level, cargo add
refuses to add it at a workspace member level because of no-default-features
(despite being set the same).
If we had a crate that exported everything we needed for "runtime" that we could activate without feature flags, I think that would probably be a better DX; cargo-component
would just add a dependency to the "rt" crate and not wit-bindgen
at all (we still have Opts::runtime_path
that cargo-component
can use to switch it to wit_bindgen_rt
or whatever in the bindings).
I like that idea yeah, I can work on adding that :+1:
https://github.com/bytecodealliance/wit-bindgen/pull/876
One last thing: would it be possible to kick off a publish job to get 0.20.0 of wit-bindgen-rt
on crates.io? While it won't be used (reexported) from wit-bindgen
until 0.21.0, a 0.20.0 of wit-bindgen-rt
would allow me to switch cargo component new
over to it as part of this breaking change release
oh I was thinking I could do 0.20.1
oh that's also great!
thanks, Alex!
oh no, that won't work
I changed something in Opts
that's breaking
doh
yeah though I can sneak in a publish manually for this
that'd be sufficient for cargo-component
at least, appreciate it!
can do :+1:
@Peter Huene hm this may not actually work, the generated code isn't prepared to access wit-bindgen-rt
directly actually
e.g. the generated code is calling wit_bindgen::rt::maybe_link_cabi_realloc()
even via the runtime_path
and bitflags_path
Opts
?
so we'll need to add a wit_bindgen_rt_path: "..."
to the opts
oh hm
no you're right runtime_path
should work
I should probably rename that for 0.21.0 to wit_bindgen_rt_path
ok yeah no runtime_path
will work for 0.20, disregard me
Ok I have published
actually wait
I think that wit-bindgen 0.20.0 and wit-bindgen-rt 0.20.0 may conflict with each other
since they both have a symbol of the same name
cargo-component
projects will only link in the latter tho, right?
the issue stems from a workspace-level dep on wit-bindgen though, right?
so while by default cargo-component would use wit-bindgen-rt that may not be the case for all users
oh yeah, they'll have to fix the workspace dep as part of the breaking changes in this release
ah ok
I can also just make 0.21.0 if that's easier
it's just new projects they create will get it
they'll have to manually update; they shouldn't be referencing both
ok sounds reasonable
i'll document what folks need to do to get things up-and-running again; i just wanted to batch these changes together in a single release
changes look good, no more feature-flagged wit-bindgen
dep :tada:
Last updated: Nov 25 2024 at 19:03 UTC