I'm trying to follow the guide here for compiling C# as a WASM component, but I'm getting an error:
Restore complete (0.4s)
You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
dotnet-guest-test failed with 1 error(s) (2.8s) → bin/Debug/net9.0/wasi-wasm/dotnet-guest-test.dll
/home/seanomik/.nuget/packages/microsoft.dotnet.ilcompiler.llvm/10.0.0-alpha.1.24525.6/build/Microsoft.NETCore.Native.targets(363,5): error MSB3073: The command ""\tools\\ilc" @"obj/Debug/net9.0/wasi-wasm/native/dotnet-guest-test.ilc.rsp"" exited with code 127.
I'm on Arch Linux and installed dotnet-sdk-preview-bin
to get dotnet 9.0. I tried to switch the target to 8.0, but got the same error. I even tried to downgrade dotnet to 8.0, but that didn't change anything. I tried to build the project in a podman container using mcr.microsoft.com/dotnet/sdk:9.0
which is based off of Debian 12, but got the same error.
Any help appreciated!
My understanding is that componentize-dotnet and specifically the NativeAOT compiler are not supported on Linux yet, see the note under Getting Started: https://bytecodealliance.org/articles/simplifying-components-for-dotnet-developers-with-componentize-dotnet
Damn, okay. I didn't see that page. Maybe I'll make a windows vm just for compiling this component then lol. I actually found a PR that was opened a week ago on the componentize-dotnet repo to fix linux support. I tried that fork, but it didn't fix it :sad: so I made a comment.
I've used componentize-dotnet
on Linux, although I had to hack a few files to make it work. Since then, I think those fixes have been upstreamed, so I would have expected it to work out-of-the-box at this point. @James Sturtevant would you expect that to work?
Its possible I'm missing a required system package. I'm pretty new to compiling C# to WASM, and relatively new to C# in general. All I did was install the dotnet 9.0 preview, the exact version is9.0.100-rc.2.24474.11
. I have Rust stable and nightly installed. Not sure if I need to install something else.
James is PDT, so he'll not quite be up yet..... but I think Joel is correct.
It does work on Linux but there is a bug when the pacakges are published to nuget via a Windows machine: It always hard links the windows LLVM compiler: https://github.com/bytecodealliance/componentize-dotnet/issues/55. If you build the pacakge on linux you get the opposite affect.
After adding componentize-dotnet dep, You should be able to manualy add the correct LLVM pacakge with: dotnet add runtime.linux-x64.Microsoft.DotNet.ILCompiler.LLVM
. If you are on the latest preview of .net9 then a dotnet publish
is required to generate the package.
Been working on resolving this in https://github.com/bytecodealliance/componentize-dotnet/pull/54 but ran into some issues with the latest preview version on .net9, mainly some of the build flags changed leading to the same issues you've seen in https://github.com/bytecodealliance/componentize-dotnet/pull/54#issuecomment-2459742388
SeanOMik said:
Maybe I'll make a windows vm just for compiling this component then lol.
I would try building it using the Windows version running in Wine, it may work just fine.
in my experience installing Wine is much easier than creating a Windows VM (unless you already have a VM image lying around)
James Sturtevant said:
It does work on Linux but there is a bug when the pacakges are published to nuget via a Windows machine: It always hard links the windows LLVM compiler: https://github.com/bytecodealliance/componentize-dotnet/issues/55. If you build the pacakge on linux you get the opposite affect.
After adding componentize-dotnet dep, You should be able to manualy add the correct LLVM pacakge with:
dotnet add runtime.linux-x64.Microsoft.DotNet.ILCompiler.LLVM
. If you are on the latest preview of .net9 then adotnet publish
is required to generate the package.
That fixed it, that must have been what I was missing! I struggled a bit with getting my wit world to work with bindgen, but eventually figured it out. Thanks!!
Jacob Lifshay said:
SeanOMik said:
Maybe I'll make a windows vm just for compiling this component then lol.
I would try building it using the Windows version running in Wine, it may work just fine.
I'll have to try that if I do end up needing it. I wasn't sure it would work on wine since its dev stuff, not application stuff, but its worth a shot next time.
Glad it worked! I am trying to resolve that issue to make a smoother expereince but msbuild hasn't played nicely so far.
Last updated: Nov 22 2024 at 16:03 UTC