question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

crossgen2 doesn't resolve compilers for non-portable rids

See original GitHub issue

I’m trying to make runtime repo build using artifacts produced for a non-portable rid in https://github.com/dotnet/runtime/pull/75597.

The build fails while trying to resolve the R2R compiler:

  13:47:14.530    19>Target "ResolveReadyToRunCompilers: (TargetId:2247)" in file "/home/tmds/sdk/sdk/7.0.100-rtm.22478.1/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets" from project "/home/tmds/tarball41/src/runtime/artifacts/source-build/self/src/src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj" (target "_PrepareForReadyToRunCompilation" depends on it):
                     Using "ResolveReadyToRunCompilers" task from assembly "/home/tmds/sdk/sdk/7.0.100-rtm.22478.1/Sdks/Microsoft.NET.Sdk/targets/../tools/net7.0/Microsoft.NET.Build.Tasks.dll".
                     Task "ResolveReadyToRunCompilers" (TaskId:1425)
                       Task Parameter:ReadyToRunUseCrossgen2=True (TaskId:1425)
                       Task Parameter:
                           TargetingPacks=
                               Microsoft.NETCore.App
                                       NuGetPackageId=Microsoft.NETCore.App.Ref
                                       NuGetPackageVersion=7.0.0-rtm.22465.3
                                       PackageConflictPreferredPackages=Microsoft.NETCore.App.Ref;Microsoft.NETCore.App.Runtime.fedora.36-x64
                                       PackageDirectory=/home/tmds/sdk/packs/Microsoft.NETCore.App.Ref/7.0.0-rtm.22465.3
                                       Path=/home/tmds/sdk/packs/Microsoft.NETCore.App.Ref/7.0.0-rtm.22465.3
                                       RuntimeFrameworkName=Microsoft.NETCore.App
                                       RuntimePackRuntimeIdentifiers=fedora.36-x64
                                       TargetFramework=net7.0
                                       TargetingPackFormat= (TaskId:1425)
                       Task Parameter:NETCoreSdkRuntimeIdentifier=fedora.36-x64 (TaskId:1425)
                       Task Parameter:
                           Crossgen2Packs=
                               Microsoft.NETCore.App.Crossgen2.fedora.36-x64
                                       NuGetPackageId=Microsoft.NETCore.App.Crossgen2.fedora.36-x64
                                       NuGetPackageVersion=7.0.0-rtm.22465.3
                                       OriginalItemSpec=Microsoft.NETCore.App.Crossgen2.fedora.36-x64
                                       PackageDirectory=/home/tmds/tarball41/src/runtime/artifacts/source-build/self/package-cache/microsoft.netcore.app.crossgen2.fedora.36-x64/7.0.0-rtm.22465.3 (TaskId:1425)
                       Task Parameter:
                           RuntimePacks=
                               Microsoft.NETCore.App.Runtime.fedora.36-x64
                                       FrameworkName=Microsoft.NETCore.App
                                       IsTrimmable=
                                       NuGetPackageId=Microsoft.NETCore.App.Runtime.fedora.36-x64
                                       NuGetPackageVersion=7.0.0-rtm.22465.3
                                       OriginalItemSpec=Microsoft.NETCore.App.Runtime.fedora.36-x64
                                       PackageDirectory=/home/tmds/tarball41/src/runtime/artifacts/source-build/self/package-cache/microsoft.netcore.app.runtime.fedora.36-x64/7.0.0-rtm.22465.3
                                       RuntimeIdentifier=fedora.36-x64 (TaskId:1425)
                       Task Parameter:PerfmapFormatVersion=1 (TaskId:1425)
                       Task Parameter:RuntimeGraphPath=/home/tmds/tarball41/src/runtime/artifacts/source-build/self/src/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json (TaskId:1425)
  13:47:14.535    19>/home/tmds/sdk/sdk/7.0.100-rtm.22478.1/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(299,5): error NETSDK1095: Optimizing assemblies for performance is not supported for the selected target platform or architecture. Please verify you are using a supported runtime identifier, or set the PublishReadyToRun property to false. [/home/tmds/tarball41/src/runtime/artifacts/source-build/self/src/src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj]

Looking at the code in ResolveReadyToRunCompilers.cs, it looks like isSupportedTarget will be false because targetOS is will be null for a non-portable rid:

https://github.com/dotnet/sdk/blob/b99ebbe963623467a37c327e2544af1381b1d2c3/src/Tasks/Microsoft.NET.Build.Tasks/ResolveReadyToRunCompilers.cs#L144-L162

cc @ViktorHofer @hoyosjs @AntonLapounov

How can we update this code so it works for non-portable rids?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
tmdscommented, Oct 6, 2022

Does it behave differently in source-build?

Yes it behaves different in source-build because we’re building packages that don’t have the Microsoft portable rids (like linux-x64), but non-portable packages named after the platform they represent (like fedora.36-x64).

If yes, can we emulate the usual behavior?

Currently we are emulating the usual behavior because source-build builds the runtime repo twice. Once it names everything linux-x64 so the rest of source-build can pretend those artifacts exist.

Building runtime repo twice costs a significant amount of time. We’d like to eliminate the ‘portable runtime’ build by making the repositories capable of consuming the non-portable artifacts. I hit this issue as part of https://github.com/dotnet/runtime/pull/75597.

1reaction
tmdscommented, Oct 5, 2022

The SDK picks the best match. Because these packages were built from source, there’s an exact match (fedora.36-x64) and it doesn’t fall back to the portable rid (linux-x64).

Read more comments on GitHub >

github_iconTop Results From Across the Web

[solved] Can't use Crossgen2 in .net 6 #48498
I have installed preview 2 and this issue disappeared.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found