Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AOT LLVM - Issue migrating from 8 to 9 (bad wasm file version: 0x1000d (expected 0x1)) #2685

Closed
sardonic1 opened this issue Sep 11, 2024 · 3 comments
Labels
area-NativeAOT-LLVM LLVM generation for Native AOT compilation (including Web Assembly)

Comments

@sardonic1
Copy link

I have a wasi-wasm project compiling a WASM successfully under the 8.x compiler, validated by wabt, and running in a Chicory runtime. E.g.

<PackageReference Include="Microsoft.DotNet.ILCompiler.LLVM" Version="8.0.0-*" />
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler.LLVM" Version="8.0.0-*" />

However, when I try to switch to the 9.x compiler e.g.

<PackageReference Include="Microsoft.DotNet.ILCompiler.LLVM" Version="9.0.0-*" />
<PackageReference Include="runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM" Version="9.0.0-*" />

A WASM is output with the WASM magic number, but a version of 0x1000d as reported by wabt wasm_validate. Is this by design? Has the 9.x compiler moved beyond and no longer supporting version 1 or is there some silent failure munging the output wasm bytes?

@jkotas jkotas added the area-NativeAOT-LLVM LLVM generation for Native AOT compilation (including Web Assembly) label Sep 12, 2024
@SingleAccretion
Copy link

SingleAccretion commented Sep 12, 2024

A WASM is output with the WASM magic number, but a version of 0x1000d as reported by wabt wasm_validate. Is this by design?

Yes, this is expected.

In .NET 9, we (.NET in general) have moved to depending on WASI Preview 2 (as opposed to WASI Preview 1), and producing WASM Components instead of core WASM modules. The components use a distinct binary format, which is why you see validation errors.

If you are unable to change the WASM runtime in use (to one that supports running components natively, e. g. wasmtime), I am afraid staying on .NET 8 is the only option for the time being. In the longer term, we may bring back the ability to produce core WASM modules (see WebAssembly/component-model#378), but they would still depend on WASI P2 APIs.

@dotnet/nativeaot-llvm

@pavelsavara
Copy link
Member

pavelsavara commented Sep 12, 2024

In the longer term, we may bring back the ability to produce core WASM modules

I would strongly prefer not to do that, because we don't have resources to support too many build configurations and tooling.

WASI preview 1 is dead end.

@pavelsavara pavelsavara closed this as not planned Won't fix, can't repro, duplicate, stale Sep 12, 2024
@pavelsavara
Copy link
Member

pavelsavara commented Sep 12, 2024

Also we now consume WASIp2 APIs directly (not via libc shims) so there is truly no way back.
wasi-libc would eventually become also just dependent on p2 or p3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-NativeAOT-LLVM LLVM generation for Native AOT compilation (including Web Assembly)
Projects
None yet
Development

No branches or pull requests

4 participants