dotnet / runtimelab

This repo is for experimentation and exploring new ideas that may or may not make it into the main dotnet/runtime repo.
MIT License
1.36k stars 188 forks source link

NativeAOT-LLVM: Compile fails due to invalid cast error #2555

Closed PJB3005 closed 2 months ago

PJB3005 commented 2 months ago

I tried to compile Space Station 14's client as a test run, if only just to get a ballpark of how large the final wasm binary would be. I know full-well there's no chance in hell it's going to work just like this, but while compiling the code on Release the following error did crop up:

EXEC : error : Invalid cast (Producer: 'LLVM17.0.4' Reader: 'LLVM 18.0.0git') [E:\.nuget\microsoft.dotnet.ilcompiler.llvm\9.0.0-alpha.1.24173.1\build\ExecWrapper.proj]
  1 error generated.
E:\.nuget\microsoft.dotnet.ilcompiler.llvm\9.0.0-alpha.1.24173.1\build\ExecWrapper.proj(3,5): error MSB3073: The command ""E:\Projects\emsdk\/upstream/bin/clang++.exe" "obj\Release\wasi-wasm\native\Content.Client.7.bc" -o "obj\Relea
se\wasi-wasm\native\Content.Client.7.o" -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -disable-lsr --sysroot="D:\Downloads\wasi-sdk-20.0.m-mingw.tar\wasi-sdk-20.0.m-mingw\wasi-sdk-20.0+m\/share/wasi-sysroo
t" -target wasm32-unknown-wasi -c -O2 -g3" exited with code 1.
EXEC : error : Invalid cast (Producer: 'LLVM17.0.4' Reader: 'LLVM 18.0.0git') [E:\.nuget\microsoft.dotnet.ilcompiler.llvm\9.0.0-alpha.1.24173.1\build\ExecWrapper.proj]
  1 error generated.
E:\.nuget\microsoft.dotnet.ilcompiler.llvm\9.0.0-alpha.1.24173.1\build\ExecWrapper.proj(3,5): error MSB3073: The command ""E:\Projects\emsdk\/upstream/bin/clang++.exe" "obj\Release\wasi-wasm\native\Content.Client.4.bc" -o "obj\Relea
se\wasi-wasm\native\Content.Client.4.o" -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -disable-lsr --sysroot="D:\Downloads\wasi-sdk-20.0.m-mingw.tar\wasi-sdk-20.0.m-mingw\wasi-sdk-20.0+m\/share/wasi-sysroo
t" -target wasm32-unknown-wasi -c -O2 -g3" exited with code 1.

Reproduction branch:

Note that the project makes use of submodules: the RobusToolbox submodule in the main repo (first link) needs to be updated to point to the second link.

Error occurs when doing dotnet publish -r wasi-wasm -c Release /p:UseAppHost=false inside Content.Client on those branches.

NativeAOT-LLVM version: 9.0.0-alpha.1.24173.1 Emscripten SDK version: 3.1.47 WASI SDK version: 22.0

SingleAccretion commented 2 months ago

Fixed in #2556. In have confirmed also that the project compiles successfully after that.