From e0d2fbe8f7455b8d952ca15aaf729250c3fe79b8 Mon Sep 17 00:00:00 2001 From: Yi-Hsuan Deng Date: Tue, 17 Dec 2024 10:18:48 +0000 Subject: [PATCH] [features] Fix minsize feature list order 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 --- features/common/BUILD.bazel | 10 +++++---- platforms/riscv32/features/BUILD.bazel | 31 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/features/common/BUILD.bazel b/features/common/BUILD.bazel index 8014593..90215fa 100644 --- a/features/common/BUILD.bazel +++ b/features/common/BUILD.bazel @@ -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", ], ), ], @@ -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", diff --git a/platforms/riscv32/features/BUILD.bazel b/platforms/riscv32/features/BUILD.bazel index 80cb2aa..63e62b9 100644 --- a/platforms/riscv32/features/BUILD.bazel +++ b/platforms/riscv32/features/BUILD.bazel @@ -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, @@ -168,6 +198,7 @@ feature_set( ":all_warnings_as_errors", ":fastbuild", ":opt", + ":minsize", ":sys_spec", ":rv32_bitmanip", ],