Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions bazel/config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,13 @@ label_flag(
name = "PICO_FREERTOS_LIB",
build_setting_default = "//bazel:empty_cc_lib",
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add docstrings above these and add them to the exclusion list in BAZEL_ONLY_ALLOWLIST here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, Thanks. These have been added.

bool_flag(
name = "PICO_COMPILATION_OPT_OVERRIDE",
build_setting_default = False,
)

bool_flag(
name = "PICO_COMPILATION_DEBUG_OVERRIDE",
build_setting_default = False,
)
10 changes: 10 additions & 0 deletions bazel/constraint/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,13 @@ label_flag_matches(
flag = "//bazel/config:PICO_FREERTOS_LIB",
value = "//bazel:empty_cc_lib",
)

config_setting(
name = "pico_compiliation_opt_override",
flag_values = {"//bazel/config:PICO_COMPILATION_OPT_OVERRIDE": "True"},
)

config_setting(
name = "pico_compiliation_debug_override",
flag_values = {"//bazel/config:PICO_COMPILATION_DEBUG_OVERRIDE": "True"},
)
53 changes: 41 additions & 12 deletions bazel/toolchain/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,33 @@ 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_compiliation_debug_override": [],
"//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_compiliation_opt_override": [],
"//conditions:default": [
"-O2",
"-DNDEBUG",
],
})
)

configurable_toolchain_feature(
Expand Down Expand Up @@ -134,16 +152,27 @@ configurable_toolchain_feature(

# TODO: Make this shim unnecessary.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These shims aren't necessary anymore, you can just directly list opt_args and debug_args in the cc_feature rules.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, Thanks. You are right, they weren't needed. Removed

cc_args_list(
name = "all_opt_debug_args",
args = [":opt_debug_args"],
name = "all_debug_args",
args = [":debug_args"],
)

cc_args_list(
name = "all_opt_args",
args = [":opt_args"],
)

cc_feature(
name = "override_debug",
args = [":all_opt_debug_args"],
name = "dbg",
args = [":all_debug_args"],
overrides = "@rules_cc//cc/toolchains/features:dbg",
)

cc_feature(
name = "opt",
args = [":all_opt_args"],
overrides = "@rules_cc//cc/toolchains/features:opt",
)

HOSTS = (
("linux", "x86_64"),
("linux", "aarch64"),
Expand Down Expand Up @@ -180,7 +209,8 @@ _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:gc_sections",
"@pico-sdk//bazel/toolchain:cxx_no_exceptions",
"@pico-sdk//bazel/toolchain:cxx_no_rtti",
Expand All @@ -189,7 +219,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"],
Expand Down Expand Up @@ -232,7 +261,8 @@ _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:gc_sections",
"@pico-sdk//bazel/toolchain:cxx_no_exceptions",
"@pico-sdk//bazel/toolchain:cxx_no_rtti",
Expand All @@ -241,7 +271,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"],
Expand Down