bazelbuild / bazelbuild/rules_cc

Toolchain rules: legacy features need to be explicitly enabled to create a working toolchain

Open
#224 1 comment 1 reaction 1 assignee Claimed by @armandomontanez View on GitHub
category: toolchains P3 type: bug
Dominant language
Starlark
Stars
247
Forks
196
PR merge metrics
No merged PRs in 30d

Description

When creating a rule-based toolchain, legacy features must be explicitly enabled in order for tool invocations to be correctly constructed. This can be done in one of two ways:

1. List `implies` on a `cc_action_type_config`:
```python
cc_action_type_config(
name = "arm-none-eabi-ar",
action_types = ["@rules_cc//cc/toolchains/actions:ar_actions"],
tools = [":arm-none-eabi-ar_tool"],
implies = [
"@rules_cc//cc/toolchains/features/legacy:archiver_flags",
"@rules_cc//cc/toolchains/features/legacy:linker_param_file",
]
)
```
2. Create a custom feature that implies legacy features across a `cc_toolchain`.
```python
cc_feature(
name = "legacy_features",
args = [],
enabled = True,
feature_name = "force_legacy_features",
implies = [
"@rules_cc//cc/toolchains/features/legacy:archiver_flags",
"@rules_cc//cc/toolchains/features/legacy:linker_param_file",
# ...
"@rules_cc//cc/toolchains/features/legacy:fission_support",
"@rules_cc//cc/toolchains/features/legacy:sysroot",
],
)

cc_toolchain(
name = "my_toolchain",
# ...
toolchain_features = [
"@pico-sdk//bazel/toolchain:legacy_features",
],
)
```

This is a bit of a stumbling block, since it's not exactly obvious which of these legacy features are required to construct a working toolchain, or how to re-implement these features correctly in a way that makes Bazel happy.

There's a few potential paths to pursue here:
1. Have an option on `cc_toolchain` that enables all legacy features.
2. Provide features (or better, raw `cc_args `/`cc_args_list`) that implement the required flags, and either provide guidance on how to comprehensively build a toolchain that includes the required arguments or make the toolchain rules infer the required args if no args are explicitly provided.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.