Skip to content

Commit 087f930

Browse files
davidwrightondougbu
authored andcommitted
Enable compiling Asp.NET with crossgen2
1 parent 5c3ef58 commit 087f930

File tree

2 files changed

+58
-6
lines changed

2 files changed

+58
-6
lines changed

eng/Dependencies.props

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ and are generated based on the last package release.
9292
<LatestPackageReference Include="Microsoft.NETCore.App.Runtime.linux-musl-x64" />
9393
<LatestPackageReference Include="Microsoft.NETCore.App.Runtime.linux-musl-arm" />
9494
<LatestPackageReference Include="Microsoft.NETCore.App.Runtime.linux-musl-arm64" />
95+
96+
<!-- Crossgen2 compiler -->
97+
<LatestPackageReference Include="Microsoft.NETCore.App.Crossgen2.osx-x64" />
98+
<LatestPackageReference Include="Microsoft.NETCore.App.Crossgen2.osx-arm64" />
99+
<LatestPackageReference Include="Microsoft.NETCore.App.Crossgen2.linux-x64" />
100+
<LatestPackageReference Include="Microsoft.NETCore.App.Crossgen2.win-x64" />
101+
<LatestPackageReference Include="Microsoft.NETCore.App.Crossgen2.win-arm64" />
95102
</ItemGroup>
96103

97104
<ItemGroup Label=".NET team dependencies (Non-source-build)" Condition="'$(DotNetBuildFromSource)' != 'true'">
@@ -205,7 +212,7 @@ and are generated based on the last package release.
205212
-->
206213
<LatestPackageReference Update="@(LatestPackageReference->WithMetadataValue('Version', ''))">
207214
<Version
208-
Condition=" $([System.String]::new('%(Identity)').StartsWith('Microsoft.NETCore.App.Runtime.')) ">$(MicrosoftNETCoreAppRuntimeVersion)</Version>
215+
Condition=" $([System.String]::new('%(Identity)').StartsWith('Microsoft.NETCore.App.Runtime.')) or $([System.String]::new('%(Identity)').StartsWith('Microsoft.NETCore.App.Crossgen2.'))">$(MicrosoftNETCoreAppRuntimeVersion)</Version>
209216
</LatestPackageReference>
210217
</ItemGroup>
211218
</Project>

src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ This package is an internal implementation of the .NET Core SDK and is not meant
4444

4545
<!-- Optimize the framework using the crossgen tool -->
4646
<CrossgenOutput Condition=" '$(CrossgenOutput)' == '' AND '$(Configuration)' != 'Debug' ">true</CrossgenOutput>
47+
<UseCrossgen2>true</UseCrossgen2>
4748

4849
<!-- Produce crossgen profiling symbols (.ni.pdb or .map files). -->
4950
<GenerateCrossgenProfilingSymbols>true</GenerateCrossgenProfilingSymbols>
@@ -100,13 +101,16 @@ This package is an internal implementation of the .NET Core SDK and is not meant
100101
<!-- Crossgen executable name -->
101102
<CrossgenToolFileName>crossgen</CrossgenToolFileName>
102103
<CrossgenToolFileName Condition=" '$(TargetOsName)' == 'win' ">$(CrossgenToolFileName).exe</CrossgenToolFileName>
104+
<Crossgen2ToolFileName>crossgen2</Crossgen2ToolFileName>
105+
<Crossgen2ToolFileName Condition=" '$(TargetOsName)' == 'win' ">$(Crossgen2ToolFileName).exe</Crossgen2ToolFileName>
103106
<!-- Default crossgen executable relative path -->
104107
<CrossgenToolPackagePath>$(CrossgenToolFileName)</CrossgenToolPackagePath>
105108
<!-- Disambiguated RID-specific crossgen executable relative path -->
106109
<CrossgenToolPackagePath Condition=" '$(CrossCompileDirectory)' != '' ">$(CrossCompileDirectory)\$(CrossgenToolPackagePath)</CrossgenToolPackagePath>
107110

108111
<!-- E.g. "PkgMicrosoft_NETCore_App_Runtime_win-x64" (set in obj/Microsoft.AspNetCore.App.Runtime.csproj.nuget.g.props). -->
109112
<RuntimePackageRootVariableName>PkgMicrosoft_NETCore_App_Runtime_$(RuntimeIdentifier)</RuntimePackageRootVariableName>
113+
<Crossgen2PackageRootVariableName>PkgMicrosoft_NETCore_App_Crossgen2_$(TargetOsName)-$(BuildArchitecture)</Crossgen2PackageRootVariableName>
110114

111115
<AssetTargetFallback>$(AssetTargetFallback);native,Version=0.0</AssetTargetFallback>
112116

@@ -125,6 +129,11 @@ This package is an internal implementation of the .NET Core SDK and is not meant
125129
PrivateAssets="All"
126130
GeneratePathProperty="true" />
127131

