Skip to content

Fix target naming to follow symbolic macro naming requirements - #487

Open
reutermj wants to merge 1 commit into
bazelbuild:mainfrom
reutermj:main
Open

Fix target naming to follow symbolic macro naming requirements#487
reutermj wants to merge 1 commit into
bazelbuild:mainfrom
reutermj:main

Conversation

@reutermj

@reutermj reutermj commented Sep 9, 2025

Copy link
Copy Markdown
Contributor

Any target produced by a symbolic macro must start with the name of the macro. cc_toolchain produces two sets of targets prefixed with _ instead of the name. This change drops the _ prefix from the targets produced by cc_toolchain to enable its use in symbolic macros.

example error:

ERROR: /home/mark/.cache/bazel/_bazel_mark/5979f8eda1b07b2dab85fbe51f06c597/external/toolchains_cc++cxx_toolchains+toolchains_cc_default_toolchain/BUILD:3:18: in cc_toolchain_config rule @@toolchains_cc++cxx_toolchains+toolchains_cc_default_toolchain//:_toolchains_cc_default_toolchain_cc_toolchain_config: Target @@toolchains_cc++cxx_toolchains+toolchains_cc_default_toolchain//:_toolchains_cc_default_toolchain_cc_toolchain_config declared in symbolic macro 'toolchains_cc_default_toolchain' violates macro naming rules and cannot be built. Name must be the same as the macro's name, or the macro's name followed by '_' (recommended), '-', or '.', and a non-empty string.

fix verified with working toolchain: https://github.com/reutermj/toolchains_cc/tree/backup-gcc

Any target produced by a symbolic macro must start with the name of the macro.
cc_toolchain produces two sets of targets prefixed with `_` instead of the name.
This change drops the `_` prefix from the targets produced by cc_toolchain to enable its use in symbolic macros.
@reutermj reutermj changed the title Fix target naming to follow symbolic macro namming requirements Fix target naming to follow symbolic macro naming requirements Sep 9, 2025
@armandomontanez

armandomontanez commented Sep 15, 2025

Copy link
Copy Markdown
Collaborator

This target is intended to be private so we don't have other folks rely on the intermediate target, so it's named with a _{name} prefix which is part of the bzl style guide. Is there a flag to turn this check off until either the check or style guide are improved?

@reutermj

reutermj commented Sep 15, 2025

Copy link
Copy Markdown
Contributor Author

There's nothing blocking me on my end. I can (and currently do) just use a legacy macro in the meantime which doesn't have the naming check. Yeah the style guide and the symbolic macro requirements aren't in agreement:

Have their names prefixed by <name> or _<name>. For example, using name = '%s_bar' % (name).

https://bazel.build/rules/bzl-style#macros

The names of any targets or submacros created by a symbolic macro must either match the macro's name parameter or must be prefixed by name followed by _ (preferred), . or -.

https://bazel.build/extending/macros#naming

@reutermj

Copy link
Copy Markdown
Contributor Author

@armandomontanez the style guide has been updated as of: bazelbuild/bazel#27005

Can we get this revisited?

@dzbarsky

Copy link
Copy Markdown
Contributor

This will be fixed as a side effect of #555

@armandomontanez armandomontanez added P3 We're not considering working on this, but happy to review a PR. (No assignee) category: toolchains type: internal cleanup Does not directly address a feature request or a bug report, but improves project hygiene labels Mar 27, 2026
@hvadehra
hvadehra removed their request for review April 21, 2026 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: toolchains P3 We're not considering working on this, but happy to review a PR. (No assignee) type: internal cleanup Does not directly address a feature request or a bug report, but improves project hygiene

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants