Skip to content

Commit

Permalink
[features] Add feature for Oz minsize opt level
Browse files Browse the repository at this point in the history
When enabling LTO, Oz is required to have a smaller firmware size.

This PR adds the "minsize" feature, which will be enabled along with LTO
on some ROM_EXT targets through bazel transition.

In our tests with ROM_EXT on the master branch,
* Os + LTO ~ +2,904 bytes
* Oz - LTO ~ -1,260 bytes
* Oz  + LTO ~ -1,640 bytes

Change-Id: I141284b331b9760fb25f690bba4c10b02057f13f
Signed-off-by: Yi-Hsuan Deng <[email protected]>
  • Loading branch information
sasdf authored and timothytrippel committed Dec 13, 2024
1 parent 8551be6 commit a63989d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions features/common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,25 @@ feature(
],
)

feature(
name = "minsize",
enabled = False,
flag_sets = [
flag_set(
actions = C_ALL_COMPILE_ACTIONS + CPP_ALL_COMPILE_ACTIONS + LD_ALL_ACTIONS,
flag_groups = [
flag_group(
flags = [
"-Oz",
# Inline slightly more which is actually smaller.
"-mllvm", "--inline-threshold=10",
],
),
],
),
],
)

feature(
name = "symbol_garbage_collection",
enabled = True,
Expand Down Expand Up @@ -345,6 +364,7 @@ feature_set(
":exceptions",
":use_lld",
":lto",
":minsize",
":symbol_garbage_collection",
":dbg",
":fastbuild",
Expand Down

0 comments on commit a63989d

Please sign in to comment.