Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCons: Default optimize to auto, fixing target/dev_build inference for Web #94107

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ opts.Add(EnumVariable("arch", "CPU architecture", "auto", ["auto"] + architectur
opts.Add(BoolVariable("dev_build", "Developer build with dev-only debugging code (DEV_ENABLED)", False))
opts.Add(
EnumVariable(
"optimize", "Optimization level", "speed_trace", ("none", "custom", "debug", "speed", "speed_trace", "size")
"optimize",
"Optimization level (by default inferred from 'target' and 'dev_build')",
"auto",
("auto", "none", "custom", "debug", "speed", "speed_trace", "size"),
)
)
opts.Add(BoolVariable("debug_symbols", "Build with debugging symbols", False))
Expand Down Expand Up @@ -466,14 +469,15 @@ env.editor_build = env["target"] == "editor"
env.dev_build = env["dev_build"]
env.debug_features = env["target"] in ["editor", "template_debug"]

if env.dev_build:
opt_level = "none"
elif env.debug_features:
opt_level = "speed_trace"
else: # Release
opt_level = "speed"
if env["optimize"] == "auto":
if env.dev_build:
opt_level = "none"
elif env.debug_features:
opt_level = "speed_trace"
else: # Release
opt_level = "speed"
env["optimize"] = ARGUMENTS.get("optimize", opt_level)

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

if env.editor_build:
Expand Down
1 change: 1 addition & 0 deletions platform/web/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def get_flags():
# -Os reduces file size by around 5 MiB over -O3. -Oz only saves about
# 100 KiB over -Os, which does not justify the negative impact on
# run-time performance.
# Note that this overrides the "auto" behavior for target/dev_build.
"optimize": "size",
}

Expand Down
Loading