Skip to content

Commit

Permalink
Move native pgo into a targets file instead of being a separate proje…
Browse files Browse the repository at this point in the history
…ct to be more static-graph friendly.
  • Loading branch information
jkoritzinsky committed Sep 8, 2021
1 parent 5fbd69e commit 790204b
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 90 deletions.
56 changes: 56 additions & 0 deletions eng/nativepgo.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<Project>
<PropertyGroup>
<NativeOptimizationDataSupported Condition="'$(TargetOS)' == 'windows' And ('$(TargetArchitecture)' == 'x64' Or '$(TargetArchitecture)' == 'x86')">true</NativeOptimizationDataSupported>
<NativeOptimizationDataSupported Condition="'$(TargetOS)' == 'Linux' And '$(TargetArchitecture)' == 'x64'">true</NativeOptimizationDataSupported>
<NativeOptimizationDataSupported Condition="'$(NoPgoOptimize)' == 'true'">false</NativeOptimizationDataSupported>
<NativeOptimizationDataSupported Condition="'$(DotNetBuildFromSource)' == 'true'">false</NativeOptimizationDataSupported>

<_NativeOptimizationDataPackageTarget>$(TargetOS.ToLower())-$(TargetArchitecture.ToLower())</_NativeOptimizationDataPackageTarget>
<_NativeOptimizationDataPackageTarget Condition="'$(TargetOS)' == 'windows'">windows_nt-$(TargetArchitecture.ToLower())</_NativeOptimizationDataPackageTarget>

</PropertyGroup>
<ItemGroup>
<PackageReference Include="optimization.$(_NativeOptimizationDataPackageTarget).PGO.CoreCLR"
Version="$(optimizationPGOCoreCLRVersion)"
Condition="'$(optimizationPGOCoreCLRVersion)'!='' And '$(NativeOptimizationDataSupported)'!=''"
GeneratePathProperty="true" />
</ItemGroup>


<!-- -->
<!-- Task: GetPgoDataPackagePath -->
<!-- -->
<!-- Notes: -->
<!-- -->
<!-- DumpPgoDataPackagePath is used to get the path of the native PGO data -->
<!-- for other MSBuild projects, generally to pass to another project or -->
<!-- native script like build-runtime.cmd/sh. -->
<!-- -->

<Target Name="GetPgoDataPackagePath" Returns="$(PgoPackagePath)">
<PropertyGroup>
<PgoPackagePathProperty>Pkgoptimization_$(_NativeOptimizationDataPackageTarget)_PGO_CoreCLR</PgoPackagePathProperty>
</PropertyGroup>

<!--
Use an item group for expansion of $($(PgoPackagePathProperty)) (an illegal MSBuild expression)
i.e. the prop value's value.
-->
<ItemGroup>
<PgoPackagePathPropertyItemList Include="$(PgoPackagePathProperty)" />
<PgoPackagePathPropertyItemList>
<PgoPackagePath>$(%(Identity))</PgoPackagePath>
</PgoPackagePathPropertyItemList>
</ItemGroup>

<PropertyGroup>
<PgoPackagePath>@(PgoPackagePathPropertyItemList->'%(PgoPackagePath)')</PgoPackagePath>
</PropertyGroup>

<Error Condition="!Exists('$(PgoPackagePath)') And '$(NativeOptimizationDataSupported)' == 'true'" Text="Unable to locate restored PGO package at $(PgoPackagePath). Maybe the platform-specific package naming changed?" />
</Target>

<Target Name="OutputPgoPathForCI" Condition="'$(ContinuousIntegrationBuild)' == 'true' and '$(NativeOptimizationDataSupported)' == 'true'" DependsOnTargets="GetPgoDataPackagePath">
<Message Text="##vso[task.setvariable variable=CoreClrPgoDataArg]-pgodatapath &quot;$(PgoPackagePath)&quot;" />
</Target>
</Project>
4 changes: 0 additions & 4 deletions src/coreclr/.nuget/optdata/Directory.Build.props

This file was deleted.

4 changes: 0 additions & 4 deletions src/coreclr/.nuget/optdata/Directory.Build.targets

This file was deleted.

67 changes: 0 additions & 67 deletions src/coreclr/.nuget/optdata/optdata.proj

This file was deleted.

4 changes: 2 additions & 2 deletions src/coreclr/runtime-prereqs.proj
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include=".nuget/optdata/optdata.proj" />
<ProjectReference Condition="'$(TargetOS)' == 'Windows'" Include="ToolBox/SOS/DacTableGen/DacTableGen.csproj" />
</ItemGroup>

<Import Project="$(RepositoryEngineeringDir)versioning.targets" />
<Import Project="$(RepositoryEngineeringDir)nativepgo.targets" />

<Target Name="BuildPrereqs" BeforeTargets="Build" DependsOnTargets="GenerateRuntimeVersionFile" />
<Target Name="BuildPrereqs" BeforeTargets="Build" DependsOnTargets="GenerateRuntimeVersionFile;OutputPgoPathForCI" />
</Project>
18 changes: 5 additions & 13 deletions src/coreclr/runtime.proj
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,11 @@
<ProjectReference Include="runtime-prereqs.proj" GlobalPropertiesToRemove="$(NativeBuildPartitionPropertiesToRemove)" />
</ItemGroup>

<Import Project="$(RepositoryEngineeringDir)nativepgo.targets" />

<Target Name="BuildRuntime"
DependsOnTargets="GetPgoDataPackagePath"
BeforeTargets="Build">

<!-- Get the path to PGO data to pass to the runtime build script. -->
<MSBuild
Projects=".nuget/optdata/optdata.proj"
Targets="GetPgoDataPackagePath">
<Output
TaskParameter="TargetOutputs"
PropertyName="PgoDataPath" />
</MSBuild>


<ItemGroup>
<_CoreClrBuildArg Condition="'$(TargetArchitecture)' != ''" Include="-$(TargetArchitecture)" />
<_CoreClrBuildArg Condition="!$([MSBuild]::IsOsPlatform(Windows)) and '$(CMakeArgs)' != ''" Include="$(CMakeArgs)" />
Expand All @@ -37,14 +29,14 @@
('$(TargetArchitecture)' == 'x86' or '$(TargetArchitecture)' == 'x64') and
'$(Configuration)' == 'Release' and
'$(ClrRuntimeSubset)' == 'true' and
'$(NoPgoOptimize)' != 'true' and
'$(NativeOptimizationDataSupported)' == 'true' and
'$(PgoInstrument)' != 'true'"
Include="-enforcepgo" />
<_CoreClrBuildArg Condition="$([MSBuild]::IsOsPlatform(Windows)) and '$(CrossDac)' != ''" Include="-$(CrossDac)dac" />
<_CoreClrBuildArg Condition="'$(Ninja)' == 'true' and !$([MSBuild]::IsOsPlatform(Windows))" Include="-ninja" />
<_CoreClrBuildArg Condition="'$(Ninja)' == 'false' and $([MSBuild]::IsOsPlatform(Windows))" Include="-msbuild" />
<_CoreClrBuildArg Condition="'$(PgoInstrument)' == 'true'" Include="-pgoinstrument" />
<_CoreClrBuildArg Condition="'$(NoPgoOptimize)' != 'true' and '$(PgoInstrument)' != 'true'" Include="-pgodatapath &quot;$(PgoDataPath)&quot;" />
<_CoreClrBuildArg Condition="'$(NativeOptimizationDataSupported)' == 'true' and '$(PgoInstrument)' != 'true'" Include="-pgodatapath &quot;$(PgoPackagePath)&quot;" />
</ItemGroup>

<ItemGroup Condition="'$(ClrFullNativeBuild)' != 'true'">
Expand Down

0 comments on commit 790204b

Please sign in to comment.