Build Failure with Inline WIT with `wit-bindgen`
还没有人认领这个 Issue。
- #191 来自 @tqwewe —— 已关闭,未合并
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- rust, wasm
- 领域
- build-system, cli
调研方向
从链接的复现仓库及其 lib.rs 中的 wit_bindgen::generate! 内联定义开始,然后为 guest package 运行文档中说明的手动 cargo/wasm-tools 序列和 cargo component build。比较运行 host package 时产生的行为;当两条构建路径都成功运行并显示“Hello, World!”时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Description
There's an inconsistency when building a project with inline WIT definitions using cargo component build. It fails under cargo component but succeeds when manually building with cargo and wasm-tools with wit-bindgen given the following lib.rs:
wit_bindgen::generate!({
inline: r#"
package component:guest;
world example {
export example: interface {
hello-world: func() -> string;
}
}
"#,
exports: {
"example": Component
}
});
use exports::example::Guest;
struct Component;
impl Guest for Component {
fn hello_world() -> String {
"Hello, World!".to_string()
}
}
Reproduction Steps
Manual Build with Cargo and wasm-tools
- Build for
wasm32-wasitarget:cargo build --package guest --target wasm32-wasi - Create the component with wasm-tools:
wasm-tools component new ./target/wasm32-wasi/debug/guest.wasm -o ./target/wasm32-wasi/debug/guest.wasm --adapt ./wasi_snapshot_preview1.wasm - Run the host package and observe successful
Hello, World!message:cargo run --package host
Build with Cargo Component
- Clean previous builds:
cargo clean - Build with
cargo component:cargo component build --package guest - Observe failure when running the host package:
cargo run --package host
Expected Behavior
Both build methods should successfully compile and run the project, displaying Hello, World! regardless if we use a wit directory with cargo_component_bindings or wit-bindgen.
Actual Behavior
The build succeeds with manual steps but fails with cargo component.
Additional Information
Repository Link: GitHub Repository
Is this intended behaviour?
I think it would be ideal if we can just use cargo component with wit-bindgen as an easy way of building wasm components, though it seems like we need to stick to the structure of having a wit directory along side our src directory.
- 主要语言
- Rust
- 星标
- 593
- 派生
- 68
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
bytecodealliance/cargo-component 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 38/100
-
难度 3/5 1-2 天 新手友好度 76/100
-
难度 5/5 一周以上 新手友好度 35/100
-
难度 4/5 3-5 天 新手友好度 35/100
-
难度 3/5 1-2 天 新手友好度 48/100
bytecodealliance/cargo-component#399 · 2 条评论 ·
查看 bytecodealliance/cargo-component 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
area: settings bug Haiku review: no-score ui
难度 2/5 1-3 小时 新手友好度 78/100
MMFoundation/WallpaperMachine#346 ·
维护者通常 1 天内回复
-
Make the HTTP server's keep-alive and headers timeouts configurable可能已有人在做 @mattgodbolt 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
compiler-explorer/compiler-explorer#9902 ·
维护者通常 1 天内回复
-
documentation
难度 2/5 1-3 小时 新手友好度 68/100
jonathanong/no-mistakes#5490 ·
-
follow-up
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复