`@bazel_tool//tools/cpp:link_extra_libs` should not propagate to exec config
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 75
Description
### Description of the feature request:
The C++ compilation rules have a neat feature: they [allow you](https://bazel.build/reference/be/c-cpp#cc_binary.link_extra_lib) to specify a library that should be a linktime dependency of all `cc_binary` targets. That library is configured through a label flag, `@bazel_tool//tools/cpp:link_extra_libs`.
Unfortunately, this label flag persists across the transition from the target to the exec configuration. This is very inconvenient: if the `link_extra_libs` you want for the target platform include generated code, you run into circular dependencies when trying to build any binaries used in their generation. This tends to happen with [some Pigweed libraries](https://pigweed.dev/build_system.html#docs-build-system-bazel-link-extra-lib), preventing us from using `link_extra_libs` in most cases.
@gregestren I recall that internally we've done some work to restrict flag propagation to the exec config (b/292617118). What's the status on the open source side?
### Which category does this issue belong to?
Configurability
### What underlying problem are you trying to solve with this feature?
_No response_
### Which operating system are you running Bazel on?
_No response_
### What is the output of `bazel info release`?
release 7.1.2
### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.
_No response_
### What's the output of `git remote get-url origin; git rev-parse HEAD` ?
_No response_
### Have you found anything relevant by searching the web?
_No response_
### Any other information, logs, or outputs that you want to share?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.