-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Native AOT runtime changes for multiple package conflict #72346
Conversation
@@ -42,20 +42,20 @@ | |||
<!-- Locate the runtime package according to the current target runtime --> | |||
<Target Name="ImportRuntimeIlcPackageTarget" Condition="'$(BuildingFrameworkLibrary)' != 'true' AND $(IlcCalledViaPackage) == 'true'" DependsOnTargets="$(ImportRuntimeIlcPackageTargetDependsOn)" BeforeTargets="Publish"> | |||
<!-- This targets file is imported by the SDK when the PublishAot property is set. SDK resolves runtime package paths differently--> | |||
<Error Condition="'@(ResolvedILCompilerPack)' == '' AND '$(PublishAot)' == 'true'" Text="The ResolvedILCompilerPack ItemGroup is required for target ImportRuntimeIlcPackageTarget" /> | |||
<Error Condition="'@(ResolvedILCompilerPack)' == '' AND '$(AotRuntimePackageLoadedViaSDK)' == 'true'" Text="The ResolvedILCompilerPack ItemGroup is required for target ImportRuntimeIlcPackageTarget" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is AotRuntimePackageLoadedViaSDK
different from IlcCalledViaPackage
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To the best of my knowledge, AotRuntimePackageLoadedViaSDK, is intended to indicate ILCompiler
package loaded mechanism and is a new flag. IlcCalledViaPackage
seems to used to control the native targets and is used for the ILCompiler
runtime package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created an issue to track this, #72415
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I read this correctly, IlcCalledViaPackage
no longer does what it suggests since it's set to true
in these targets which get imported on both the SDK and package paths. Can we remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IlcCalledViaPackage was introduced here: dotnet/corert#5123 - all the context we have left is in what's in the pull request/comments.
It was working around some issue around two situations:
- The props/targets are included from the NuGet package (IlcCalledViaPackage == true) and
- The props/targets are included directly (like we do in this repo when we build tests, or crossgen2)
There were things happening differently in those two scenarios. I'm not aware of us doing anything to make that not needed, but I also don't know much about what the original problem was.
|
||
|
||
<!-- This targets file is imported by the SDK when the PublishAot property is set. Use the SDK runtime package resolve property to set down stream properties --> | ||
<PropertyGroup Condition="'$(PublishAot)' == 'true'"> | ||
<PropertyGroup Condition="'$(AotRuntimePackageLoadedViaSDK)' == 'true'"> | ||
<RuntimePackagePath>@(ResolvedILCompilerPack->'%(PackageDirectory)')</RuntimePackagePath> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we somehow reuse this logic for the NuGet package as well? i.e., have the NuGet package set ResolvedILCompilerPack
and use the SDK logic for restoring the runtime pack?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this suggestion as a best practice suggestion? This approach seems simpler since the Target ResolveFrameworkReferences
that processes ResolvedILCompilerPack
happens fairly early in the SDK. Setting the ILCompiler
runtime package path as was done prior to the SDK support here seems to be working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created an issue to track this, #72415
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I would prefer to have one code path that does the package resolution in both cases. Would it work to adjust KnownFrameworkReference
to include a reference to the right version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be my hope, but I've noticed that restore is weird and delicate, so it may not work how I would expect.
src/coreclr/nativeaot/BuildIntegration/Microsoft.DotNet.ILCompiler.props
Outdated
Show resolved
Hide resolved
src/coreclr/nativeaot/BuildIntegration/Microsoft.DotNet.ILCompiler.props
Outdated
Show resolved
Hide resolved
<!-- Only import the build props if the NativeAot package isn't referenced via NuGet. --> | ||
<Import Project="$(MSBuildThisFileDirectory)..\build\Microsoft.DotNet.ILCompiler.targets" Condition="'$(PublishAot)' == 'true'"/> | ||
<Import Project="$(MSBuildThisFileDirectory)..\build\Microsoft.DotNet.ILCompiler.props" Condition="'$(PublishAot)' == 'true' and '$(ILCompilerTargetsPath)' == ''" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like PublishAot
was originally acting as a kind of sentinel, but presumably it was broken (since it looks like the SDK would always import the included targets when PublishAot
was set, even with a nuget package reference). Can we remove the PublishAot
condition now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure if there is any way that the SDK path can be activated before the explicit ILCompiler package reference can set the sentinel since there are non-PublishAOT calls in the SDK that might set the sentinel.
So there are two concerns here,
- If explicit
ILCompiler
package references always set the sentinel first, then its ok to remove the check here - There needs to be a guard for non-PublishAot SDK code paths to not import aot targets since Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.props and Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets might get invoked in non-PublishAot scenarios. I also added a check in the targets file before importing the native AOT target file and if the above concern is not valid, we can remove it from the props file
@@ -42,20 +42,20 @@ | |||
<!-- Locate the runtime package according to the current target runtime --> | |||
<Target Name="ImportRuntimeIlcPackageTarget" Condition="'$(BuildingFrameworkLibrary)' != 'true' AND $(IlcCalledViaPackage) == 'true'" DependsOnTargets="$(ImportRuntimeIlcPackageTargetDependsOn)" BeforeTargets="Publish"> | |||
<!-- This targets file is imported by the SDK when the PublishAot property is set. SDK resolves runtime package paths differently--> | |||
<Error Condition="'@(ResolvedILCompilerPack)' == '' AND '$(PublishAot)' == 'true'" Text="The ResolvedILCompilerPack ItemGroup is required for target ImportRuntimeIlcPackageTarget" /> | |||
<Error Condition="'@(ResolvedILCompilerPack)' == '' AND '$(AotRuntimePackageLoadedViaSDK)' == 'true'" Text="The ResolvedILCompilerPack ItemGroup is required for target ImportRuntimeIlcPackageTarget" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I read this correctly, IlcCalledViaPackage
no longer does what it suggests since it's set to true
in these targets which get imported on both the SDK and package paths. Can we remove it?
src/coreclr/nativeaot/BuildIntegration/Microsoft.DotNet.ILCompiler.targets
Outdated
Show resolved
Hide resolved
@@ -42,20 +42,20 @@ | |||
<!-- Locate the runtime package according to the current target runtime --> | |||
<Target Name="ImportRuntimeIlcPackageTarget" Condition="'$(BuildingFrameworkLibrary)' != 'true' AND $(IlcCalledViaPackage) == 'true'" DependsOnTargets="$(ImportRuntimeIlcPackageTargetDependsOn)" BeforeTargets="Publish"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ImportRuntimeIlcPackageTargetDependsOn
needs to be updated (it looks like it was originally intended to be defined only when using the nuget package). We shouldn't need to run RunResolvePackageDependencies
if we are resolving the compiler package from ResolvedILCompilerPack
.
src/coreclr/nativeaot/BuildIntegration/Microsoft.DotNet.ILCompiler.targets
Outdated
Show resolved
Hide resolved
|
||
|
||
<!-- This targets file is imported by the SDK when the PublishAot property is set. Use the SDK runtime package resolve property to set down stream properties --> | ||
<PropertyGroup Condition="'$(PublishAot)' == 'true'"> | ||
<PropertyGroup Condition="'$(AotRuntimePackageLoadedViaSDK)' == 'true'"> | ||
<RuntimePackagePath>@(ResolvedILCompilerPack->'%(PackageDirectory)')</RuntimePackagePath> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I would prefer to have one code path that does the package resolution in both cases. Would it work to adjust KnownFrameworkReference
to include a reference to the right version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionally LGTM. My personal preference would be to clean up the old properties here, but it also seems fine to do that in a follow-up if you want to unblock this change. Thank you!
this is blocking sdk flow dotnet/sdk#26715 and is it really needed by even 1% of the users? it is disconnected from everything else integrated into the sdk. crossgen integration in sdk is shipped without this hook and no one has ever asked or complained about it. we wait for next release of .net for all the new features and improvements together, if someone need to try out the latest dev version once in a while. they download the daily build which takes no more than a few seconds to download than the runtime pack.. |
@kasperk81 Both linker and Roslyn have similar hooks. Yes, we need this hook to be successful with customers that we are closely working with. crossgen does not have this hook since it is tightly coupled with the runtime pack and so it does not make sense to have a separate hook for it.
The SDK version is often controlled in customer build environments. Requiring them to update the SDK to pickup or validate a bug-fix is a non-starter. |
Fixes dotnet/sdk#26268 where currently adding a ILCompiler package reference creates an application that doesn't work. We want to support this scenario where we expect developers to get the latest ILCompiler package (rather than use the SDK one, which can be a little older) when publishing, for example to pick a fix that is not yet present in the SDK.
Some notes
microsoft.dotnet.ilcompiler
deals primarily with setting up properties and targets and is handled similar to the way the linker manages conflicts with package references (see Move ILLink targets to the linker repo sdk#25993 and Move the ILLink targets from the SDK repo to the linker repo linker#2837)runtime.win-x64.microsoft.dotnet.ilcompiler
for the windows package) that contains ilc tool and runtime assets. The package reference path is now set based on a flag that gets sets if the SDK package is the only one used. Otherwise, the Nuget package one that comes from the explicit package reference in the app will be picked.