Skip to content

0.19.1: @bazel_tools//tools/cpp:cc-compiler-local-k8' is not a cc_toolchain rule #6662

Closed

Description

@scottmin0r

Description of the problem / feature request:

C++ builds fail with:

ERROR: The label '@bazel_tools//tools/cpp:cc-compiler-local-k8' is not a cc_toolchain rule

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

On Linux/amd64, in an otherwise empty workspace with an empty WORKSPACE file, run:

bazel build --crosstool_top=@bazel_tools//tools/cpp:default-toolchain //...

What operating system are you running Bazel on?

Linux (Debian variant)

What's the output of bazel info release?

release 0.19.1

Have you found anything relevant by searching the web?

In the file https://github.com/bazelbuild/bazel/blob/0.19.1/tools/cpp/BUILD:

On the 0.19.0 tag, this line refers to cc-compiler-local, a cc_toolchain rule that exists.

On the 0.19.1 tag, this line refers to cc-compiler-local-k8, a cc_toolchain rule that does not exist.

This appears to be the cause of the issue, although I am not sure why this was changed.

Activity

  1. added
    P0
    team-Rules-CPP
    on Nov 12, 2018
  2. katre commented on Nov 12, 2018

    @katre
    Collaborator

    You're right about the cause, I'm not sure what those changed lines are about. Adding @mhlopko and @lberki to try and help figure it out.

  3. nlopezgi commented on Nov 12, 2018

    @nlopezgi
    Contributor

    #6665 might be related. Perhaps this is also due to 6bc4528 not being included in 0.19.1

  4. assigned and unassigned on Nov 13, 2018
  5. gelrom commented on Nov 13, 2018

    @gelrom

    Could the following output have the same underlying cause?
    ...in cc_toolchain rule @local_config_cc//:cc-compiler-k8: Error while selecting cc_toolchain: Toolchain identifier 'local' was not found, valid identifiers are...
    This break occurs at 0.19.1. I've been unable to determine if it also occurs at 0.19, but 0.18 was definitely working. Note that this still breaks even if all backward breaking flags that were flipped in 0.19 are set to false.

    edit: If this is irrelevant, I can delete this comment and file a separate issue.

  6. scentini commented on Nov 13, 2018

    @scentini
    Contributor

    @gelrom can you share the build command? Seems close enough, but not quite the same.

  7. scentini commented on Nov 13, 2018

    @scentini
    Contributor

    @gelrom also, could you please provide the list of valid identifiers in the error message?

  8. scentini commented on Nov 13, 2018

    @scentini
    Contributor

    @scottminor-google, we've confirmed that @bazel_tools//tools/cpp:default-toolchain is in error.
    Why do you need to set --crosstool_top=@bazel_tools//tools/cpp:default-toolchain ? I'm trying to determine the scope of the issue.
    Thanks.

  9. 4 remaining items

  10. scottmin0r commented on Nov 14, 2018

    @scottmin0r
    Author

    Thanks for the fix! I rebuilt bazel from 94d51fc to test/verify this fix against our codebase. Unfortunately, I'm running into another error:

    ERROR: /usr/local/google/home/minors/.cache/bazel/_bazel_minors/32b2ee46dce03a213358bafd92f1c3ce/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 [stub_armeabi-v7a, local_linux, local_darwin, local_freebsd, local_windows_mingw, local_windows_msys64_mingw64, local_windows_clang, local_windows_msys64, vc_14_0_x64]
    ERROR: Analysis of target '//:hello_world' failed; build aborted: Analysis of target '@local_config_cc//:cc-compiler-k8' failed; build aborted
    

    This is reproduced in a workspace with:

    • an empty WORKSPACE file
    • //hello_world.cpp:
      #include <iostream>
      
      int main() {
        std::cout << "Hello, world!" << std::endl;
        return 0;
      }
      
    • //BUILD:
      cc_binary(
          name = "hello_world",
          srcs = ["hello_world.cpp"],
      )
      

    Bazel builds successfully when doing:

    bazel build //...
    

    but fails with the above error when specifying default-toolchain:

    bazel build //... --crosstool_top=@bazel_tools//tools/cpp:default-toolchain
    
  11. scottmin0r commented on Nov 14, 2018

    @scottmin0r
    Author

    In our codebase, the error is a little different - it still complains about @local_config_cc//:cc-compiler-k8, but the available toolchain identifiers is one element - the toolchain_identifier specified in our custom CROSSTOOL. I have no idea why that would be interacting with @local_config_cc (or even what that is supposed to be).

    Is there anything I can read up on to better understand C/C++ toolchain resolution and what best practices are? I feel woefully uneducated when it comes to this area of Bazel.

  12. wjywbs commented on Nov 14, 2018

    @wjywbs
    Contributor

    I'm encountering an issue similar to this. I took some time to make a minimal repro in https://github.com/wjywbs/bazel-cc-toolchain-bug, and posted the outputs of bazel 0.18.1, 0.19.0 and 0.19.1 in there.

  13. scentini commented on Nov 14, 2018

    @scentini
    Contributor

    Thanks for the repro, looking into it.

  14. reopened this on Nov 14, 2018
  15. katre commented on Nov 14, 2018

    @katre
    Collaborator

    It looks like cherrypicking 683c302 will fix this (but, it changes how crosstool_top is selected). @scottminor-google, can you add that cherrypick on top of the existing release-0.19.2 branch and let me know if it works?

  16. added a commit that references this issue on Nov 14, 2018
    7c31965
  17. katre commented on Nov 14, 2018

    @katre
    Collaborator

    I've pushed the cherrypick into the RC, please let me know if there are still issues.

  18. scottmin0r commented on Nov 14, 2018

    @scottmin0r
    Author

    I built bazel from f2be11dda2 and it successfully builds a C++ target from our codebase with no additional flags. Thanks for the fix!

  19. katre commented on Nov 19, 2018

    @katre
    Collaborator

    Closing since 0.19.2 will be released shortly.

  20. added a commit that references this issue on Nov 19, 2018
  21. added 2 commits that reference this issue on Nov 26, 2018
    9dd0218
    db46207
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P0team-Rules-CPPtype: bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions