cargo-component cannot find exported function in a world

オープン
#360 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
rust, wasm

調査の方向性

host.wit、Cargo.toml 内の [package.metadata.component.target.dependencies] エントリ、および文書化されている cargo component build コマンドから始めます。cargo-component が component:adder/add をどのように解決するかを追跡し、動作するインターフェースベースの WIT 形式と比較します。直接関数エクスポート形式が期待どおりに動作するか、その制限が文書化されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

I am following https://component-model.bytecodealliance.org/language-support/rust.html#importing-an-interface-into-a-command-component to create a command component with cargo-component.

My adder WIT was:

package component:adder;

world adder {
    export add: func(a: s32, b: s32) -> s32;
}

And my WIT for the host is

 package component:host;

 world host {
    import component:adder/add;
 }

I also added this to Cargo.toml

[package.metadata.component.target.dependencies]
"component:adder" = { path = "../guest-adder/wit" }

But when I ran cargo component build, I got

error: failed to create a target world for package `host-command-component` (/Users/zhiqiu/offline_code/opensource/wasi_mindmap/host-command-component/Cargo.toml)

Caused by:
    0: failed to merge local target `/Users/zhiqiu/offline_code/opensource/wasi_mindmap/host-command-component/wit`
    1: interface not found in package
            --> /Users/zhiqiu/offline_code/opensource/wasi_mindmap/host-command-component/wit/host.wit:4:28
             |
           4 |     import component:adder/add;
             |                            ^--

This took me a while to debug, but in the end, I had to write my adder WIT like:

package component:adder;

interface add {
  add: func(a: s32, b: s32) -> s32;
}

world adder {
    export add;
}

So it has add interface exported, which has an add function.

I don't think the behavior of cargo-component is expected, as in a WIT file, a world can just simply export a function.

主要言語
Rust
スター
593
フォーク
68
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

bytecodealliance/cargo-component のほかの issue

bytecodealliance/cargo-component の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。