Skip to content
Merged
Show file tree
Hide file tree
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
Next Next commit
Re-enable ngen for desktop compilers
  • Loading branch information
KevinRansom committed Mar 28, 2019
commit 4b8707e93fbdb6c6db0807f1cccba08e7969e6ce
2 changes: 1 addition & 1 deletion FSharpBuild.Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>

<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
<Import Project="eng\targets\NuGet.targets" />
<Import Project="eng\targets\NGenBinaries.targets" />
<Import Project="FSharp.Profiles.props" />

<PropertyGroup Condition="'$(UseAssetTargetFallback)' == 'true'">
Expand Down
41 changes: 41 additions & 0 deletions eng/targets/NGenBinaries.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<Project>
<Target Name="NGenWindowsBinaries"
AfterTargets="AfterBuild"
DependsOnTargets="CheckAdministratorPrivilege"
Condition="'$(OS)' != 'Unix' AND
$(TargetFramework.StartsWith('net4')) AND
'$(NGenBinary)' == 'true' AND
Exists('$(TargetPath)') ">
<PropertyGroup>
<PathToNGen64>$(windir)\Microsoft.NET\Framework64\v4.0.30319\ngen.exe</PathToNGen64>
<PathToNGen32>$(windir)\Microsoft.NET\Framework\v4.0.30319\ngen.exe</PathToNGen32>
<PathToSN32>$(WindowsSDK_ExecutablePath_x86)sn.exe</PathToSN32>
</PropertyGroup>

<!--
Enable Skip Verification and then NGen for both 32 and 64 bit product.
If compiling use the app config file, if present.
-->
<Exec Command='"$(PathToSN32)" /Vr "$(TargetPath)"' Condition = "Exists('$(PathToSN32)') AND Exists('$(TargetPath)') AND '$(IsAdministrator)' == 'true'"/>

<Exec Command='"$(PathToNGen64)" install "$(TargetPath)" /ExeConfig:$(TargetPath)' Condition = "Exists('$(PathToNGen64)') AND '$(PlatformTarget)' != 'x86' AND Exists('$(TargetPath).config') AND '$(IsAdministrator)' == 'true'"/>
<Exec Command='"$(PathToNGen32)" install "$(TargetPath)" /ExeConfig:$(TargetPath)' Condition = "Exists('$(PathToNGen32)') AND '$(PlatformTarget)' != 'x64' AND Exists('$(TargetPath).config') AND '$(IsAdministrator)' == 'true'"/>
<Exec Command='"$(PathToNGen64)" install "$(TargetPath)"' Condition = " Exists('$(PathToNGen64)') AND '$(PlatformTarget)' != 'x86' AND (!Exists('$(TargetPath).config')) AND '$(IsAdministrator)' == 'true' "/>
<Exec Command='"$(PathToNGen32)" install "$(TargetPath)"' Condition = " Exists('$(PathToNGen32)') AND '$(PlatformTarget)' != 'x64' AND (!Exists('$(TargetPath).config')) AND '$(IsAdministrator)' == 'true' "/>
</Target>

<!-- Amazingly the net session command returns 0 if in an administrator session and > 0 if not -->
<Target Name="CheckAdministratorPrivilege"
BeforeTargets="BeforeCompile"
Condition="'$(OS)' != 'Unix'">
<Exec Command="NET SESSION &lt;nul 2&lt;nul" ContinueOnError="true" IgnoreExitCode="true">
<Output TaskParameter="ExitCode" PropertyName="ErrorCode"/>
</Exec>
<PropertyGroup>
<IsAdministrator Condition="'$(ErrorCode)' == '0'">true</IsAdministrator>
<IsAdministrator Condition="'$(ErrorCode)' != '0'">false</IsAdministrator>
<DelaySign Condition="'$(IsAdministrator)' == 'true'">true</DelaySign>
<PublicSign Condition="'$(IsAdministrator)' == 'true'">false</PublicSign>
</PropertyGroup>
</Target>
</Project>
1 change: 1 addition & 0 deletions src/fsharp/FSharp.Build/FSharp.Build.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<NoWarn>$(NoWarn);45;55;62;75;1204</NoWarn>
<AllowCrossTargeting>true</AllowCrossTargeting>
<OtherFlags>$(OtherFlags) --maxerrors:20 --extraoptimizationloops:1</OtherFlags>
<NGenBinary>true</NGenBinary>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<NoWarn>$(NoWarn);45;55;62;75;1182;1204</NoWarn>
<AllowCrossTargeting>true</AllowCrossTargeting>
<OtherFlags>$(OtherFlags) --maxerrors:20 --extraoptimizationloops:1</OtherFlags>
<NGenBinary>true</NGenBinary>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<UseAssetTargetFallback>true</UseAssetTargetFallback>
<Tailcalls>true</Tailcalls> <!-- .tail annotations always emitted for this binary, even in debug mode -->
<SkipPDBConversion>true</SkipPDBConversion>
<NGenBinary>true</NGenBinary>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net46' AND '$(OS)' == 'Windows_NT'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

<PropertyGroup>
<TargetFramework>net46</TargetFramework>
<NGenBinary>true</NGenBinary>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/fsharp/FSharp.Core/FSharp.Core.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<DefineConstants Condition="'$(Configuration)' == 'Proto'">BUILDING_WITH_LKG;$(DefineConstants)</DefineConstants>
<OtherFlags>$(OtherFlags) --warnon:1182 --compiling-fslib --compiling-fslib-40 --maxerrors:20 --extraoptimizationloops:1</OtherFlags>
<Tailcalls>true</Tailcalls> <!-- .tail annotations always emitted for this binary, even in debug mode -->
<NGenBinary>true</NGenBinary>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/fsharp/fsiAnyCpu/fsiAnyCpu.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<OtherFlags>$(OtherFlags) --warnon:1182 --maxerrors:20 --extraoptimizationloops:1</OtherFlags>
<Win32Resource>..\fsi\fsi.res</Win32Resource>
<UseAssetTargetFallback>true</UseAssetTargetFallback>
<NGenBinary>true</NGenBinary>
</PropertyGroup>

<PropertyGroup>
Expand Down