You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +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:
@@ -40,6 +40,9 @@ def get_flags():
|
||||
return [
|
||||
("arch", detect_arch()),
|
||||
("use_volk", False),
|
||||
# Benefits of LTO for macOS (size, performance) haven't been clearly established yet.
|
||||
# So for now we override the default value which may be set when using `production=yes`.
|
||||
("lto", "none"),
|
||||
]
|
||||
|
||||
|
||||
@@ -166,6 +169,15 @@ def configure(env):
|
||||
env["RANLIB"] = basecmd + "ranlib"
|
||||
env["AS"] = basecmd + "as"
|
||||
|
||||
# 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"])
|
||||
|
||||
if env["use_ubsan"] or env["use_asan"] or env["use_tsan"]:
|
||||
env.extra_suffix += ".san"
|
||||
env.Append(CCFLAGS=["-DSANITIZERS_ENABLED"])
|
||||
|
||||
Reference in New Issue
Block a user