132+
<Reference Include="Microsoft.NETCore.App.Crossgen2.$(TargetOsName)-$(BuildArchitecture)"
133+
ExcludeAssets="All"
134+
PrivateAssets="All"
135+
GeneratePathProperty="true" />
136+
128137
<ProjectReference Condition=" '$(BuildIisNativeProjects)' == 'true' AND $(BuildNative) "
129138
Include="$(RepoRoot)src\Servers\IIS\AspNetCoreModuleV2\InProcessRequestHandler\InProcessRequestHandler.vcxproj">
130139
<SetPlatform>Platform=$(NativePlatform)</SetPlatform>
@@ -349,10 +358,16 @@ This package is an internal implementation of the .NET Core SDK and is not meant
349358
<RuntimePackageRootMapping>
350359
<RuntimePackageRoot>$(%(Identity))</RuntimePackageRoot>
351360
</RuntimePackageRootMapping>
361+
<Crossgen2PackageRootMapping Include="$(Crossgen2PackageRootVariableName)" />
362+
<Crossgen2PackageRootMapping>
363+
<Crossgen2PackageRoot>$(%(Identity))</Crossgen2PackageRoot>
364+
</Crossgen2PackageRootMapping>
352365
</ItemGroup>
353366
<PropertyGroup>
354367
<RuntimePackageRoot>@(RuntimePackageRootMapping->'%(RuntimePackageRoot)')</RuntimePackageRoot>
355368
<RuntimePackageRoot>$([MSBuild]::EnsureTrailingSlash('$(RuntimePackageRoot)'))</RuntimePackageRoot>
369+
<Crossgen2PackageRoot>@(Crossgen2PackageRootMapping->'%(Crossgen2PackageRoot)')</Crossgen2PackageRoot>
370+
<Crossgen2PackageRoot>$([MSBuild]::EnsureTrailingSlash('$(Crossgen2PackageRoot)'))</Crossgen2PackageRoot>
356371
</PropertyGroup>
357372
</Target>
358373

@@ -375,10 +390,18 @@ This package is an internal implementation of the .NET Core SDK and is not meant
375390

376391
<ReferenceCopyLocalPaths Remove="@(IntermediateCrossgenAssembly)" />
377392
<ReferenceCopyLocalPaths Include="@(IntermediateCrossgenAssembly->'$(TargetDir)%(FileName)%(Extension)')" />
393+
394+
<_DistinctPlatformAssemblyPaths Include="@(_PlatformAssemblyPaths->Distinct())"/>
395+
<_DistinctPlatformAssemblyPaths>
396+
<CommandLineOption>-r:%(Identity)*.dll</CommandLineOption>
397+
</_DistinctPlatformAssemblyPaths>
398+
399+
<Crossgen2PlatformAssemblyPaths Include="@(_DistinctPlatformAssemblyPaths->'%(CommandLineOption)')" />
378400
</ItemGroup>
379401

380402
<PropertyGroup>
381-
<CrossgenToolPath>$([System.IO.Path]::Combine('$(RuntimePackageRoot)', 'tools', '$(CrossgenToolPackagePath)'))</CrossgenToolPath>
403+
<CrossgenToolPath Condition="'$(UseCrossgen2)' != 'true'" >$([System.IO.Path]::Combine('$(RuntimePackageRoot)', 'tools', '$(CrossgenToolPackagePath)'))</CrossgenToolPath>
404+
<CrossgenToolPath Condition="'$(UseCrossgen2)' == 'true'" >$([System.IO.Path]::Combine('$(Crossgen2PackageRoot)', 'tools', '$(Crossgen2ToolFileName)'))</CrossgenToolPath>
382405
<CrossgenSymbolsTargetDir>$(TargetDir)</CrossgenSymbolsTargetDir>
383406
<CrossgenPlatformAssemblyPaths>@(_PlatformAssemblyPaths->Distinct(), '$(PathSeparator)')</CrossgenPlatformAssemblyPaths>
384407

@@ -392,15 +415,21 @@ This package is an internal implementation of the .NET Core SDK and is not meant
392415
File="$(CrossgenToolDir)PlatformAssembliesPaths.rsp"
393416
Overwrite="true" />
394417

418+
<WriteLinesToFile
419+
Lines="@(Crossgen2PlatformAssemblyPaths)"
420+
File="$(CrossgenToolDir)PlatformAssembliesPathsCrossgen2.rsp"
421+
Overwrite="true" />
422+
395423
<ItemGroup>
396424
<RuntimePackageFiles Include="$(RuntimePackageRoot)runtimes\**\*" />
397425
</ItemGroup>
398426

399427
<Error Text="Could not find crossgen $(CrossgenToolPath)" Condition=" ! Exists($(CrossgenToolPath))" />
400428

401429
<!-- Create tool directory with crossgen executable and runtime assemblies -->
402-
<Copy SourceFiles="@(RuntimePackageFiles);$(CrossgenToolPath)" DestinationFolder="$(CrossGenToolDir)"/>
403-
<Exec Command="chmod +x &quot;$(CrossGenToolDir)$(CrossgenToolFileName)&quot;" Condition="'$(OS)' != 'Windows_NT'" />
430+
<Copy SourceFiles="@(RuntimePackageFiles)" DestinationFolder="$(CrossGenToolDir)"/>
431+
<Copy Condition="'$(UseCrossgen2)' != 'true'" SourceFiles="$(CrossgenToolPath)" DestinationFolder="$(CrossGenToolDir)"/>
432+
<Exec Command="chmod +x &quot;$(CrossGenToolDir)$(CrossgenToolFileName)&quot;" Condition="'$(OS)' != 'Windows_NT' and '$(UseCrossgen2)' != 'true'" />
404433
</Target>
405434

