Skip to content

Commit 8897c77

Browse files
committed
SCons: Default optimize to auto, fixing target/dev_build inference for Web
Fixes #94087.
1 parent b0467d0 commit 8897c77

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

SConstruct

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,10 @@ opts.Add(EnumVariable("arch", "CPU architecture", "auto", ["auto"] + architectur
200200
opts.Add(BoolVariable("dev_build", "Developer build with dev-only debugging code (DEV_ENABLED)", False))
201201
opts.Add(
202202
EnumVariable(
203-
"optimize", "Optimization level", "speed_trace", ("none", "custom", "debug", "speed", "speed_trace", "size")
203+
"optimize",
204+
"Optimization level (by default inferred from 'target' and 'dev_build')",
205+
"auto",
206+
("auto", "none", "custom", "debug", "speed", "speed_trace", "size"),
204207
)
205208
)
206209
opts.Add(BoolVariable("debug_symbols", "Build with debugging symbols", False))
@@ -466,14 +469,15 @@ env.editor_build = env["target"] == "editor"
466469
env.dev_build = env["dev_build"]
467470
env.debug_features = env["target"] in ["editor", "template_debug"]
468471

469-
if env.dev_build:
470-
opt_level = "none"
471-
elif env.debug_features:
472-
opt_level = "speed_trace"
473-
else: # Release
474-
opt_level = "speed"
472+
if env["optimize"] == "auto":
473+
if env.dev_build:
474+
opt_level = "none"
475+
elif env.debug_features:
476+
opt_level = "speed_trace"
477+
else: # Release
478+
opt_level = "speed"
479+
env["optimize"] = ARGUMENTS.get("optimize", opt_level)
475480

476-
env["optimize"] = ARGUMENTS.get("optimize", opt_level)
477481
env["debug_symbols"] = methods.get_cmdline_bool("debug_symbols", env.dev_build)
478482

479483
if env.editor_build:

platform/web/detect.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def get_flags():
7878
# -Os reduces file size by around 5 MiB over -O3. -Oz only saves about
7979
# 100 KiB over -Os, which does not justify the negative impact on
8080
# run-time performance.
81+
# Note that this overrides the "auto" behavior for target/dev_build.
8182
"optimize": "size",
8283
}
8384

0 commit comments

Comments
 (0)