bytecodealliance / bytecodealliance/componentize-dotnet

Referencing a project that exposes WIT bindings gives linker error

Đang mở
#92 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C#
Star
147
Fork
18
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

**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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện bản build với tệp WIT định nghĩa world `host` và hàm `foobar` được import của nó, sau đó kiểm tra project C# import tệp WIT và project F# tham chiếu đến tệp đó. Chạy build của component có và không gọi `HostWorld.exports.HostWorld.Foobar ()`; hoàn tất có nghĩa là đã xác định được cấu hình và việc link thành công, hoặc giới hạn đã được ghi lại.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
csharp, fsharp, wasm
Lĩnh vực
build-system
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.