406435
<Target Name="_BatchCrossGenAssemblies"
@@ -413,18 +442,34 @@ This package is an internal implementation of the .NET Core SDK and is not meant
413442
Condition="'$(CrossCompileDirectory)' == ''">$(RuntimePackageRoot)runtimes\$(RuntimeIdentifier)\native\$(LibPrefix)clrjit$(LibExtension)</CoreCLRJitPath>
414443
<CoreCLRJitPath
415444
Condition="'$(CrossCompileDirectory)' != ''">$(RuntimePackageRoot)runtimes\$(CrossCompileDirectory)\native\$(LibPrefix)clrjit$(LibExtension)</CoreCLRJitPath>
445+
446+
<Crossgen2TargetOs>$(TargetOsName)</Crossgen2TargetOs>
447+
<Crossgen2TargetOs Condition="'$(TargetOsName)' == 'win'">windows</Crossgen2TargetOs>
448+
<Crossgen2Args>--targetarch:$(TargetArchitecture)</Crossgen2Args>
449+
<Crossgen2Args>$(Crossgen2Args) --targetos:$(Crossgen2TargetOs)</Crossgen2Args>
450+
<Crossgen2Args>$(Crossgen2Args) -O</Crossgen2Args>
451+
<Crossgen2Args>$(Crossgen2Args) @&quot;$(CrossgenToolDir)PlatformAssembliesPathsCrossgen2.rsp&quot;</Crossgen2Args>
452+
<Crossgen2Args Condition="'$(GenerateCrossgenProfilingSymbols)' == 'true' and '$(TargetOsName)' == 'win'">$(Crossgen2Args) --pdb --pdb-path:&quot;$(CrossgenSymbolsTargetDir)&quot;</Crossgen2Args>
453+
<Crossgen2Args Condition="'$(GenerateCrossgenProfilingSymbols)' == 'true' and '$(TargetOsName)' != 'win'">$(Crossgen2Args) --perfmap --perfmap-path:&quot;$(CrossgenSymbolsTargetDir)&quot;</Crossgen2Args>
416454
</PropertyGroup>
417455

418-
<Exec Command="&quot;$(CrossgenToolDir)$(CrossgenToolFileName)&quot; -nologo -readytorun -in &quot;%(IntermediateCrossgenAssembly.Identity)&quot; -out &quot;$(TargetDir)%(FileName)%(Extension)&quot; -jitpath &quot;$(CoreCLRJitPath)&quot; &quot;@$(CrossgenToolDir)PlatformAssembliesPaths.rsp&quot;"
456+
<Exec Condition="'$(UseCrossgen2)' != 'true'"
457+
Command="&quot;$(CrossgenToolDir)$(CrossgenToolFileName)&quot; -nologo -readytorun -in &quot;%(IntermediateCrossgenAssembly.Identity)&quot; -out &quot;$(TargetDir)%(FileName)%(Extension)&quot; -jitpath &quot;$(CoreCLRJitPath)&quot; &quot;@$(CrossgenToolDir)PlatformAssembliesPaths.rsp&quot;"
419458
EnvironmentVariables="COMPlus_PartialNGen=0"
420459
IgnoreStandardErrorWarningFormat="true"
421460
StandardOutputImportance="High" />
422461

423-
<Exec Condition=" '$(GenerateCrossgenProfilingSymbols)' == 'true' "
462+
<Exec Condition=" '$(GenerateCrossgenProfilingSymbols)' == 'true' and '$(UseCrossgen2)' != 'true'"
424463
Command="&quot;$(CrossgenToolDir)$(CrossgenToolFileName)&quot; -nologo -readytorun -in &quot;$(TargetDir)%(IntermediateCrossgenAssembly.FileName)%(Extension)&quot; -Create$(CrossGenSymbolsType) &quot;$(CrossgenSymbolsTargetDir)&quot; &quot;@$(CrossgenToolDir)PlatformAssembliesPaths.rsp&quot;"
425464
EnvironmentVariables="COMPlus_PartialNGen=0"
426465
IgnoreStandardErrorWarningFormat="true"
427466
StandardOutputImportance="High" />
467+
468+
<Exec Condition="'$(UseCrossgen2)' == 'true'"
469+
Command="&quot;$(CrossgenToolPath)&quot; $(Crossgen2Args) -o:&quot;$(TargetDir)%(FileName)%(Extension)&quot; &quot;%(IntermediateCrossgenAssembly.Identity)&quot;"
470+
IgnoreStandardErrorWarningFormat="true"
471+
StandardOutputImportance="High" />
472+
428473
</Target>
429474

430475
<!--

0 commit comments

Comments
 (0)