Skip to content

Misleading toolchain API documentation for requires_true, requires_false #617

Open

Description

@epertoso

While configuring a toolchain, we were trying to override the legacy fully_static_link feature to always be enabled, except when the variable is_cc_test is true or if the target needs runtime libraries.

The documentation for requires_true (requires_false) says that the given variable will be checked for truthiness (falsiness). so we were trying to use them in the following setup:

cc_nested_args(
    name = "if_not_cc_test",
    args = ["-static"],
    requires_false = "@rules_cc//cc/toolchains/variables:is_cc_test",
)

cc_args(
    name = "fully_static_args",
    actions = [
        "@rules_cc//cc/toolchains/actions:link_actions",
    ],
    nested = [":if_not_cc_test"],
    requires_false = "@rules_cc//cc/toolchains/variables:runtime_library_search_directories",
)

cc_feature(
    name = "fully_static_link",
    args = [":fully_static_args"],
    overrides = "@rules_cc//cc/toolchains/features/legacy:fully_static_link",
    visibility = ["//visibility:public"],
)

We were expecting requires_false = "@rules_cc//cc/toolchains/variables:runtime_library_search_directories" to work, as Bazel's expand_if_true/expand_if_false evaluate an empty sequence to false, however we get an error as the current implementation restricts the allowed types to bool.

Patching nested_args.bzl to accept list as well makes our setup work.

We think either the documentation should be updated to reflect that only variables of type bool are accepted, or the implementation should match what expand_if_true/expand_if_false do.

Activity

  1. changed the title [-]Misleading toolchain API documentaiton for requires_true, requires_false[/-] [+]Misleading toolchain API documentation for requires_true, requires_false[/+] on Mar 3, 2026
  2. added
    type: bug
    P3
    on Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3category: toolchainstype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions