Skip to content

Bazel 7 completely ignors --crosstool_top; 6.5 works as expected #21121

Closed

Description

@radoye

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

Activity

  1. added
    untriaged
    on Jan 28, 2024
  2. changed the title [-]Bazel 7 completely ignors --crosstool_top; while 6.5 works as expected[/-] [+]Bazel 7 completely ignors --crosstool_top; 6.5 works as expected[/+] on Jan 28, 2024
  3. added
    team-Core
    on Jan 29, 2024
  4. added
    team-Rules-CPP
    and removed
    team-Core
    on Jan 29, 2024
  5. meteorcloudy commented on Jan 29, 2024

    @meteorcloudy
    Member

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

  6. added
    P3
    and removed
    untriaged
    on Jan 29, 2024
  7. radoye commented on Jan 29, 2024

    @radoye
    Author

    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_*?

  8. Wyverald commented on Jan 29, 2024

    @Wyverald
    Member

    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

  9. radoye commented on Jan 30, 2024

    @radoye
    Author

    Thanks for the prompt response and pointers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3team-Rules-CPPtype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions