1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

SCons: Refactor LTO options with lto=<none|thin|full>

Adds support for LTO on macOS and Android. We don't have much experience
with LTO on these platforms so for now we keep it disabled by default
even when `production=yes` is set.

Similarly for iOS where we ship object files for the user to link in
Xcode so LTO makes builds extremely slow to link.

`production=yes` defaults to full LTO.
ThinLTO is much faster for LLVM-based compilers but seems to produce
bigger binaries (at least for the Web platform).
This commit is contained in:
Rémi Verschelde
2022-07-21 15:15:54 +02:00
parent 69233093d7
commit c2c659db32
7 changed files with 94 additions and 60 deletions

View File

@@ -39,6 +39,9 @@ def get_flags():
("arch", "arm64"), # Default for convenience.
("tools", False),
("use_volk", False),
# Disable by default even if production is set, as it makes linking in Xcode
# on exports very slow and that's not what most users expect.
("lto", "none"),
]
@@ -70,9 +73,14 @@ def configure(env):
env.Append(CCFLAGS=["-gdwarf-2", "-O0"])
env.Append(CPPDEFINES=["_DEBUG", ("DEBUG", 1)])
if env["use_lto"]:
env.Append(CCFLAGS=["-flto"])
env.Append(LINKFLAGS=["-flto"])
# LTO
if env["lto"] != "none":
if env["lto"] == "thin":
env.Append(CCFLAGS=["-flto=thin"])
env.Append(LINKFLAGS=["-flto=thin"])
else:
env.Append(CCFLAGS=["-flto"])
env.Append(LINKFLAGS=["-flto"])
## Compiler configuration