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

rules_rust is failing to find _cc_toolchain in WORSPACE setup after updating to 0.57.1 #3242

Open
dunnock opened this issue Feb 6, 2025 · 4 comments
Labels

Comments

@dunnock
Copy link

dunnock commented Feb 6, 2025

I am using WORKSPACE based setup with Bazel 7.4

bazel build is able to pick the _cc_toolchain on version 0.56, but failing with the following compile error after updating to 0.57.1 (redacted):

...
ERROR: .../external/rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools/BUILD.bazel:96:15: in rust_toolchain rule @@rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools//:rust_toolchain: 
Traceback (most recent call last):
        File ".../external/rules_rust/rust/toolchain.bzl", line 670, column 72, in _rust_toolchain_impl
                libstd_and_allocator_ccinfo = _make_libstd_and_allocator_ccinfo(ctx, rust_std, ctx.attr.allocator_library, "std"),
        File ".../external/rules_rust/rust/toolchain.bzl", line 159, column 60, in _make_libstd_and_allocator_ccinfo
                cc_toolchain, feature_configuration = find_cc_toolchain(ctx)
        File ".../external/rules_rust/rust/private/utils.bzl", line 55, column 43, in find_cc_toolchain
                cc_toolchain = find_rules_cc_toolchain(ctx)
        File ".../external/bazel_tools/tools/cpp/toolchain_utils.bzl", line 63, column 9, in find_cpp_toolchain
                fail("In order to use find_cpp_toolchain, you must define the '_cc_toolchain' attribute on your rule or aspect.")
Error in fail: In order to use find_cpp_toolchain, you must define the '_cc_toolchain' attribute on your rule or aspect.
...
@UebelAndre
Copy link
Collaborator

This was likely caused by #3116

cc @katre

@UebelAndre UebelAndre added the bug label Feb 6, 2025
@katre
Copy link
Member

katre commented Feb 6, 2025

Hmm, checking the version of find_cpp_toolchain in Bazel 7.4.0, this appears to be following the "toolchain resolution for C++ not enabled" branch.

Are you explicitly disabling toolchain resolution for C++ (with the --incompatible_enable_cc_toolchain_resolution flag)? That's simply not compatible with recent Bazel rules (and, in Bazel 8.0, is an ignored flag).

If you have a reproduction I will take a look.

@dunnock
Copy link
Author

dunnock commented Feb 6, 2025

Are you explicitly disabling toolchain resolution for C++ (with the --incompatible_enable_cc_toolchain_resolution flag)? That's simply not compatible with recent Bazel rules (and, in Bazel 8.0, is an ignored flag).

I am relatively new to bazel, integrating my Rust code base into large C++ project. But from what I can see I have this setting in the workspace root:

common --noincompatible_enable_cc_toolchain_resolution

From the comment it seems is present as a workaround for bazelbuild/bazel#21121

If you have a reproduction I will take a look.

This might be tricky but I will try. I thought it is a known issue but it seems it is rather an edge case.

@katre
Copy link
Member

katre commented Feb 6, 2025

You should no longer be using either --noincompatible_enable_cc_toolchain_resolution or --crosstool_top: please see the documentation (especially those linked from bazelbuild/bazel#21121 (comment)) for the new flags to use.

We can no longer support those flags, so you'll need to update your project. There's really nothing I can do further, so no need to find a way for me to reproduce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants