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

Bazel failing to build with custom toolchain #236

Closed
ghost opened this issue Nov 12, 2018 · 2 comments
Closed

Bazel failing to build with custom toolchain #236

ghost opened this issue Nov 12, 2018 · 2 comments

Comments

@ghost
Copy link

ghost commented Nov 12, 2018

I'm running a repository built with bazel using clang from a CROSSTOOL based on this repository. Setting up a brand new machine for a new employee today, the build fails with the following error:

$ bazel build //basically:anything
ERROR: /home/user/.cache/bazel/_bazel_user/b66616ba40524aac761ec07c06bbfdfc/external/local_config_cc/BUILD:57:1: in cc_toolchain rule @local_config_cc//:cc-compiler-k8: Error while selecting cc_toolchain: Toolchain identifier 'local' was not found, valid identifiers are [clang-linux, clang-darwin]
ERROR: Analysis of target '//core/external/ros2:ros2' failed; build aborted: Analysis of target '@local_config_cc//:cc-compiler-k8' failed; build aborted
INFO: Elapsed time: 0.111s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)

I think this is related to bazel release 0.19.1 (my machine and others which work are on 0.19.0 right now). I also suspect it is related to this issue.

The repository .bazelrc contains

build --crosstool_top=@clang6llvm//:toolchain
run --crosstool_top=@clang6llvm//:toolchain
test --crosstool_top=@clang6llvm//:toolchain

to select our toolchain.

Any advice on how to fix this problem would be greatly appreciated. To be honest, I find the bazel toolchain/crosstool configuration pretty impenetrable and I have no idea why rules in local_config_cc/BUILD are even being built, so I'm at a loss as to how to debug or work around the problem.

@nlopezgi
Copy link
Contributor

Hi @johnmarkwayve ,
The issue you are experiencing is related to a change with Bazel 0.19.0 related to c++ toolchain selection (https://docs.bazel.build/versions/master/skylark/backward-compatibility.html#disallow-using-crosstool-to-select-the-cc_toolchain-label). The owners of the toolchain configs you are using need to update their crosstools accordingly.

For record, this is not the right repo to open issues related to custom written crosstool/toolchains. For these types of questions/issues you should contact bazel-discuss@googlegroups.com or open an issue in the bazel github repo.

@siddharthab
Copy link

For posterity, this bug was fixed by bazelbuild/bazel@683c302.

The problem was that the cc_toolchain defined in local_config_cc was picking up the CROSSTOOL file from --crosstool_top. This custom CROSSTOOL file did not have a toolchain with toolchain_identifier = local.

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

No branches or pull requests

2 participants