Skip to content

Commit

Permalink
[Web] Use Oz instead of Os when optimizing for size
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Faless committed Sep 24, 2024
1 parent c3e16cd commit 59d4a52
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down

0 comments on commit 59d4a52

Please sign in to comment.