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.42k stars 199 forks source link

[NativeAOT-LLVM] Publishing Hello World for WebAssembly target on macOS arm64 (M1 Max) fails #2119

Open ChristianWeyer opened 1 year ago

ChristianWeyer commented 1 year ago

When trying to publish the Hello World project (https://github.com/dotnet/runtimelab/tree/feature/NativeAOT-LLVM/samples/HelloWorld) for WebAssembly target on my Apple MBP M1 Max, with this command:

dotnet publish -r browser-wasm -c Debug /p:TargetArchitecture=wasm /p:PlatformTarget=AnyCPU /p:MSBuildEnableWorkloadResolver=false --self-contained

I get the following error:

MSBuild version 17.4.0+18d5aef85 for .NET
  Determining projects to restore...
  Restored /Users/christianweyer/Sources/Microsoft.DotNet.ILCompiler.LLVM.Fiddling/HelloWorld/HelloWorld.csproj (in 752 ms).
  HelloWorld -> /Users/christianweyer/Sources/Microsoft.DotNet.ILCompiler.LLVM.Fiddling/HelloWorld/bin/Debug/net7.0/browser-wasm/HelloWorld.dll
/Users/christianweyer/.nuget/packages/microsoft.dotnet.ilcompiler.llvm/7.0.0-alpha.1.22567.1/build/Microsoft.NETCore.Native.Publish.targets(71,5): error : Add a PackageReference for 'runtime.osx-arm64.Microsoft.DotNet.ILCompiler.LLVM' to allow cross-compilation for wasm [/Users/christianweyer/Sources/Microsoft.DotNet.ILCompiler.LLVM.Fiddling/HelloWorld/HelloWorld.csproj]

However, there seems to be no such package. If I add this to my .csproj:

<PackageReference Include="Microsoft.DotNet.ILCompiler.LLVM; runtime.osx-arm64.Microsoft.DotNet.ILCompiler.LLVM" Version="7.0.0-*" />

and try to restore, this is the resulting error:

MSBuild version 17.4.0+18d5aef85 for .NET
  Determining projects to restore...
/Users/christianweyer/Sources/Microsoft.DotNet.ILCompiler.LLVM.Fiddling/HelloWorld/HelloWorld.csproj : error NU1101: Unable to find package runtime.osx-arm64.Microsoft.DotNet.ILCompiler.LLVM. No packages exist with this id in source(s): dotnet-experimental, dotnet-public
  Failed to restore /Users/christianweyer/Sources/Microsoft.DotNet.ILCompiler.LLVM.Fiddling/HelloWorld/HelloWorld.csproj (in 828 ms).

I also tried to run this via Rosetta, but got the same result.

Maybe I am missing some instructions on how to get it working on osx-arm64?

Thanks for any further hints 🙂.


dotnet --info
.NET SDK:
 Version:   7.0.101
 Commit:    bb24aafa11

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  13.0
 OS Platform: Darwin
 RID:         osx.13-arm64
 Base Path:   /usr/local/share/dotnet/sdk/7.0.101/

Host:
  Version:      7.0.1
  Architecture: arm64
  Commit:       97203d38ba
jkotas commented 1 year ago

The project is not publishing Apple M1 packages yet.

ChristianWeyer commented 1 year ago

OK, thanks. What would it take to build it on my own? Might that be feasible?

yowl commented 1 year ago

I tried Linux a while back and it was hard (for me at least) because introducing the LLVM headers brings complications, MacOS might be the same. Windows Arm64 might be easier, unfortunately I don't have a device to test with.

ChristianWeyer commented 1 year ago

Are there any plans, timewise, to add arm64 for macOS and Windows @jkotas ?

jkotas commented 1 year ago

No firm plans, this is experimental project. The focus is to make it work well on a few host architectures rather than expanding the set of host architectures that it can run on.

Arm64 host packages may get enabled as side-effect of @yowl's work on integrating upstream. (In any case, integrating more of upstream is likely a pre-requisite for enabling the arm64 builds.)