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
+22
View File
@@ -43,6 +43,10 @@ function newclangtoolchain(toolchain)
}
end
function is_clang()
return _OPTIONS.platform == "clang" or os.is_real("macosx") or os.is_real("ios")
end
newplatform {
name = "clang",
description = "Clang",
@@ -182,6 +186,7 @@ newoption {
description = "Set the shared data directory (default: /usr/share/ecode)",
}
newoption { trigger = "with-static-cpp", description = "Builds statically libstdc++" }
newoption { trigger = "with-lto", description = "Enables Link-Time Optimization for release builds." }
function explode(div,str)
if (div=='') then return false end
@@ -747,6 +752,23 @@ function parse_args()
if _OPTIONS["time-trace"] then
buildoptions { "-ftime-trace" }
end
if _OPTIONS["with-lto"] and not os.is_real("emscripten") then
configuration "release"
if is_vs() then
buildoptions { "/GL" }
linkoptions { "/LTCG" }
elseif is_clang() then
buildoptions { "-flto=thin" }
linkoptions { "-flto=thin" }
else
buildoptions { "-flto=auto" }
linkoptions { "-flto=auto" }
end
configuration {}
end
end
function add_static_links()