Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
armandomontanez opened this issue May 22, 2024 · 0 comments
Labels
P3 Accepted issue. Team is likely to fix this issue in the future, but no short-term promises are made. type: bug Something that should be working isn't working

Comments

@armandomontanez
Copy link
Collaborator

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:
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",
    ]
)
  1. Create a custom feature that implies legacy features across a cc_toolchain.
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.
@comius comius added type: bug Something that should be working isn't working P3 Accepted issue. Team is likely to fix this issue in the future, but no short-term promises are made. labels Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 Accepted issue. Team is likely to fix this issue in the future, but no short-term promises are made. type: bug Something that should be working isn't working
Projects
None yet
Development

No branches or pull requests

2 participants