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

Add PGO for F# compiler #42514

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
19 changes: 19 additions & 0 deletions src/Layout/tool_fsharp/tool_fsc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,31 @@
<ServerGarbageCollection>true</ServerGarbageCollection>
</PropertyGroup>

<!-- MIBC, PGO -->
<PropertyGroup>
<MibcTargetOS>linux</MibcTargetOS>
<!-- We deliberately want to use linux mibc pgo data on macOS -->
<MibcTargetOS Condition="$([MSBuild]::IsOSPlatform('OSX'))">linux</MibcTargetOS>
Copy link
Member

Choose a reason for hiding this comment

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

When the sdk builds it builds cross target --- ie the tooling used to build the product doesnot necessarily match the build target.

When you do mibc you need to match the build target not the tooling platform.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmm alright, I am trying to leverage NETCoreSdkRuntimeIdentifier now - is this the right thing?

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably not :)

<MibcTargetOS Condition="$([MSBuild]::IsOSPlatform('WINDOWS'))">windows_nt</MibcTargetOS>
<MibcPath>$(PkgMicrosoft_FSharp_Compiler)/contentFiles/mibc</MibcPath>
<MibcTargetArchitecture>$([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant)</MibcTargetArchitecture>
<MibcCurrentMachineArcitecture>$(MibcTargetOS)-$(MibcTargetArchitecture)</MibcCurrentMachineArcitecture>
<MibcFile>$(MibcPath)/optimization.$(MibcCurrentMachineArcitecture).mibc.runtime/DotNet_FSharp.mibc</MibcFile>
<ReadyToRunOptimizationData>$(MibcFile)</ReadyToRunOptimizationData>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.FSharp.Compiler" ExcludeAssets="contentFiles" GeneratePathProperty="true" />
<PackageReference Include="Microsoft.Build.Framework" />
<PackageReference Include="Microsoft.Build.Tasks.Core" />
<PackageReference Include="Microsoft.Build.Utilities.Core" />
</ItemGroup>

<!-- MIBC don't work for SB yet: https://github.com/dotnet/source-build/issues/247 -->
<Target Name="ValidateMibcFile" AfterTargets="_ResolvePublishNuGetPackagePdbsAndXml" Condition="'$(DotNetBuildSourceOnly)' != 'true'">
<Error Condition="!Exists('$(MibcFile)')" Text="MIBC file '$(MibcFile)' does not exist." />
</Target>

<Target Name="_ResolvePublishNuGetPackagePdbsAndXml"
AfterTargets="_ResolveCopyLocalAssetsForPublish">
<PropertyGroup>
Expand All @@ -29,6 +47,7 @@
<FilesToCopyFromFSharpCompilerPackage Include="$(PkgMicrosoft_FSharp_Compiler)/contentFiles/$(FSharpCorePath)/FSharp.Core.*.nupkg" SubDir="library-packs\"/>
<FilesToCopyFromFSharpCompilerPackage Include="$(PkgMicrosoft_FSharp_Compiler)/contentFiles/$(FSharpCorePath)/Microsoft.FSharp.Core.NetSdk.props" SubDir="" />
<FilesToCopyFromFSharpCompilerPackage Include="$(PkgMicrosoft_FSharp_Compiler)/contentFiles/any/any/*" Exclude="$(PkgMicrosoft_FSharp_Compiler)/contentFiles/any/any/Microsoft.FSharp.Core.NetSdk.props" SubDir="" />
<FilesToCopyFromFSharpCompilerPackage Include="$(MibcPath)/*" SubDir="" Condition="'$(DotNetBuildSourceOnly)' != 'true'" />
</ItemGroup>
<ItemGroup>
<ResolvedFileToPublish
Expand Down
Loading