Repository navigation
Closed
Labels
P3We're not considering working on this, but happy to review a PR. (No assignee)team-Rules-CPPIssues for C++ rulestype: bug
Description
Description of the bug:
Working through the toolchain tutorial it looks like Bazel 7 completely ignores --crosstool_top parameter (or maybe this is an undocumented/underdocumented change in behavior). I cannot seem to (easily) find any mention of this being intentional.
Specifically, even an incantation with an undefined toolchain parameter succeeds, i.e. no error is emitted in step 2.
Which category does this issue belong to?
Core
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
The setup is, basically, just like in the toolchains tutorial.
# WORKSPACE
# BUILD
cc_binary(
name = "hello",
srcs = ["hello.cc"],
)
// hello.cc
#include <iostream>
int main(int argc, char* argv[]) {
std::cout << "Hello!\n";
return 0;
}
Here's the shell session log.
rrs@forge:~/docks/dev/foundations/dt$
💣bazel --version
bazel 6.5.0
rrs@forge:~/docks/dev/foundations/dt$
💣bazel build --config=clang_config :hello
ERROR: /home/rrs/.cache/bazel/_bazel_rrs/e1b5457c168962d1267c0381e8230372/external/bazel_tools/tools/cpp/BUILD:58:19: every rule of type cc_toolchain_alias implicitly depends upon the target '//toolchain:clang_suite', but this target could not be found because of: no such package 'toolchain': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
- /home/rrs/docks/dev/foundations/dt/toolchain
ERROR: Analysis of target '//:hello' failed; build aborted:
INFO: Elapsed time: 0.983s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (35 packages loaded, 131 targets configured)
rrs@forge:~/docks/dev/foundations/dt$
💣rm .bazelversion
rrs@forge:~/docks/dev/foundations/dt$
💣bazel --version
bazel 7.0.2
rrs@forge:~/docks/dev/foundations/dt$
💣bazel build --config=clang_config :hello
Starting local Bazel server and connecting to it...
INFO: Analyzed target //:hello (67 packages loaded, 306 targets configured).
INFO: Found 1 target...
Target //:hello up-to-date:
bazel-bin/hello
INFO: Elapsed time: 3.249s, Critical Path: 0.03s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
rrs@forge:~/docks/dev/foundations/dt$
💣
Which operating system are you running Bazel on?
Debian testing
What is the output of bazel info release?
release 7.0.2
If bazel info release returns development version or (@non-git), tell us how you built Bazel.
Bazel is managed by bazelisk.
What's the output of git remote get-url origin; git rev-parse HEAD ?
N/A
Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.
Everything works as expected in 6.5.0.
Have you found anything relevant by searching the web?
No.
Any other information, logs, or outputs that you want to share?
No response
Metadata
Metadata
Assignees
Labels
P3We're not considering working on this, but happy to review a PR. (No assignee)team-Rules-CPPIssues for C++ rulestype: bug
Activity
[-]Bazel 7 completely ignors --crosstool_top; while 6.5 works as expected[/-][+]Bazel 7 completely ignors --crosstool_top; 6.5 works as expected[/+]meteorcloudy commentedon Jan 29, 2024
--incompatible_enable_cc_toolchain_resolution was flipped in Bazel 7, if you still want to use old --crosstool_top, you'll have to turn off this flag.
But indeed, https://bazel.build/versions/7.0.0/tutorials/ccp-toolchain-config#configuring_the_c_toolchain should be updated.
/cc @comius
radoye commentedon Jan 29, 2024
I must have missed that, thanks! What is the most up-to-date recommendation? Which mechanism should be used to specify a different toolchain to apply in
cc_*?Wyverald commentedon Jan 29, 2024
cc rules now use toolchain resolution; you might want to read https://bazel.build/versions/7.0.0/extending/toolchains . I understand that's a hefty article to digest. For an example project to use the LLVM toolchain, see https://github.com/grailbio/bazel-toolchain
radoye commentedon Jan 30, 2024
Thanks for the prompt response and pointers!