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

Rule-based toolchains don't work with rules_foreign_cc #297

Open
davidbalbert opened this issue Dec 31, 2024 · 1 comment
Open

Rule-based toolchains don't work with rules_foreign_cc #297

davidbalbert opened this issue Dec 31, 2024 · 1 comment
Assignees
Labels
P3 Accepted issue. Team is likely to fix this issue in the future, but no short-term promises are made.

Comments

@davidbalbert
Copy link

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 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. 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.

@pzembrod pzembrod added the P3 Accepted issue. Team is likely to fix this issue in the future, but no short-term promises are made. label Jan 24, 2025
@armandomontanez
Copy link
Collaborator

armandomontanez commented Jan 24, 2025

I'd expect the ld binary to come from cc_common.get_tool_for_action(ACTION_NAMES.cpp_link_executable). I believe tool_paths is considered the legacy way to configure a toolchain.

Sorry for the delay in response.

@armandomontanez armandomontanez self-assigned this Jan 29, 2025
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.
Projects
None yet
Development

No branches or pull requests

3 participants