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

未关闭 适合新手
#136,693 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
csharp, wasm
领域
build-system

调研方向

从 Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk 中的 .NET 10 文件 WasiApp.targets 开始,并将其 SIMD 标志与 .NET 11 版本进行比较。运行报告中的复现命令 dotnet publish -c Release;当 AOT 发布成功并生成一个输出 42 的应用时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
C#
星标
18.4k
派生
5.8k
平均合并
2 天 15 小时
30 天内合并 PR
620

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

dotnet/runtime 的其他 Issue

查看 dotnet/runtime 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。