`cargo component build` `error: decoding custom section` after update from `0.25` to `0.26`
After upgrading wit-bindgen, the following error occurred during cargo component build
Creating component /workspaces/product/components/target/wasm32-wasi/debug/test.wasm
error: decoding custom section component-type:wit-bindgen:0.26.0:platform:encoded world
Caused by:
unexpected end-of-file (at offset 0x4c70)
while cargo build --target wasm32-wasi works perfectly.
cargo expand for both versions results in this
diff 0.25.rs 0.26.rs
1198c1198
< #[link_section = "component-type:wit-bindgen:0.25.0:transformer:encoded world"]
---
> #[link_section = "component-type:wit-bindgen:0.26.0:transformer:encoded world"]
1207,1208c1207,1208
< cers\x01\x0cprocessed-by\x02\x0dwit-component\x070.208.1\x10wit-bindgen-rust\x06\
< 0.25.0";
---
> cers\x01\x0cprocessed-by\x02\x0dwit-component\x070.209.1\x10wit-bindgen-rust\x06\
> 0.26.0"
Any ideas? Could it be related to any changes in 0.26 that are not compatible with cargo-components 0.25?
Off the top of my head I don't know what could be causing this, do you have a repository/example/reproduction that could be poked around?
@alexcrichton I've run into this and made a repro here. Using the build-plug script to make the component brings about the issue at hand.
The most interesting thing about the repo is that I'm trying to house the bindings generated by the macro in an sdk crate that the actual component crates import and use. This includes WIT import and exports.
I notice that the wasi-rs repo seems to have statically expanded the macro output, is that limitation driven?
And yeah, I'm on wasm-tools 1.215.0.
Thanks @dman-os for the reproduction! That should be fixed in https://github.com/bytecodealliance/wit-bindgen/pull/1029. In the meantime you can additionally fix it by specifying type_section_suffix: "suffix", around here. The problem is you have two worlds named imports and the suffix is needed to disambiguate. The suffix will no longer be required after #1029