Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consume portable RID graph from runtime #17760

Merged
merged 4 commits into from
Nov 16, 2023
Merged

Conversation

ViktorHofer
Copy link
Member

@ViktorHofer ViktorHofer commented Nov 10, 2023

Contributes to dotnet/sdk#35750

  1. Consume portable RID graph from runtime (subsequent PR will delete it from sdk).
  2. Use the portable RID graph in source build projects
  3. Delete the mutate RID graph and invocation as that's already handled directly in runtime.

cc @tmds

1. Consume portable RID graph from runtime (subsequent PR will delete
   it from sdk).
2. Use the portable RID graph in source build projects
3. Delete the mutate RID graph and invocation as that's already handled
   directly in runtime.
@ViktorHofer ViktorHofer requested a review from a team as a code owner November 10, 2023 18:40
Comment on lines 1202 to +1204
<GenerateSdkRuntimeIdentifierChain
RuntimeIdentifier="$(PortableProductMonikerRid)"
RuntimeIdentifierGraphPath="$(SdkOutputDirectory)RuntimeIdentifierGraph.json"
RuntimeIdentifierGraphPath="$(SdkOutputDirectory)PortableRuntimeIdentifierGraph.json"
Copy link
Member Author

@ViktorHofer ViktorHofer Nov 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have absolutely no idea what that chain file is about but it should still work as expected with the portable RID graph. In general, our product build shouldn't use the legacy RID graph anymore which only exists to make the back compat switch work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This chain file contains an ordered list of rids that are usable with the rid being built.

On the 8.0 rc2 I have installed on Fedora it contains:

linux-x64
linux
unix-x64
unix
any

I'm slightly surprised it doesn't include the source-build non-portable rid.
The CLI seems to use it for some things.

ViktorHofer added a commit to dotnet/sdk that referenced this pull request Nov 10, 2023
<Target Name="SetOutputList" AfterTargets="Package" BeforeTargets="GatherBuiltPackages">
<ItemGroup>
<PackagesOutputList Include="$(ShippingPackagesOutput)" />
<PackagesOutputList Include="$(NonShippingPackagesOutput)" />
</ItemGroup>
</Target>

<Target Name="UpdateRuntimeGraph"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to see this source-build specialization removed.

@MichaelSimons
Copy link
Member

smoke-tests surfaced some rid related issues:

System.InvalidOperationException : Failed to execute /vmr/test/Microsoft.DotNet.SourceBuild.SmokeTests/bin/Release/net9.0/.dotnet/dotnet publish --self-contained true -r linux-x64 /p:PublishTrimmed=true /p:PublishReadyToRun=true /bl:/vmr/test/Microsoft.DotNet.SourceBuild.SmokeTests/bin/Release/net9.0/logs/BasicScenarioTests_Console_CSharp-publish-self-contained-linux-x64-trimmed-R2R.binlog -o /vmr/test/Microsoft.DotNet.SourceBuild.SmokeTests/bin/Release/net9.0/projects-202311101933037072/BasicScenarioTests_Console_CSharp/bin/publish
Exit code: 1
MSBuild version 17.9.0-preview-23557-02+5d1509792 for .NET
Determining projects to restore...
/vmr/test/Microsoft.DotNet.SourceBuild.SmokeTests/bin/Release/net9.0/.dotnet/sdk/9.0.100-alpha.1.23560.1/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5): error NETSDK1094: Unable to optimize assemblies for performance: a valid runtime package was not found. Either set the PublishReadyToRun property to false, or use a supported runtime identifier when publishing. When targeting .NET 6 or higher, make sure to restore packages with the PublishReadyToRun property set to true. [/vmr/test/Microsoft.DotNet.SourceBuild.SmokeTests/bin/Release/net9.0/projects-202311101933037072/BasicScenarioTests_Console_CSharp/BasicScenarioTests_Console_CSharp.csproj]

@ViktorHofer
Copy link
Member Author

Yes, I hope that @tmds can help me understand the failures: 9ce6a45#r132417371

@@ -1195,9 +1195,13 @@ Copyright (c) .NET Foundation. All rights reserved.
DestinationFiles="$(SdkOutputDirectory)RuntimeIdentifierGraph.json"
SkipUnchangedFiles="true"/>

<Copy SourceFiles="$(NuGetPackageRoot)/microsoft.netcore.platforms/$(_NETCorePlatformsPackageVersion)/PortableRuntimeIdentifierGraph.json"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my understanding:
Is this copying from a package that is produced by the runtime repo build?
Did we not have to copy this previously because it came with the sdk repo build output?

Copy link
Member Author

@ViktorHofer ViktorHofer Nov 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. The package is produced in runtime. The portable RID graph was previously checked into the sdk directly. We want to remove that extra copy now and use the package from runtime as the source of truth.

@tmds
Copy link
Member

tmds commented Nov 15, 2023

Yes, I hope that @tmds can help me understand the failures: 9ce6a45#r132417371

I think there's an issue mapping the non-portable source-built rid (NETCoreSdkRuntimeIdentifier) to a portable rid (for Crossgen2) using the rid graph (RuntimeIdentifierGraphPath):

    <ProcessFrameworkReferences FrameworkReferences="@(FrameworkReference)"
