[wasi] .NET 10: WasmEnableSIMD with AOT fails because WasiApp.targets has -msimd128 commented out

Open Beginner friendly
#136,693 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp, wasm
Domain
build-system

Research direction

Start with the .NET 10 WasiApp.targets file in Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk and compare its SIMD flag with the .NET 11 version. Run the reported dotnet publish -c Release reproduction; done means the AOT publish succeeds and produces an app that prints 42.

Written by the indexing model from the issue text.

Description

area-Build-mono untriaged
Description

With the .NET 10 SDK 10.0.401 and the wasi-experimental workload 10.0.12, a wasi-wasm app with WasmEnableSIMD and RunAOTCompilation fails to publish. WasiApp.targets in Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk 10.0.12 has the SIMD flag commented out:

<!--<_WasiClangCommonFlags Include="-msimd128"                         Condition="'$(WasmEnableSIMD)' == 'true'" />-->

so the AOT bitcode, which uses SIMD, is compiled by wasi-sdk's clang for a target without SIMD, and the LLVM backend aborts. The same line is active in the .NET 11 workload (11.0.0-rc.3.26522.148), so this looks like a fix that .NET 10 servicing is missing.

Found while building a SIMD-enabled Mono AOT baseline for the benchmarks of NetWasm, an ahead-of-time C# to WebAssembly compiler.

Reproduction Steps

macOS arm64, wasi-sdk 25.0 (the version the 10.0 targets expect), WASI_SDK_PATH set.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net10.0</TargetFramework>
    <RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
    <RunAOTCompilation>true</RunAOTCompilation>
    <WasmSingleFileBundle>true</WasmSingleFileBundle>
    <WasmEnableSIMD>true</WasmEnableSIMD>
  </PropertyGroup>
</Project>
System.Console.WriteLine(42);
dotnet publish -c Release
Expected behavior

An AOT-compiled AppBundle/Hello.wasm that prints 42, as without WasmEnableSIMD.

Actual behavior
WasmApp.Common.targets(816,5): error : Failed to compile .../obj/Release/net10.0/wasi-wasm/wasm/for-publish/aot-instances.dll.bc -> .../aot-instances.dll.o
error : clang version 19.1.5-wasi-sdk (https://github.com/llvm/llvm-project ab4b5a2db582958af1ee308a790cfdb42bd24720)
error : Target: wasm32-unknown-wasip2
fatal error: error in backend: Do not know how to split this operator's operand!
Regression?

Not checked against earlier 10.0 servicing releases. The .NET 11 RC3 targets have the line enabled.

Known Workarounds

Add <WasiClangFlags>-msimd128</WasiClangFlags> to the project. With it the app publishes and prints 42 under Wasmtime.

Configuration
  • .NET SDK 10.0.401, wasi-experimental workload 10.0.12 (manifest 10.0.112)
  • wasi-sdk 25.0 (clang 19.1.5-wasi-sdk), macOS arm64
Other information

Uncommenting the -msimd128 line in the 10.0 WasiApp.targets, as in 11.0, should fix it.

Dominant language
C#
Stars
18.4k
Forks
5.8k
Avg merge
2d 15h
Merged PRs (30d)
596

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/runtime

All issues in dotnet/runtime

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.