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

Switch over framework packaging to use Crossgen2 #47349

Merged
merged 2 commits into from
Feb 16, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/installer/pkg/sfx/Microsoft.NETCore.App/ReadyToRun.targets
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
<Project>
<Target Name="ResolveReadyToRunCompilers" DependsOnTargets="ResolveRuntimeFilesFromLocalBuild">
<!-- The following property group can be simplified once runtime repo switches over to SDK 6.0 drop -->
<PropertyGroup>
<CrossDir></CrossDir>
<CrossDir Condition="'$(BuildArchitecture)' != '$(TargetArchitecture)'">x64</CrossDir>
<Crossgen2Dir>$(CoreCLRArtifactsPath)\$(CrossDir)\crossgen2</Crossgen2Dir>
<Crossgen2Exe>$(Crossgen2Dir)\crossgen2$(ExeSuffix)</Crossgen2Exe>
<PublishReadyToRunCrossgen2ExtraArgs>--targetarch:$(TargetArchitecture)</PublishReadyToRunCrossgen2ExtraArgs>

<JitTargetOSComponent>unix</JitTargetOSComponent>
<JitTargetOSComponent Condition="'$(TargetOS)' == 'windows'">win</JitTargetOSComponent>
<JitBuildArchitecture>$(TargetArchitecture)</JitBuildArchitecture>
<JitBuildArchitecture Condition="'$(CrossDir)' != ''">$(CrossDir)</JitBuildArchitecture>
<JitLibrary>$(Crossgen2Dir)\$(LibPrefix)clrjit_$(JitTargetOSComponent)_$(TargetArchitecture)_$(JitBuildArchitecture)$(LibSuffix)</JitLibrary>
</PropertyGroup>

<ItemGroup Condition="'$(RuntimeFlavor)' != 'Mono'">
<_crossTargetJit Include="@(CoreCLRCrossTargetFiles)" Condition="'%(FileName)' == '$(LibPrefix)clrjit' and '%(Extension)' == '$(LibSuffix)'" />
<_clrjit Include="@(RuntimeFiles)" Condition="'%(FileName)' == '$(LibPrefix)clrjit' and '%(Extension)' == '$(LibSuffix)'" />
Expand All @@ -16,5 +31,34 @@
JitPath="@(_clrjit)"
DiaSymReader="$(_diaSymReaderPathIfExists)" />
</ItemGroup>
<ItemGroup>
<Crossgen2Tool Include="$(Crossgen2Exe)" JitPath="$(JitLibrary)" />
</ItemGroup>
</Target>

<!-- Hack to patch DOTNET_ROOT for the duration of Crossgen2 compilation to unblock -->
<!-- Crossgen2 bring-up before SDK 6.0 Preview 2 propagates to the runtime repo. -->
<!-- https://github.com/dotnet/runtime/issues/48252 -->

<PropertyGroup>
<OriginalDotnetRootValue />
<DOTNET_ROOT />
</PropertyGroup>

<Target Name="PatchDotnetRootBeforeRunningCrossgen2" BeforeTargets="_CreateR2RImages">
<PropertyGroup>
<OriginalDotnetRootValue>$(DOTNET_ROOT)</OriginalDotnetRootValue>
<DOTNET_ROOT>$(RepoRoot)</DOTNET_ROOT>
</PropertyGroup>
</Target>

<Target Name="RestoreDotnetRootAfterRunningCrossgen2" AfterTargets="_CreateR2RImages">
<PropertyGroup>
<DOTNET_ROOT>$(OriginalDotnetRootValue)</DOTNET_ROOT>
Copy link
Member

Choose a reason for hiding this comment

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

The only problem with this is it will eventually change this property, some time after _CreateR2RImages ran. The only 2 ways I know for somewhat strict ordering are using a dependent target (the you don't own case, but there's an extensibility model, and it's cleaner), or the CallTarget route (which has few good uses, and unless we own _CreateR2RImages, it won't be a good idea..

Copy link
Member Author

Choose a reason for hiding this comment

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

The exact problem here is that, while we "own" _CreateR2RImages, we do so in a different repo (sdk) and the entire trick here is about not having to wait for its propagation to the runtime repo as that will take about two months or more. If I could merge in my SDK PR today and propagate it to runtime tomorrow, this would be a no-concern.

</PropertyGroup>
</Target>

<!-- End of hack to patch DOTNET_ROOT for the duration of Crossgen2 compilation. -->
<!-- This can be removed once the runtime repo rolled forward to .NET 6 Preview 2 SDK repo drop. -->
<!-- https://github.com/dotnet/runtime/issues/48252 -->
</Project>