Uh oh!
There was an error while loading. Please reload this page.
[wasm] Implement initial support for WasmImportLinkage in the AppBuilders - #94615
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
ghost
commented
Nov 16, 2023
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsAfter #94615 merged this is a quick hacky fix for #94513, #86984, and #86985 Using [WasmImportLinkage][DllImport("extism:host/user")]publicstaticexternvoiddo_something();Will generate (type$i64_i32_=>_i64 (func (parami64i32) (resulti64)))
(type$i32_i64_i64_i32_=>_none (func (parami32i64i64i32)))
(import"wasi_snapshot_preview1""sock_accept" (func$fimport$0 (parami32i32i32) (resulti32)))
(import"extism:host/user""do_something" (func$fimport$1))
(import"wasi_snapshot_preview1""args_get" (func$fimport$2 (parami32i32) (resulti32)))
|
added export support (edited to reflect the current state) [UnmanagedCallersOnly(EntryPoint="display_meaning")]publicstaticvoidDisplayMeaningExport(intmeaning){Console.WriteLine($"The meaning of life is {meaning}");} (export"display_meaning" (func$13484))There is currently an issue with when invoking the export from unmanged when there is no managed delegate pointing to it that will not be dealt with in this PR. A temporary workaround is shown in the sample app Intptrworkaround=(IntPtr)(delegate* unmanaged<int,void>)&display_meaning;// needs to be in method loaded by interp prior to unmanaged call |
SingleAccretion
commented
Nov 16, 2023
The attribute was not meant to enable exports. They are meant to be enabled by simply using |
ero-qt
commented
Nov 16, 2023
I apologize upfront if this is already up for consideration or an entirely inappropriate suggestion; I think I would personally prefer if it were just [WasmImport("extism:host/user")]publicstaticexternvoiddo_something(); |
lewing
commented
Nov 16, 2023
I'm aware, this is explicitly, as mentioned in the description, a quick hack to test out the changes. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
RReverser
commented
Nov 21, 2023
Oh this is awesome. I just finished rewriting bindings in our project for .NET 8, looks like I'll have to rewrite them again, but this removes some of the hacks I had to do so it's a win. How can one try this PR out? Will it be available via |
The packages will need to be built in an official build then flow through the darc update process (hours, sometimes longer) until they hit https://github.com/dotnet/installer then you should be able to follow the instructions on the front page to download the latest 9.0-alpha.1 build (make sure to add the nuget feeds too) and then the workload commands should work. |
The API discussion is here #93824 |
RReverser
commented
Nov 22, 2023
Ah, in that case I'll have to wait I guess. I thought it might be possible to get |
There is the possibility that we could consider servicing some of these fixes in net8.0 |
RReverser
commented
Nov 22, 2023
That would be amazing. Having to manually wrap imports/exports via custom C file is the biggest remaining hurdle for us after migrating from Wasi.Sdk to .NET 8 WASI support, and it's a shame that this fix juuuust didn't make the release cut. As we're providing a sort of Wasm hosting, where we provide a project template and users do |
silesmo
commented
Nov 22, 2023
That would be great! |
RReverser
commented
Nov 22, 2023
Btw, one more issue we were seeing is that for Structs have well-defined ABI in Wasm C ABI, so this shouldn't be a problem and structs with fixed layout should be allowed like they are on other platforms. At the very least it would be useful to allow a struct with a single field, since Wasm C ABI says those have the same ABI as their field. This is useful for creating typechecked handles where a |
@kg has been looking into this I'd recommend opening an issue here where we can discuss it |
Just to set expectations the official leading edge will always be |
jkotas
commented
Nov 23, 2023
I think it is unlikely that addition of WasmImportLinkageAttribute would be approved for servicing. The default bar for servicing is bug fixes only. WasmImportLinkageAttribute is a new feature. |
As written this change supports any Attribute named WasmImportLinkageAttribute it also supports valid uses of EntryPoint on UCO that were broken before (with user reports) and there are first party considerations and it is a build task specific to wasm, what are your concerns? |
silesmo
commented
Nov 23, 2023
lewing
commented
Nov 23, 2023
|


In response to #93823 this is a rough partial fix for #94513, #86984, and #86985
With the default settings this works in wasi-wasm but emscripten will complain if you don't enable unresolved symbols on browser-wasm
Using
Will generate