bazelbuild / bazelbuild/rules_cc
Rule-based toolchains don't work with rules_foreign_cc
- Dominant language
- Starlark
- Stars
- 247
- Forks
- 196
- PR merge metrics
- No merged PRs in 30d
Description
This is probably a bug with rules_foreign_cc, but I'm not sure how you'd go about fixing it, so I'm posting it here.
Rules_foreign_cc's [`configure_make`](https://bazel-contrib.github.io/rules_foreign_cc/0.13.0/configure_make.html) rule sets the `LD` environment variable before calling `./configure`. The value of `LD` is set from `cc_toolchain.ld_executable`, which [is set from `tool_paths`](https://github.com/bazelbuild/bazel/blob/f2318d2/src/main/starlark/builtins_bzl/common/cc/cc_toolchain_provider_helper.bzl#L280). Because the new rule-based toolchain API uses action configs instead of tool paths, I can't use it to create a toolchain that works with rules_foreign_cc.
This was introduced to rules_foreign_cc in bazel-contrib/rules_foreign_cc#1068. The justification for the behavior was:
> Some configure + make systems look for the ld binary that is supposed to be used, and invoke it directly for various reasons.
>
> [...]
>
> This grabs the `ld` executable directly from `cc_toolchain.ld_executable` rather than using something like `cxx_linker_executable`, because the former returns `CC` generally, but `LD` should be the linker directly.
Is there a good way to fix this in rules_foreign_cc now, or does rules_cc need to be changed (a new action type perhaps?) to make this work?
This issue is being tracked in bazel-contrib/rules_foreign_cc#1160. I can provide a simple example if necessary.
I'm running Debian 12.8 on aarch64, Bazel 7.4.1, rules_cc 0.1.0 and rules_foreign_cc 0.13.0.
Contributor guide
Assessment
This issue has not been assessed yet.