Stream: C#/.net-collaboration

Topic: Wasm shadow stack


view this post on Zulip jonas echterhoff (Apr 11 2025 at 12:19):

Hi. I am using ilc with llvm (from componentize-dotnet) on linux to build a wasm executable. I am linking the bc files generated by ilc together with a C-based library (built with emscripten), and am trying to call from C# into C by declaring methods like this:

[RuntimeImport(Path, nameof(CreateWorld))]
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern World* CreateWorld();

This works for native excecutables, but in wasm i get a mismatch in calling conventions between emscripten and ilc. ilc seems to add an additional first parameter to each function, which I think is used to manage a shadow stack used by the GC. I have two questions:

  1. Can I somehow declare external methods as not using this calling convention and drop the first parameter?
  2. Can I tell ilc to completely disable the shadow stack, as we have a scenario where we use the C# language, but all data is unmanaged, and we don't need a GC.

(Also, is this the right place for such questions? If not, do you know what is? Thanks!)

view this post on Zulip Ralph (Apr 11 2025 at 13:25):

it's the right place!

view this post on Zulip James Sturtevant (Apr 11 2025 at 16:04):

@jonas echterhoff I don't know the answer to that one of the top of my head. @Scott Waye might and there are some folks who maintain that part of the stack in the .net llvm discord channel https://discord.com/channels/143867839282020352/1141126727028985877

Discord is great for playing games and chilling with friends, or even building a worldwide community. Customize your own space to talk, play, and hang out.

view this post on Zulip jonas echterhoff (Apr 12 2025 at 11:07):

Thanks! I'm going on vacation today, but will follow up on discord once I'm back (unless someone here will have the answer until then).


Last updated: Dec 13 2025 at 17:03 UTC