cannot import/export a component interface from dotnet.wasm to wasmtime #113868
Labels
arch-wasm
WebAssembly architecture
area-Interop-mono
needs-author-action
An issue or pull request that requires more info or actions from the author.
os-wasi
Related to WASI variant of arch-wasm
Milestone
Description
Since .NET 9, wasi-wasm defaults to generating a component.
In component mode, I cannot export functions using
UnmanagedCallersOnly
(this can only be exported in the Core Module, not at the Component Level). However, because export statements are generated in the Core Module, I can forcibly export functions at the Component level by modifying the wat, which barely solves the problem—even though it’s rather inelegant.However, I still cannot import a function. If I use:
[DllImport("example:component/im", EntryPoint = "add5678")]
this will not generate any import statements in the wat. If I add
WasmImportLinkage
, a linking error occurs:_failed to resolve import example:component/im::add5678_
My goal is to have the wasmtime rust API define the function
add5678
, rather than having it defined by another Component wasm.I hope there is a way to generat a Core Module instead of a Component. Then I can choose whether to manually generate a Component using
wasm-tools component new
or find another way to handle import/export functions for the host.It's difficult for me to use
because my use case includes iOS, and iOS doesn't support AOT. (I noticed that the last version of runtime.iossimulator-x64.Microsoft.DotNet.ILCompiler was released on 2023/7/11, so I believe it is no longer usable.)
Reproduction Steps
Expected behavior
I hope
dotnet build -c Release
can compile successfully and generate dotnet.wasm.Actual behavior
And, if I remove the
WasmImportLinkage
,dotnet build
will be success, but cannot found anyimport ... add5678
fromwasm-tools print .\bin\Release\net10.0\wasi-wasm\AppBundle\dotnet.wasm
Regression?
In the era of generating Core Modules, import/export was possible.
Known Workarounds
No response
Configuration
.Net version: .net 10 preview1
OS: windows
architecture: x64
discuss for wasi-wasm
Other information
No response
The text was updated successfully, but these errors were encountered: