crossgen2 doesn't resolve compilers for non-portable rids
See original GitHub issueI’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:
cc @ViktorHofer @hoyosjs @AntonLapounov
How can we update this code so it works for non-portable rids?
Issue Analytics
- State:
- Created a year ago
- Comments:10 (9 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 (likefedora.36-x64
).Currently we are emulating the usual behavior because source-build builds the
runtime
repo twice. Once it names everythinglinux-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.
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
).