Foster icon indicating copy to clipboard operation
Foster copied to clipboard

browser-wasm support via NativeAOT-LLVM

Open thibaudio opened this issue 5 months ago • 3 comments

Hi!

As the title says, I'm trying to add browser-wasm support via NativeAOT-LLVM. It looks like the library is built correctly, and I reference it with an updated Sample/Shapes.csproj:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net9.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
    </PropertyGroup>

    <PropertyGroup>
        <IsBrowser>true</IsBrowser>
        <IsAotCompatible>false</IsAotCompatible>
        <PublishTrimmed>true</PublishTrimmed>
        <SelfContained>true</SelfContained>
        <MSBuildEnableWorkloadResolver>false</MSBuildEnableWorkloadResolver>
        <DefineConstants>EMSCRIPTEN</DefineConstants>
    </PropertyGroup>
    
    <ItemGroup>
        <PackageReference Include="Microsoft.DotNet.ILCompiler.LLVM" Version="10.0.0-*" />
        <PackageReference Include="runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM" Version="10.0.0-*" />
        <PackageReference Include="FosterFramework" Version="0.2.3" GeneratePathProperty="true"/>
        <DirectPInvoke Include="FosterPlatform" />
        <DirectPInvoke Include="SDL3" />
        <NativeLibrary Include="$(PkgFosterFramework)\runtimes\browser-wasm\native\libFosterPlatform.a" />
        <NativeLibrary Include="$(PkgFosterFramework)\runtimes\browser-wasm\native\libSDL3.a" />
    </ItemGroup>
</Project>

For the moment, the game doesn't launch in the browser, with the following error, apparently referencing the main function: SES_UNCAUGHT_EXCEPTION: RuntimeError: indirect call signature mismatch

Will continue to work on this next week, until then I'll be happy to get any insights!

thibaudio avatar Jul 18 '25 16:07 thibaudio