Merge c7b4c9b88a1daba7f59f24e0b578581c58e75473 into 65a8907828ad87acd6a8e3363f175a64337b65cd

This commit is contained in:
Brad Nolan 2025-04-16 07:42:03 +12:00 committed by GitHub
commit 16bec823ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 92 additions and 15 deletions

View File

@ -300,3 +300,21 @@ label_flag(
name = "PICO_MBEDTLS_CONFIG",
build_setting_default = "//bazel:empty_cc_lib",
)
# PICO_BAZEL_CONFIG: PICO_COMPILATION_NO_OPT_ARGS, Makes the opt compilation mode a no-op so custom optimization arguments can be injected via the --copt flag instead, type=bool, default=0, group=build
bool_flag(
name = "PICO_COMPILATION_NO_OPT_ARGS",
build_setting_default = False,
)
# PICO_BAZEL_CONFIG: PICO_COMPILATION_NO_DEBUG_ARGS, Makes the debug compilation mode a no-op so custom debug arguments can be injected via the --copt flag instead, type=bool, default=0, group=build
bool_flag(
name = "PICO_COMPILATION_NO_DEBUG_ARGS",
build_setting_default = False,
)
# PICO_BAZEL_CONFIG: PICO_COMPILATION_NO_FASTBUILD_ARGS, Makes the fastbuild compilation mode a no-op so custom fastbuild arguments can be injected via the --copt flag instead, type=bool, default=0, group=build
bool_flag(
name = "PICO_COMPILATION_NO_FASTBUILD_ARGS",
build_setting_default = False,
)

View File

@ -258,3 +258,18 @@ label_flag_matches(
flag = "//bazel/config:PICO_MBEDTLS_CONFIG",
value = "//bazel:empty_cc_lib",
)
config_setting(
name = "pico_compilation_no_opt_args_set",
flag_values = {"//bazel/config:PICO_COMPILATION_NO_OPT_ARGS": "True"},
)
config_setting(
name = "pico_compilation_no_debug_args_set",
flag_values = {"//bazel/config:PICO_COMPILATION_NO_DEBUG_ARGS": "True"},
)
config_setting(
name = "pico_compilation_no_fastbuild_args_set",
flag_values = {"//bazel/config:PICO_COMPILATION_NO_FASBUILD_ARGS": "True"},
)

View File

@ -89,15 +89,46 @@ cc_args(
)
cc_args(
name = "opt_debug_args",
name = "debug_args",
actions = [
"@rules_cc//cc/toolchains/actions:compile_actions",
"@rules_cc//cc/toolchains/actions:link_actions",
],
args = [
"-Og", # TODO: Make this configurable.
"-g3",
args = select({
"//bazel/constraint:pico_compilation_no_debug_args_set": [],
"//conditions:default": [
"-Og",
"-g3",
],
})
)
cc_args(
name = "opt_args",
actions = [
"@rules_cc//cc/toolchains/actions:compile_actions",
"@rules_cc//cc/toolchains/actions:link_actions",
],
args = select({
"//bazel/constraint:pico_compilation_no_opt_args_set": [],
"//conditions:default": [
"-O2",
"-DNDEBUG",
],
})
)
cc_args(
name = "fastbuild_args",
actions = [
"@rules_cc//cc/toolchains/actions:compile_actions",
"@rules_cc//cc/toolchains/actions:link_actions",
],
args = select({
"//bazel/constraint:pico_compilation_no_fastbuild_args_set": [],
# The conditions default are kept as nothing here, The bazel docs default are -gmlt -Wl,-S.
"//conditions:default": [],
})
)
configurable_toolchain_feature(
@ -132,16 +163,23 @@ configurable_toolchain_feature(
linkopts = ["-Wl,-z,max-page-size=4096"],
)
# TODO: Make this shim unnecessary.
cc_args_list(
name = "all_opt_debug_args",
args = [":opt_debug_args"],
cc_feature(
name = "dbg",
args = [":debug_args"],
overrides = "@rules_cc//cc/toolchains/features:dbg",
)
cc_feature(
name = "override_debug",
args = [":all_opt_debug_args"],
overrides = "@rules_cc//cc/toolchains/features:dbg",
name = "opt",
args = [":opt_args"],
overrides = "@rules_cc//cc/toolchains/features:opt",
)
cc_feature(
name = "fastbuild",
args = [":fastbuild_args"],
overrides = "@rules_cc//cc/toolchains/features:fastbuild",
)
HOSTS = (
@ -180,7 +218,9 @@ _HOST_CPU_CONSTRAINTS = {
tags = ["manual"], # Don't try to build this in wildcard builds.
known_features = [
"@rules_cc//cc/toolchains/args:experimental_replace_legacy_action_config_features",
"@pico-sdk//bazel/toolchain:override_debug",
"@pico-sdk//bazel/toolchain:dbg",
"@pico-sdk//bazel/toolchain:opt",
"@pico-sdk//bazel/toolchain:fastbuild",
"@pico-sdk//bazel/toolchain:gc_sections",
"@pico-sdk//bazel/toolchain:cxx_no_exceptions",
"@pico-sdk//bazel/toolchain:cxx_no_rtti",
@ -189,7 +229,6 @@ _HOST_CPU_CONSTRAINTS = {
],
enabled_features = [
"@rules_cc//cc/toolchains/args:experimental_replace_legacy_action_config_features",
"@pico-sdk//bazel/toolchain:override_debug",
] + select({
"//bazel/constraint:pico_no_gc_sections_enabled": [],
"//conditions:default": [":gc_sections"],
@ -232,7 +271,9 @@ _HOST_CPU_CONSTRAINTS = {
tags = ["manual"], # Don't try to build this in wildcard builds.
known_features = [
"@rules_cc//cc/toolchains/args:experimental_replace_legacy_action_config_features",
"@pico-sdk//bazel/toolchain:override_debug",
"@pico-sdk//bazel/toolchain:dbg",
"@pico-sdk//bazel/toolchain:opt",
"@pico-sdk//bazel/toolchain:fastbuild",
"@pico-sdk//bazel/toolchain:gc_sections",
"@pico-sdk//bazel/toolchain:cxx_no_exceptions",
"@pico-sdk//bazel/toolchain:cxx_no_rtti",
@ -241,7 +282,6 @@ _HOST_CPU_CONSTRAINTS = {
],
enabled_features = [
"@rules_cc//cc/toolchains/args:experimental_replace_legacy_action_config_features",
"@pico-sdk//bazel/toolchain:override_debug",
] + select({
"//bazel/constraint:pico_no_gc_sections_enabled": [],
"//conditions:default": [":gc_sections"],

View File

@ -158,6 +158,10 @@ BAZEL_ONLY_ALLOWLIST = (
"PICO_BT_ENABLE_BLE",
"PICO_BT_ENABLE_CLASSIC",
"PICO_BT_ENABLE_MESH",
# Compilation modes remove, These allow the user to remove the defaults, with no args. See --compilation_mode cmd line option
"PICO_COMPILATION_NO_OPT_ARGS",
"PICO_COMPILATION_NO_DEBUG_ARGS",
"PICO_COMPILATION_NO_FASTBUILD_ARGS",
)