You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-06 12:20:30 +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:
@@ -191,7 +191,6 @@ def get_opts():
|
||||
),
|
||||
BoolVariable("use_mingw", "Use the Mingw compiler, even if MSVC is installed.", False),
|
||||
BoolVariable("use_llvm", "Use the LLVM compiler", False),
|
||||
BoolVariable("use_thinlto", "Use ThinLTO", False),
|
||||
BoolVariable("use_static_cpp", "Link MinGW/MSVC C++ runtime libraries statically", True),
|
||||
BoolVariable("use_asan", "Use address sanitizer (ASAN)", False),
|
||||
]
|
||||
@@ -449,7 +448,10 @@ def configure_msvc(env, vcvars_msvc_config):
|
||||
|
||||
## LTO
|
||||
|
||||
if env["use_lto"]:
|
||||
if env["lto"] != "none":
|
||||
if env["lto"] == "thin":
|
||||
print("ThinLTO is only compatible with LLVM, use `use_llvm=yes` or `lto=full`.")
|
||||
sys.exit(255)
|
||||
env.AppendUnique(CCFLAGS=["/GL"])
|
||||
env.AppendUnique(ARFLAGS=["/LTCG"])
|
||||
if env["progress"]:
|
||||
@@ -562,17 +564,19 @@ def configure_mingw(env):
|
||||
if try_cmd("gcc-ranlib --version", env["mingw_prefix"], env["arch"]):
|
||||
env["RANLIB"] = mingw_bin_prefix + "gcc-ranlib"
|
||||
|
||||
if env["use_lto"]:
|
||||
if not env["use_llvm"] and env.GetOption("num_jobs") > 1:
|
||||
if env["lto"] != "none":
|
||||
if env["lto"] == "thin":
|
||||
if not env["use_llvm"]:
|
||||
print("ThinLTO is only compatible with LLVM, use `use_llvm=yes` or `lto=full`.")
|
||||
sys.exit(255)
|
||||
env.Append(CCFLAGS=["-flto=thin"])
|
||||
env.Append(LINKFLAGS=["-flto=thin"])
|
||||
elif not env["use_llvm"] and env.GetOption("num_jobs") > 1:
|
||||
env.Append(CCFLAGS=["-flto"])
|
||||
env.Append(LINKFLAGS=["-flto=" + str(env.GetOption("num_jobs"))])
|
||||
else:
|
||||
if env["use_thinlto"]:
|
||||
env.Append(CCFLAGS=["-flto=thin"])
|
||||
env.Append(LINKFLAGS=["-flto=thin"])
|
||||
else:
|
||||
env.Append(CCFLAGS=["-flto"])
|
||||
env.Append(LINKFLAGS=["-flto"])
|
||||
env.Append(CCFLAGS=["-flto"])
|
||||
env.Append(LINKFLAGS=["-flto"])
|
||||
|
||||
env.Append(LINKFLAGS=["-Wl,--stack," + str(STACK_SIZE)])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user