...
                                RuntimeGraphPath="$(RuntimeIdentifierGraphPath)"
...
                                NETCoreSdkRuntimeIdentifier="$(NETCoreSdkRuntimeIdentifier)"
...

That would mean that the non-portable rid was not added to the RuntimeIdentifierGraphPath gets used here.

@ViktorHofer
Copy link
Member Author

@tmds do you know where that file is coming from? I can't find it checked-in anywhere. 9ce6a45#diff-de198c84af9d2e1870737bbc063dd42615618c702cc0a1f4c41b40fc11a16e59R78

@tmds
Copy link
Member

tmds commented Nov 15, 2023

@tmds do you know where that file is coming from? I can't find it checked-in anywhere. 9ce6a45#diff-de198c84af9d2e1870737bbc063dd42615618c702cc0a1f4c41b40fc11a16e59R78

In Microsoft.NET.Sdk.targets, RuntimeIdentifierGraphPath defaults to PortableRuntimeIdentifierGraph.json (unless UseRidGraph is set, which the smoke tests don't do).

Probably the changes cause to use the original PortableRuntimeIdentifierGraph.json instead of the one that gets patched with the source-build rid during the runtime build.

@ViktorHofer
Copy link
Member Author

Right. But do you know where this path is: $(ProjectDirectory)pkg/Microsoft.NETCore.Platforms/runtime.json? Where is this pkg folder?

@tmds
Copy link
Member

tmds commented Nov 15, 2023

Right. But do you know where this path is: $(ProjectDirectory)pkg/Microsoft.NETCore.Platforms/runtime.json? Where is this pkg folder?

<Target Name="UpdateRuntimeGraph"
BeforeTargets="Build"
Condition="'$(_IsBootstrapping)' == 'true'">
<PropertyGroup>
<RuntimeJsonFile>$(ProjectDirectory)pkg/Microsoft.NETCore.Platforms/runtime.json</RuntimeJsonFile>
</PropertyGroup>
<Message Importance="High" Text="Adding rid, $(TargetRid), to $(RuntimeJsonFile)" />
<AddRidToRuntimeJson RuntimeJson="$(RuntimeJsonFile)"
Rid="$(TargetRid)-$(Platform)" />
</Target>

I think this is dead code. Nothing sets _IsBootstrapping.

Afaik, the patching of the runtime graph with non-portable rids is working well since .NET 7 when the runtime repo assumed that responsibility.

@ViktorHofer
Copy link
Member Author

ViktorHofer commented Nov 15, 2023

This confuses me:

    "centos.8-x64": {
      "#import": [
        "linux"
      ]
    }

Shouldn't this import linux-x64?

Here's the live built RID graph: PortableRuntimeIdentifierGraph.json

Yes, that's the issue. The current portable runtime json file has the following entry:

"centos.8-x64": {
      "#import": [
        "linux-x64"
      ]
    }

This needs a fix in runtime.

@@ -16,7 +16,7 @@
<RuntimeOS>$(NETCoreSdkRuntimeIdentifier.Substring(0, $(_platformIndex)))</RuntimeOS>

<_platformIndex>$(NETCoreSdkPortableRuntimeIdentifier.LastIndexOf('-'))</_platformIndex>
<BaseOS>$(NETCoreSdkPortableRuntimeIdentifier.Substring(0, $(_platformIndex)))</BaseOS>
<BaseOS>$(NETCoreSdkPortableRuntimeIdentifier.Substring(0, $(_platformIndex)))-$(Platform)</BaseOS>
Copy link
Member Author

@ViktorHofer ViktorHofer Nov 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tmds I had to add the Platform property here so that AdditionalRuntimeIdentifierParent is set to the right value.

This needs to change as we now use a different "add current RID to RID graph" code in runtime (the one that originated in sdk): https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.NETCore.Platforms/src/UpdateRuntimeIdentifierGraph.cs

Please double check if this is correct. Should we change the name of this property to PortableRid (which is what sdk.proj uses)? Changing the property name would require a change in runtime.

I assume your pipelines pass BaseOS in as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to change as we now use a different "add current RID to RID graph" code in runtime (the one that originated in sdk): https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.NETCore.Platforms/src/UpdateRuntimeIdentifierGraph.cs

Yes, it seems that the task that updated the old runtime graph didn't expect this to include an architecture (which is why this is named OS and not Rid), while the new task that updates the new graphs expects this to include an architecture.

Please double check if this is correct. Should we change the name of this property to PortableRid (which is what sdk.proj uses)? Changing the property name would require a change in runtime.

If it includes an architecture, it makes more sense to end with a Rid suffix.

Yes, this line needs to change: https://github.com/dotnet/runtime/blob/487d7f010b90a82178d55eea21e72dc6dedf9d5d/eng/SourceBuild.props#L45.

@ViktorHofer ViktorHofer merged commit 5037a63 into main Nov 16, 2023
@ViktorHofer ViktorHofer deleted the UseRIDGraphFromRuntime branch November 16, 2023 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants