From e25448e10e577af86470b20ff665a8bcb91df5d6 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sun, 31 Mar 2024 19:03:37 +0300 Subject: [PATCH] Trade minor optimizations in MSVC Development builds for compile speed Enabled the disabled optimization flags with whole program optimization flag where the compilation speed doesn't seem to be affected at all, but binary size is slightly smaller. --- .../Platforms/Windows/WindowsToolchainBase.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Source/Tools/Flax.Build/Platforms/Windows/WindowsToolchainBase.cs b/Source/Tools/Flax.Build/Platforms/Windows/WindowsToolchainBase.cs index c31a63cca..c1cdcb0ee 100644 --- a/Source/Tools/Flax.Build/Platforms/Windows/WindowsToolchainBase.cs +++ b/Source/Tools/Flax.Build/Platforms/Windows/WindowsToolchainBase.cs @@ -484,12 +484,6 @@ namespace Flax.Build.Platforms // Remove unreferenced COMDAT commonArgs.Add("/Zc:inline"); - // Favor Small Code, Favor Fast Code - if (compileEnvironment.FavorSizeOrSpeed == FavorSizeOrSpeed.FastCode) - commonArgs.Add("/Ot"); - else if (compileEnvironment.FavorSizeOrSpeed == FavorSizeOrSpeed.SmallCode) - commonArgs.Add("/Os"); - // Run-Time Error Checks if (compileEnvironment.RuntimeChecks && !compileEnvironment.CompileAsWinRT) commonArgs.Add("/RTC1"); @@ -510,10 +504,16 @@ namespace Flax.Build.Platforms commonArgs.Add("/Zo"); } + // Favor Small Code, Favor Fast Code + if (compileEnvironment.FavorSizeOrSpeed == FavorSizeOrSpeed.FastCode) + commonArgs.Add("/Ot"); + else if (compileEnvironment.FavorSizeOrSpeed == FavorSizeOrSpeed.SmallCode) + commonArgs.Add("/Os"); if (compileEnvironment.Optimization) { // Enable Most Speed Optimizations - commonArgs.Add("/Ox"); + // Commented out due to /Og causing slow build times without /GL in development builds + //commonArgs.Add("/Ox"); // Generate Intrinsic Functions commonArgs.Add("/Oi"); @@ -523,6 +523,9 @@ namespace Flax.Build.Platforms if (compileEnvironment.WholeProgramOptimization) { + // Enable Most Speed Optimizations + commonArgs.Add("/Ox"); + // Whole Program Optimization commonArgs.Add("/GL"); } @@ -908,7 +911,7 @@ namespace Flax.Build.Platforms } else { - args.Add("/DEBUG"); + args.Add("/DEBUG"); // Same as /DEBUG:FULL } // Use Program Database