Add optional LTO and harden Windows clipboard handling

- add --with-lto support to Premake 4 and 5 release builds
  - use ThinLTO with Clang, automatic LTO with GCC, and LTCG with MSVC
  - exclude Emscripten builds from LTO configuration
  - retry SDL2 clipboard writes on Windows when the clipboard is temporarily unavailable
  - make the UIMergeView copy regression test independent of the system clipboard
This commit is contained in:
Martín Lucas Golini
2026-09-01 00:46:13 -03:00
parent 6e467dbb59
commit 47f9336c0a
4 changed files with 55 additions and 4 deletions
+16
View File
@@ -51,6 +51,7 @@ newoption {
description = "Set the shared data directory",
}
newoption { trigger = "with-static-cpp", description = "Builds statically libstdc++" }
newoption { trigger = "with-lto", description = "Enables Link-Time Optimization for release builds." }
function is_arm64_arch()
local arch = _OPTIONS["arch"]
@@ -714,6 +715,21 @@ function parse_args()
if _OPTIONS["time-trace"] then
buildoptions { "-ftime-trace" }
end
if _OPTIONS["with-lto"] then
filter { "configurations:release*", "toolset:gcc", "not system:emscripten" }
buildoptions { "-flto=auto" }
linkoptions { "-flto=auto" }
filter { "configurations:release*", "toolset:clang", "not system:emscripten" }
buildoptions { "-flto=thin" }
linkoptions { "-flto=thin" }
filter { "configurations:release*", "toolset:msc" }
linktimeoptimization "On"
filter {}
end
end
function add_static_links()