Skip to content

Commit

Permalink
[features] Fix minsize feature list order
Browse files Browse the repository at this point in the history
Only the last optimization level is effective.
To overwrite the level to minsize with the minsize feature flag,
the feature needs to be listed after the compilation modes.

Change-Id: I63ff18f0b6ae450441708e80abbf7228f031913f
Signed-off-by: Yi-Hsuan Deng <[email protected]>
  • Loading branch information
sasdf authored and timothytrippel committed Jan 8, 2025
1 parent 3eeb4b8 commit 1d67503
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
10 changes: 6 additions & 4 deletions features/common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,11 @@ feature(
enabled = False,
flag_sets = [
flag_set(
actions = C_ALL_COMPILE_ACTIONS + CPP_ALL_COMPILE_ACTIONS + LD_ALL_ACTIONS,
actions = C_ALL_COMPILE_ACTIONS + CPP_ALL_COMPILE_ACTIONS,
flag_groups = [
flag_group(
flags = [
"-Oz",
# Inline slightly more which is actually smaller.
"-mllvm", "--inline-threshold=10",
],
),
],
Expand Down Expand Up @@ -364,11 +362,15 @@ feature_set(
":exceptions",
":use_lld",
":lto",
":minsize",
":symbol_garbage_collection",
":dbg",
":fastbuild",
":opt",

# To overwrite the level to minsize with feature flags, it needs to be
# listed after the compilation modes.
":minsize",

":output_format",
":misc",
":coverage",
Expand Down
31 changes: 31 additions & 0 deletions platforms/riscv32/features/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,36 @@ feature(
provides = ["compilation_mode"],
)

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

feature(
name = "guards",
enabled = False,
Expand Down Expand Up @@ -168,6 +198,7 @@ feature_set(
":all_warnings_as_errors",
":fastbuild",
":opt",
":minsize",
":sys_spec",
":rv32_bitmanip",
],
Expand Down

0 comments on commit 1d67503

Please sign in to comment.