summaryrefslogtreecommitdiff
path: root/SConstruct
diff options
context:
space:
mode:
Diffstat (limited to 'SConstruct')
-rw-r--r--SConstruct73
1 files changed, 36 insertions, 37 deletions
diff --git a/SConstruct b/SConstruct
index ce586010f4..200e8e5984 100644
--- a/SConstruct
+++ b/SConstruct
@@ -170,7 +170,7 @@ opts.Add(EnumVariable("arch", "CPU architecture", "auto", ["auto"] + architectur
opts.Add(EnumVariable("float", "Floating-point precision", "32", ("32", "64")))
opts.Add(EnumVariable("optimize", "Optimization type", "speed", ("speed", "size", "none")))
opts.Add(BoolVariable("production", "Set defaults to build Godot for use in production", False))
-opts.Add(BoolVariable("use_lto", "Use link-time optimization", False))
+opts.Add(EnumVariable("lto", "Link-time optimization (for production buids)", "none", ("none", "auto", "thin", "full")))
# Components
opts.Add(BoolVariable("deprecated", "Enable compatibility code for deprecated and removed features", True))
@@ -438,35 +438,6 @@ if selected_platform in platform_list:
)
env.SetOption("num_jobs", safer_cpu_count)
- # 'dev' and 'production' are aliases to set default options if they haven't been set
- # manually by the user.
- if env["dev"]:
- env["verbose"] = methods.get_cmdline_bool("verbose", True)
- env["warnings"] = ARGUMENTS.get("warnings", "extra")
- env["werror"] = methods.get_cmdline_bool("werror", True)
- if env["tools"]:
- env["tests"] = methods.get_cmdline_bool("tests", True)
- if env["production"]:
- env["use_static_cpp"] = methods.get_cmdline_bool("use_static_cpp", True)
- env["use_lto"] = methods.get_cmdline_bool("use_lto", True)
- env["debug_symbols"] = methods.get_cmdline_bool("debug_symbols", False)
- if not env["tools"] and env["target"] == "debug":
- print(
- "WARNING: Requested `production` build with `tools=no target=debug`, "
- "this will give you a full debug template (use `target=release_debug` "
- "for an optimized template with debug features)."
- )
- if env.msvc:
- print(
- "WARNING: For `production` Windows builds, you should use MinGW with GCC "
- "or Clang instead of Visual Studio, as they can better optimize the "
- "GDScript VM in a very significant way. MSVC LTO also doesn't work "
- "reliably for our use case."
- "If you want to use MSVC nevertheless for production builds, set "
- "`debug_symbols=no use_lto=no` instead of the `production=yes` option."
- )
- Exit(255)
-
env.extra_suffix = ""
if env["extra_suffix"] != "":
@@ -489,19 +460,42 @@ if selected_platform in platform_list:
env["LINKFLAGS"] = ""
env.Append(LINKFLAGS=str(LINKFLAGS).split())
- # Platform specific flags
+ # Platform specific flags.
+ # These can sometimes override default options.
flag_list = platform_flags[selected_platform]
for f in flag_list:
if not (f[0] in ARGUMENTS) or ARGUMENTS[f[0]] == "auto": # Allow command line to override platform flags
env[f[0]] = f[1]
- # Must happen after the flags' definition, so that they can be used by platform detect
+ # 'dev' and 'production' are aliases to set default options if they haven't been
+ # set manually by the user.
+ # These need to be checked *after* platform specific flags so that different
+ # default values can be set (e.g. to keep LTO off for `production` on some platforms).
+ if env["dev"]:
+ env["verbose"] = methods.get_cmdline_bool("verbose", True)
+ env["warnings"] = ARGUMENTS.get("warnings", "extra")
+ env["werror"] = methods.get_cmdline_bool("werror", True)
+ if env["tools"]:
+ env["tests"] = methods.get_cmdline_bool("tests", True)
+ if env["production"]:
+ env["use_static_cpp"] = methods.get_cmdline_bool("use_static_cpp", True)
+ env["debug_symbols"] = methods.get_cmdline_bool("debug_symbols", False)
+ # LTO "auto" means we handle the preferred option in each platform detect.py.
+ env["lto"] = ARGUMENTS.get("lto", "auto")
+ if not env["tools"] and env["target"] == "debug":
+ print(
+ "WARNING: Requested `production` build with `tools=no target=debug`, "
+ "this will give you a full debug template (use `target=release_debug` "
+ "for an optimized template with debug features)."
+ )
+
+ # Must happen after the flags' definition, as configure is when most flags
+ # are actually handled to change compile options, etc.
detect.configure(env)
- print(
- 'Building for platform "%s", architecture "%s", %s, target "%s".'
- % (selected_platform, env["arch"], "editor" if env["tools"] else "template", env["target"])
- )
+ # Needs to happen after configure to handle "auto".
+ if env["lto"] != "none":
+ print("Using LTO: " + env["lto"])
# Set our C and C++ standard requirements.
# C++17 is required as we need guaranteed copy elision as per GH-36436.
@@ -517,6 +511,11 @@ if selected_platform in platform_list:
# We apply it to CCFLAGS (both C and C++ code) in case it impacts C features.
env.Prepend(CCFLAGS=["/std:c++17"])
+ print(
+ 'Building for platform "%s", architecture "%s", %s, target "%s".'
+ % (selected_platform, env["arch"], "editor" if env["tools"] else "template", env["target"])
+ )
+
# Enforce our minimal compiler version requirements
cc_version = methods.get_compiler_version(env) or {
"major": None,
@@ -735,7 +734,7 @@ if selected_platform in platform_list:
env.module_list = modules_enabled
methods.sort_module_list(env)
- methods.update_version(env.module_version_string)
+ methods.generate_version_header(env.module_version_string)
env["PROGSUFFIX"] = suffix + env.module_version_string + env["PROGSUFFIX"]
env["OBJSUFFIX"] = suffix + env["OBJSUFFIX"]