Optimize Development builds to use SSE2 by default on Windows and use SSE4.1 when targeting Windows 11
This commit is contained in:
@@ -281,10 +281,10 @@ namespace Flax.Build
|
|||||||
options.CompileEnv.IntrinsicFunctions = true;
|
options.CompileEnv.IntrinsicFunctions = true;
|
||||||
options.CompileEnv.BufferSecurityCheck = true;
|
options.CompileEnv.BufferSecurityCheck = true;
|
||||||
options.CompileEnv.Inlining = true;
|
options.CompileEnv.Inlining = true;
|
||||||
options.CompileEnv.WholeProgramOptimization = false;
|
options.CompileEnv.WholeProgramOptimization = true;
|
||||||
|
|
||||||
options.LinkEnv.DebugInformation = true;
|
options.LinkEnv.DebugInformation = true;
|
||||||
options.LinkEnv.LinkTimeCodeGeneration = false;
|
options.LinkEnv.LinkTimeCodeGeneration = true;
|
||||||
options.LinkEnv.UseIncrementalLinking = true;
|
options.LinkEnv.UseIncrementalLinking = true;
|
||||||
options.LinkEnv.Optimization = true;
|
options.LinkEnv.Optimization = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ namespace Flax.Build.Platforms
|
|||||||
/// <seealso cref="Flax.Build.Platforms.WindowsToolchainBase" />
|
/// <seealso cref="Flax.Build.Platforms.WindowsToolchainBase" />
|
||||||
public sealed class WindowsToolchain : WindowsToolchainBase
|
public sealed class WindowsToolchain : WindowsToolchainBase
|
||||||
{
|
{
|
||||||
|
private Version _minVersion;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="WindowsToolchain"/> class.
|
/// Initializes a new instance of the <see cref="WindowsToolchain"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -35,6 +37,14 @@ namespace Flax.Build.Platforms
|
|||||||
public WindowsToolchain(WindowsPlatform platform, TargetArchitecture architecture)
|
public WindowsToolchain(WindowsPlatform platform, TargetArchitecture architecture)
|
||||||
: base(platform, architecture, WindowsPlatformToolset.Latest, WindowsPlatformSDK.Latest)
|
: base(platform, architecture, WindowsPlatformToolset.Latest, WindowsPlatformSDK.Latest)
|
||||||
{
|
{
|
||||||
|
// Select minimum Windows version
|
||||||
|
if (!Version.TryParse(Configuration.WindowsMinVer, out _minVersion))
|
||||||
|
{
|
||||||
|
if (int.TryParse(Configuration.WindowsMinVer, out var winMinVerMajor))
|
||||||
|
_minVersion = new Version(winMinVerMajor, 0);
|
||||||
|
else
|
||||||
|
_minVersion = new Version(7, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -44,20 +54,12 @@ namespace Flax.Build.Platforms
|
|||||||
|
|
||||||
options.CompileEnv.PreprocessorDefinitions.Add("PLATFORM_WINDOWS");
|
options.CompileEnv.PreprocessorDefinitions.Add("PLATFORM_WINDOWS");
|
||||||
|
|
||||||
// Select minimum Windows version
|
|
||||||
if (!Version.TryParse(Configuration.WindowsMinVer, out var winMinVer))
|
|
||||||
{
|
|
||||||
if (int.TryParse(Configuration.WindowsMinVer, out var winMinVerMajor))
|
|
||||||
winMinVer = new Version(winMinVerMajor, 0);
|
|
||||||
else
|
|
||||||
winMinVer = new Version(7, 0);
|
|
||||||
}
|
|
||||||
int winVer;
|
int winVer;
|
||||||
if (winMinVer.Major >= 10)
|
if (_minVersion.Major >= 10)
|
||||||
winVer = 0x0A00; // Windows 10
|
winVer = 0x0A00; // Windows 10
|
||||||
else if (winMinVer.Major == 8 && winMinVer.Minor >= 1)
|
else if (_minVersion.Major == 8 && _minVersion.Minor >= 1)
|
||||||
winVer = 0x0603; // Windows 8.1
|
winVer = 0x0603; // Windows 8.1
|
||||||
else if (winMinVer.Major == 8)
|
else if (_minVersion.Major == 8)
|
||||||
winVer = 0x0602; // Windows 8
|
winVer = 0x0602; // Windows 8
|
||||||
else
|
else
|
||||||
winVer = 0x0601; // Windows 7
|
winVer = 0x0601; // Windows 7
|
||||||
@@ -74,6 +76,18 @@ namespace Flax.Build.Platforms
|
|||||||
options.LinkEnv.InputLibraries.Add("delayimp.lib");
|
options.LinkEnv.InputLibraries.Add("delayimp.lib");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void SetupCompileCppFilesArgs(TaskGraph graph, BuildOptions options, List<string> args)
|
||||||
|
{
|
||||||
|
base.SetupCompileCppFilesArgs(graph, options, args);
|
||||||
|
|
||||||
|
if (Toolset >= WindowsPlatformToolset.v142 && _minVersion.Major >= 11)
|
||||||
|
{
|
||||||
|
// Windows 11 requires SSE4.2
|
||||||
|
args.Add("/d2archSSE42");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void LinkFiles(TaskGraph graph, BuildOptions options, string outputFilePath)
|
public override void LinkFiles(TaskGraph graph, BuildOptions options, string outputFilePath)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -511,16 +511,13 @@ namespace Flax.Build.Platforms
|
|||||||
commonArgs.Add("/Os");
|
commonArgs.Add("/Os");
|
||||||
if (compileEnvironment.Optimization)
|
if (compileEnvironment.Optimization)
|
||||||
{
|
{
|
||||||
// Enable Most Speed Optimizations
|
|
||||||
// Commented out due to /Og causing slow build times without /GL in development builds
|
|
||||||
//commonArgs.Add("/Ox");
|
|
||||||
|
|
||||||
// Generate Intrinsic Functions
|
// Generate Intrinsic Functions
|
||||||
commonArgs.Add("/Oi");
|
commonArgs.Add("/Oi");
|
||||||
|
|
||||||
// Frame-Pointer Omission
|
// Frame-Pointer Omission
|
||||||
commonArgs.Add("/Oy");
|
commonArgs.Add("/Oy");
|
||||||
|
|
||||||
|
// Only use /Ox with /GL to prevent too long build times
|
||||||
if (compileEnvironment.WholeProgramOptimization)
|
if (compileEnvironment.WholeProgramOptimization)
|
||||||
{
|
{
|
||||||
// Enable Most Speed Optimizations
|
// Enable Most Speed Optimizations
|
||||||
@@ -889,7 +886,7 @@ namespace Flax.Build.Platforms
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Link Incrementally
|
// Link Incrementally
|
||||||
if (linkEnvironment.UseIncrementalLinking)
|
if (linkEnvironment.UseIncrementalLinking && !linkEnvironment.LinkTimeCodeGeneration)
|
||||||
{
|
{
|
||||||
args.Add("/INCREMENTAL");
|
args.Add("/INCREMENTAL");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user