dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.36k stars 4.74k forks source link

Should microsoft.netcore.app.crossgen2.linux-x64 contain libclrjit_unix_riscv64_x64 ? #106992

Closed omajid closed 2 months ago

omajid commented 2 months ago

When I try cross-building the VMR on x64 for riscv64-linux, aspnetcore fails when tries to use crossgen:

      Running crossgen with /dotnet/src/aspnetcore/artifacts/sb/package-cache/microsoft.netcore.app.crossgen2.linux-x64/9.0.0-preview.7.24365.1/tools/crossgen2
      Error: Unable to load shared library 'clrjit_unix_riscv64_x64' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable: 
      /dotnet/src/aspnetcore/artifacts/sb/package-cache/microsoft.netcore.app.crossgen2.linux-x64/9.0.0-preview.7.24365.1/tools/clrjit_unix_riscv64_x64.so: cannot open shared object file: No such file or directory
      /dotnet/src/aspnetcore/artifacts/sb/package-cache/microsoft.netcore.app.crossgen2.linux-x64/9.0.0-preview.7.24365.1/tools/libclrjit_unix_riscv64_x64.so: cannot open shared object file: No such file or directory
      /dotnet/src/aspnetcore/artifacts/sb/package-cache/microsoft.netcore.app.crossgen2.linux-x64/9.0.0-preview.7.24365.1/tools/clrjit_unix_riscv64_x64: cannot open shared object file: No such file or directory
      /dotnet/src/aspnetcore/artifacts/sb/package-cache/microsoft.netcore.app.crossgen2.linux-x64/9.0.0-preview.7.24365.1/tools/libclrjit_unix_riscv64_x64: cannot open shared object file: No such file or directory

After digging a bit, libclrjit_unix_riscv64_x64 is the clrjit library used by crossgen that runs on x64 and produces code for riscv64. ASP.NET Core is expecting this to exist in the microsoft.netcore.app.crossgen2.linux-x64 nuget package. Is this a good assumption? Should libclrjit_unix_riscv64_x64 be produced and shipped in that nuget package?

cc @sirntar @SzpejnaDawid

jkotas commented 2 months ago

Related https://github.com/dotnet/runtime/pull/100099

SzpejnaDawid commented 2 months ago

When i was playing in cross compilation of dotnet/dotnet then I locally turn off crossgen for ASP.NET using this:

# in dotnet/src/aspnetcore/src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj
# 45th line after modification
<CrossgenOutput Condition=" '$(TargetArchitecture)' == 's390x' OR '$(TargetArchitecture)' == 'armv6' OR '$(TargetArchitecture)' == 'ppc64le' OR '$(TargetArchitecture)' == 'loongarch64' OR '$(TargetArchitecture)' == 'riscv64' ">false</CrossgenOutput>

Building dotnet/dotnet has low priority in my tasks so I didn't focus on it. I hope my answer will be helpful for you.

omajid commented 2 months ago

Thanks, @SzpejnaDawid !

Another solution that I am thinking about in a dotnet/dotnet context is to use the just-built crossgen2 from runtime (which includes support for targeting riscv64).

That said, in this issue I am mostly asking about the long-term solution: will the microsoft.netcore.app.crossgen2.* packages on nuget.org contain support for cross-compiling to community archs (assuming community archs support crossgen2)?

jkotas commented 2 months ago

will the microsoft.netcore.app.crossgen2.* packages on nuget.org contain support for cross-compiling to community archs

It would be problematic for Microsoft to ship binaries on nuget.org that Microsoft is not setup to test.

omajid commented 2 months ago

Thanks!