From 59d4a52fe47ae6131a43f644ced197f60ceb7fb3 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Tue, 24 Sep 2024 14:13:51 +0200 Subject: [PATCH] [Web] Use Oz instead of Os when optimizing for size LLVM has an Oz optimization flag, which they define as: `Like -Os (and thus -O2), but reduces code size further.` I've tested this, on a release builds, and the result is ~25% smaller uncompressed size, and ~10% smaller when compressed. --- SConstruct | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/SConstruct b/SConstruct index 0245531b45e..c520bcfe12e 100644 --- a/SConstruct +++ b/SConstruct @@ -770,8 +770,12 @@ else: env.Append(CCFLAGS=["-O2"]) env.Append(LINKFLAGS=["-O2"]) elif env["optimize"] == "size": - env.Append(CCFLAGS=["-Os"]) - env.Append(LINKFLAGS=["-Os"]) + if methods.using_emcc(env): + env.Append(CCFLAGS=["-Oz"]) + env.Append(LINKFLAGS=["-Oz"]) + else: + env.Append(CCFLAGS=["-Os"]) + env.Append(LINKFLAGS=["-Os"]) elif env["optimize"] == "debug": env.Append(CCFLAGS=["-Og"]) env.Append(LINKFLAGS=["-Og"])