Skip to content

Commit

Permalink
Pack MIBC files (#17513)
Browse files Browse the repository at this point in the history
* Pack MIBC files

* Update Directory.Build.targets

* temp

* temp

* mibc copies

* Update fsc.targets

* Update SourceBuildPrebuiltBaseline.xml

* only F#

* Update SourceBuildPrebuiltBaseline.xml

* Update SourceBuildPrebuiltBaseline.xml

* Fix

* don't bother for specific OS and stuff

* Update SourceBuildPrebuiltBaseline.xml

* Add forgotten applying to proto

* Use linux pgo on mac

* fix locking files

* Try something

* revert

* up

* up

* try something

* Update Directory.Build.targets

* updates

* Pass arguments explicitly

* Have an explicit task in proto

* Have an explicit task in proto

* Should be good now?

* Should be good now? Please

* Move restore baack

* Try something

* hah

* well how bout this bro

* Update single-test.fs

* Update SourceBuildPrebuiltBaseline.xml

* Update optimizationData.targets

* oops

* Update optimizationData.targets

* more hacks

* aaaaaand more hacks

* up

* bad copypaste

* oops

---------

Co-authored-by: Kevin Ransom <kevinr@microsoft.com>
Co-authored-by: KevinRansom <codecutter@hotmail.com>
Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com>
  • Loading branch information
4 people authored Aug 26, 2024
1 parent c8fbed0 commit 2f27f48
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<RepoRoot Condition="'$(RepoRoot)' == ''">$(MSBuildThisFileDirectory)</RepoRoot>
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
<FSharpNetCoreProductDefaultTargetFramework>net9.0</FSharpNetCoreProductDefaultTargetFramework>
<IgnoreMibc Condition="'$(IgnoreMibc)' == ''">$(DotNetBuildFromSource)</IgnoreMibc>
</PropertyGroup>

<!--
Expand Down
15 changes: 15 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,19 @@
</KnownCrossgen2Pack>
</ItemGroup>

<!-- We want to restore ALL the MIBCs when we build anything, since in the future it will contain different profiles, not only the FSC one we got from building Giraffe -->
<Import Project="$(MSBuildThisFileDirectory)\eng\restore\optimizationData.targets"/>
<ItemGroup>
<PackageReference Include="@(MIBCPackage)" />
</ItemGroup>

<Target Name="CopyMIBCWrapper" AfterTargets="Restore" BeforeTargets="Build;Pack">
<MSBuild
Projects="$(MSBuildThisFileDirectory)eng\restore\optimizationData.targets"
Properties="ArtifactsDir=$(MSBuildThisFileDirectory)artifacts\;NuGetPackageRoot=$(NuGetPackageRoot);MibcFiles=$(MibcFiles);optimizationwindows_ntx86MIBCRuntimeVersion=$(optimizationwindows_ntx86MIBCRuntimeVersion);optimizationwindows_ntx64MIBCRuntimeVersion=$(optimizationwindows_ntx64MIBCRuntimeVersion);optimizationwindows_ntarm64MIBCRuntimeVersion=$(optimizationwindows_ntarm64MIBCRuntimeVersion);optimizationlinuxx64MIBCRuntimeVersion=$(optimizationlinuxx64MIBCRuntimeVersion);optimizationlinuxarm64MIBCRuntimeVersion=$(optimizationlinuxarm64MIBCRuntimeVersion)"
Targets="CopyMIBC"
RemoveProperties="TargetFramework"
StopOnFirstFailure="True" />
</Target>

</Project>
27 changes: 27 additions & 0 deletions eng/restore/optimizationData.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project>
<!-- We want to restore ALL the MIBCs when we build anything, since in the future it will contain different profiles, not only the FSC one we got from building Giraffe -->
<ItemGroup Condition="'$(IgnoreMIBC)' != 'true'">
<MIBCPackage Include="optimization.windows_nt-x86.mibc.runtime" Version="$(optimizationwindows_ntx86MIBCRuntimeVersion)" />
<MIBCPackage Include="optimization.windows_nt-x64.mibc.runtime" Version="$(optimizationwindows_ntx64MIBCRuntimeVersion)" />
<MIBCPackage Include="optimization.windows_nt-arm64.mibc.runtime" Version="$(optimizationwindows_ntarm64MIBCRuntimeVersion)" />
<MIBCPackage Include="optimization.linux-x64.mibc.runtime" Version="$(optimizationlinuxx64MIBCRuntimeVersion)" />
<MIBCPackage Include="optimization.linux-arm64.mibc.runtime" Version="$(optimizationlinuxarm64MIBCRuntimeVersion)" />
</ItemGroup>

<!-- We copy all packages to the output (per architecture) -->
<Target Name="CopyMIBC">
<ItemGroup>
<MibcFiles Include="$(NuGetPackageRoot)%(MibcPackage.Identity)\%(MibcPackage.Version)\**\DotNet_FSharp.mibc" />
</ItemGroup>

<Copy
SourceFiles="@(MibcFiles)"
DestinationFolder="$(ArtifactsDir)mibc\%(MibcPackage.Identity)\"
SkipUnchangedFiles="true" />

<Copy
SourceFiles="@(MibcFiles)"
DestinationFolder="$(ArtifactsDir)mibc-proto\%(MibcPackage.Identity)\"
SkipUnchangedFiles="true" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<NuspecProperty Include="configuration=$(Configuration)" />
</ItemGroup>

<ItemGroup Condition="'$(IgnoreMibc)' != 'true'">
<NuspecProperty Include="mibcRoot=$(ArtifactsDir)\mibc" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(MSBuildThisFileDirectory)..\fsi\fsiProject\fsi.fsproj" />
<ProjectReference Include="$(MSBuildThisFileDirectory)..\fsc\fscProject\fsc.fsproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
<file src="FSharp.Build\$configuration$\netstandard2.0\Microsoft.FSharp.NetSdk.targets" target="contentFiles\any\any" />
<file src="FSharp.Build\$configuration$\netstandard2.0\Microsoft.FSharp.Overrides.NetSdk.targets" target="contentFiles\any\any" />

<!-- PGO, MIBC -->
<file src="$mibcRoot$\**\*.mibc" target="contentFiles\mibc" />

<!-- resources -->
<file src="FSharp.Core\$configuration$\netstandard2.0\**\FSharp.Core.resources.dll"
target="lib\$fSharpNetCoreProductTargetFramework$" />
Expand Down
13 changes: 13 additions & 0 deletions src/fsc/fscProject/fsc.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,18 @@
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Proto'">
<MibcTargetOS>linux</MibcTargetOS>
<!-- We deliberately want to use linux mibc pgo data on macOS -->
<MibcTargetOS Condition="$([MSBuild]::IsOSPlatform('OSX'))">linux</MibcTargetOS>
<MibcTargetOS Condition="$([MSBuild]::IsOSPlatform('WINDOWS'))">windows_nt</MibcTargetOS>
<MibcTargetArchitecture>$([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant)</MibcTargetArchitecture>
<MibcCurrentMachineArcitecture>$(MibcTargetOS)-$(MibcTargetArchitecture)</MibcCurrentMachineArcitecture>
<MibcFile>$(ArtifactsDir)mibc-proto\optimization.$(MibcCurrentMachineArcitecture).mibc.runtime\DotNet_FSharp.mibc</MibcFile>

<TargetFramework>$(FSharpNetCoreProductTargetFramework)</TargetFramework>
<PublishReadyToRun>$(EnablePublishReadyToRun)</PublishReadyToRun>
<RuntimeIdentifier>$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
<ReadyToRunOptimizationData>$(MibcFile)</ReadyToRunOptimizationData>
</PropertyGroup>

<ItemGroup Condition="'$(Configuration)' == 'Proto'">
Expand All @@ -24,6 +33,10 @@
<IntermediateOutputPath>$(ArtifactsDir)obj/$(MSBuildProjectName)/$(Configuration)/</IntermediateOutputPath>
</PropertyGroup>

<Target Name="ValidateMibcFile" AfterTargets="CopyMIBC" BeforeTargets="Build;Pack" Condition="'$(IgnoreMibc)' != 'true'">
<Error Condition="'$(Configuration)' == 'Proto' AND !Exists('$(MibcFile)')" Text="Mibc file '$(MibcFile)' does not exist." />
</Target>

<Import Project="$([MSBuild]::GetPathOfFileAbove('fsc.targets', '$(MSBuildThisFileDirectory)../'))" />

</Project>
1 change: 1 addition & 0 deletions tests/fsharp/single-test.fs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ let generateProjectArtifacts (pc:ProjectConfiguration) outputType (targetFramewo
<RestoreAdditionalProjectSources Condition = "" '$(RestoreAdditionalProjectSources)' == ''"">$(RestoreFromArtifactsPath)</RestoreAdditionalProjectSources>
<RestoreAdditionalProjectSources Condition = "" '$(RestoreAdditionalProjectSources)' != ''"">$(RestoreAdditionalProjectSources);$(RestoreFromArtifactsPath)</RestoreAdditionalProjectSources>
<RollForward>LatestMajor</RollForward>
<IgnoreMIBC>true</IgnoreMIBC>
</PropertyGroup>
<!-- FSharp.Core reference -->
Expand Down

0 comments on commit 2f27f48

Please sign in to comment.