-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
arch-wasmWebAssembly architectureWebAssembly architecturearea-System.Runtime.InteropServicesin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is mergedos-wasiRelated to WASI variant of arch-wasmRelated to WASI variant of arch-wasm
Milestone
Description
Description
As per #93824 (comment):
Not really API Review related, but would we want to have LibraryImport automatically propagate this attribute to the inner DllImport? My initial thought is yes, but just wanted to cover my bases.
Correct, this would need to be propagated.
This works as expected for simple functions that don't require any transform by the LibraryImport, but seems to be broken when using any marshalled types.
Reproduction Steps
Example:
[LibraryImport("foo")]
[WasmImportLinkage]
public static partial void test1();
[LibraryImport("foo")]
[WasmImportLinkage]
public static partial void test2(byte[] marshalMe);Expected behavior
Both functions become Wasm imports.
Actual behavior
Only simple test1 function becomes a Wasm import. The generated pinvoke-table.h looks like this:
__attribute__((import_module("foo"),import_name("test1")))
extern void SpacetimeDB_Internal_23_foo_23_test1 ();
void test2 (void *);This, in turn, results in a linker error:
wasm-ld : error : D:/.../obj/Release/net9.0/wasi-wasm/wasm/for-publish/pinvoke.o: undefined symbol: test2
Regression?
No response
Known Workarounds
- Use
DllImportwith manual marshalling, which can get pretty cumbersome when using a lot of functions. - Manually declare all functions in an extra C file with
__attribute__((import_module("foo"))applied to each of them, and add it to MSBuild linker args. This is what we did before .NET 9 asWasmImportLinkagedidn't exist yet, but it is also pretty cumbersome to maintain such a list manually.
Configuration
No response
Other information
No response
mhmd-azeez
Metadata
Metadata
Assignees
Labels
arch-wasmWebAssembly architectureWebAssembly architecturearea-System.Runtime.InteropServicesin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is mergedos-wasiRelated to WASI variant of arch-wasmRelated to WASI variant of arch-wasm
Type
Projects
Status
No status