bytecodealliance / bytecodealliance/componentize-dotnet

Referencing a project that exposes WIT bindings gives linker error

オープン
#92 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
C#
スター
147
フォーク
18
PR マージ指標
30日以内にマージされた PR はありません

説明

**Background**: I am interested in compiling F# to a WASM component. So far, I've managed to get a simple WASI "Hello, world!" program compiling and running using componentize-dotnet. For the next step, I wanted to access host bindings exposed via a WIT file. Since `wit-bindgen` generates C#, and not F# source files, it does not seem like I can do this directly from F#.

What I have experimented so far is creating a new C# Project which imports the wit file, and then reference this C# project from F#. With this setup, the auto-generated host bindings seem to be accessible to F#. However, I get some kind of link error when trying to build the project:
```rust
error: failed to encode component

Caused by:
0: failed to decode world from module
1: module was not valid
2: no top-level imported function `foobar` specified
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```
Here, `foobar` is a function that I am exposing from my wit file:
```wit
package example:host;
world host {
import foobar: func ();
}
```

This error only occurs when actually calling `HostWorld.exports.HostWorld.Foobar ()` somewhere from the F# project or from the C# project.

Is there some combination of configurations that could make this setup work? If there is, it would be nice for this to be documented somewhere since I could not find any relevant information.

Environment:
- `BytecodeAlliance.Componentize.DotNet.Wasm.SDK`: 0.7.0-preview00010
- `runtime.linux-x64.microsoft.dotnet.ilcompiler.llvm`: 10.0.0-alpha.1.25162.1
- OS: Linux x64
- .NET: 10.0.100-preview.6

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、`host` world とインポートされた `foobar` 関数を定義する WIT ファイルでビルドを再現し、次に WIT ファイルをインポートする C# プロジェクトと、それを参照する F# プロジェクトを調査します。`HostWorld.exports.HostWorld.Foobar ()` を呼び出す場合と呼び出さない場合でコンポーネントのビルドを実行します。設定が特定されてリンクが成功するか、または制限事項が文書化されれば完了です。

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

評価

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

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

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