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.BufferSecurityCheck = true;
|
||||
options.CompileEnv.Inlining = true;
|
||||
options.CompileEnv.WholeProgramOptimization = false;
|
||||
options.CompileEnv.WholeProgramOptimization = true;
|
||||
|
||||
options.LinkEnv.DebugInformation = true;
|
||||
options.LinkEnv.LinkTimeCodeGeneration = false;
|
||||
options.LinkEnv.LinkTimeCodeGeneration = true;
|
||||
options.LinkEnv.UseIncrementalLinking = true;
|
||||
options.LinkEnv.Optimization = true;
|
||||
break;
|
||||
|
||||
@@ -27,6 +27,8 @@ namespace Flax.Build.Platforms
|
||||
/// <seealso cref="Flax.Build.Platforms.WindowsToolchainBase" />
|
||||
public sealed class WindowsToolchain : WindowsToolchainBase
|
||||
{
|
||||
private Version _minVersion;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="WindowsToolchain"/> class.
|
||||
/// </summary>
|
||||
@@ -35,6 +37,14 @@ namespace Flax.Build.Platforms
|
||||
public WindowsToolchain(WindowsPlatform platform, TargetArchitecture architecture)
|
||||
: 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 />
|
||||
@@ -44,20 +54,12 @@ namespace Flax.Build.Platforms
|
||||
|
||||
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;
|
||||
if (winMinVer.Major >= 10)
|
||||
if (_minVersion.Major >= 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
|
||||
else if (winMinVer.Major == 8)
|
||||
else if (_minVersion.Major == 8)
|
||||
winVer = 0x0602; // Windows 8
|
||||
else
|
||||
winVer = 0x0601; // Windows 7
|
||||
@@ -74,6 +76,18 @@ namespace Flax.Build.Platforms
|
||||
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 />
|
||||
public override void LinkFiles(TaskGraph graph, BuildOptions options, string outputFilePath)
|
||||
{
|
||||
|
||||
@@ -511,16 +511,13 @@ namespace Flax.Build.Platforms
|
||||
commonArgs.Add("/Os");
|
||||
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
|
||||
commonArgs.Add("/Oi");
|
||||
|
||||
// Frame-Pointer Omission
|
||||
commonArgs.Add("/Oy");
|
||||
|
||||
// Only use /Ox with /GL to prevent too long build times
|
||||
if (compileEnvironment.WholeProgramOptimization)
|
||||
{
|
||||
// Enable Most Speed Optimizations
|
||||
@@ -889,7 +886,7 @@ namespace Flax.Build.Platforms
|
||||
}
|
||||
|
||||
// Link Incrementally
|
||||
if (linkEnvironment.UseIncrementalLinking)
|
||||
if (linkEnvironment.UseIncrementalLinking && !linkEnvironment.LinkTimeCodeGeneration)
|
||||
{
|
||||
args.Add("/INCREMENTAL");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user