bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
23.14k stars 4.05k forks source link

Can't find rules_cc bzl file, only fixable by expunge #12631

Closed GMNGeoffrey closed 3 years ago

GMNGeoffrey commented 3 years ago

Description of the problem / feature request:

Twice in the last two days when returning to rebuild a Bazel project, I've seen an error about it being unable to find the .bzl file for rules_cc rules. I think this has to do with the implicit loading of rules_cc by Bazel, as you'll notice that nowhere is that file mentioned in the repository (https://sourcegraph.com/search?q=repo:%5Egithub%5C.com/google/llvm-bazel%24+%22cc:defs.bzl%22&patternType=regexp). I tried various smaller hammers to fix this issue, but only bazel clean --expunge worked.

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

As this is an issue with failing incremental builds, I have no way to reproduce. It has happened to me twice now and I'm happy to collect relevant information if it happens again before expunging, but filing a bug per the instructions at https://docs.bazel.build/versions/master/user-manual.html#the-clean-command.

What operating system are you running Bazel on?

Linux Debian

What's the output of bazel info release?

release 3.3.1

What's the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?

git@github.com:GMNGeoffrey/llvm-bazel.git
6ca5627cf5a620d10796876a6442668e1f0e1dfc
6ca5627cf5a620d10796876a6442668e1f0e1dfc

Have you found anything relevant by searching the web?

No

Any other information, logs, or outputs that you want to share?

Command line logs ``` gcmn@ws 2020-12-04 09:45 ~/src/llvm-bazel/llvm-bazel$ bazel query //... + @llvm-project//... | xargs bazel test --config=rbe --test_output=errors --test_tag_filters=-nobuildkite --build_tag_filters=-nobuildkite Starting local Bazel server and connecting to it... Loading: 0 packages loaded Loading: 0 packages loaded Loading: 10 packages loaded Loading: 10 packages loaded Loading: 10 packages loaded INFO: Invocation ID: 6ecb5912-b85a-427e-9095-1a161129cfc9 ERROR: While resolving toolchains for target @llvm-project//mlir:mlir_runner_utils: com.google.devtools.build.lib.packages.BuildFileContainsErrorsException: e rror loading package '@bazel_tools//tools/cpp': Every .bzl file must have a corresponding package, but '@rules_cc//cc:defs.bzl' does not have one. Please crea te a BUILD file in the same or any parent directory. Note that this BUILD file does not need to do anything except exist. ERROR: Analysis of target '@llvm-project//mlir:mlir_runner_utils' failed; build aborted: com.google.devtools.build.lib.packages.BuildFileContainsErrorsExcepti on: error loading package '@bazel_tools//tools/cpp': Every .bzl file must have a corresponding package, but '@rules_cc//cc:defs.bzl' does not have one. Please create a BUILD file in the same or any parent directory. Note that this BUILD file does not need to do anything except exist. INFO: Elapsed time: 3.198s INFO: 0 processes. FAILED: Build did NOT complete successfully (9 packages loaded, 0 targets configured) FAILED: Build did NOT complete successfully (9 packages loaded, 0 targets configured) Fetching @rbe_default; Restarting. gcmn@ws 2020-12-04 09:45 ~/src/llvm-bazel/llvm-bazel$ bazel sync --configure Loading: loading... gcmn@ws 2020-12-04 09:45 ~/src/llvm-bazel/llvm-bazel$ bazel query //... + @llvm-project//... | xargs bazel test --config=rbe --test_output=errors --test_tag_f ilters=-nobuildkite --build_tag_filters=-nobuildkite Loading: 0 packages loaded Loading: 10 packages loaded Loading: 10 packages loaded INFO: Invocation ID: 3cd6e1a4-03a2-43ea-b150-ef3ffeacf722 ERROR: While resolving toolchains for target @llvm-project//mlir:mlir_async_runtime: com.google.devtools.build.lib.packages.BuildFileContainsErrorsException: error loading package '@bazel_tools//tools/cpp': Every .bzl file must have a corresponding package, but '@rules_cc//cc:defs.bzl' does not have one. Please cre ate a BUILD file in the same or any parent directory. Note that this BUILD file does not need to do anything except exist. ERROR: Analysis of target '@llvm-project//mlir:mlir_async_runtime' failed; build aborted: com.google.devtools.build.lib.packages.BuildFileContainsErrorsExcept ion: error loading package '@bazel_tools//tools/cpp': Every .bzl file must have a corresponding package, but '@rules_cc//cc:defs.bzl' does not have one. Pleas e create a BUILD file in the same or any parent directory. Note that this BUILD file does not need to do anything except exist. INFO: Elapsed time: 1.813s INFO: 0 processes. FAILED: Build did NOT complete successfully (8 packages loaded, 1 target configured) FAILED: Build did NOT complete successfully (8 packages loaded, 1 target configured) gcmn@ws 2020-12-04 09:45 ~/src/llvm-bazel/llvm-bazel$ bazel clean INFO: Invocation ID: 5bbd1da3-f1e8-42e3-9090-5cb75837b7c8 INFO: Starting clean (this may take a while). Consider using --async if the clean takes more than several minutes. gcmn@ws 2020-12-04 09:46 ~/src/llvm-bazel/llvm-bazel$ bazel query //... + @llvm-project//... | xargs bazel test --config=rbe --test_output=errors --test_tag_filters=-nobuildkite --build_tag_filters=-nobuildkite Loading: 0 packages loaded Loading: 10 packages loaded Loading: 10 packages loaded Loading: 10 packages loaded INFO: Invocation ID: 9c4f93c3-d92c-45b7-875e-290b363a6d70 DEBUG: /usr/local/google/home/gcmn/.cache/bazel/_bazel_gcmn/1655d0ec87ba8569e84422cbb0aeec46/external/bazel_toolchains/rules/rbe_repo.bzl:491:10: Bazel 3.3.1 is used in rbe_default. ERROR: While resolving toolchains for target @llvm-project//mlir:mlir-opt: com.google.devtools.build.lib.packages.BuildFileContainsErrorsException: error loading package '@bazel_tools//tools/cpp': Every .bzl file must have a corresponding package, but '@rules_cc//cc:defs.bzl' does not have one. Please create a BUILD file in the same or any parent directory. Note that this BUILD file does not need to do anything except exist. ERROR: Analysis of target '@llvm-project//mlir:mlir-opt' failed; build aborted: com.google.devtools.build.lib.packages.BuildFileContainsErrorsException: error loading package '@bazel_tools//tools/cpp': Every .bzl file must have a corresponding package, but '@rules_cc//cc:defs.bzl' does not have one. Please create a BUILD file in the same or any parent directory. Note that this BUILD file does not need to do anything except exist. INFO: Elapsed time: 1.893s INFO: 0 processes. FAILED: Build did NOT complete successfully (11 packages loaded, 50 targets configured) FAILED: Build did NOT complete successfully (11 packages loaded, 50 targets configured) currently loading: @bazel_tools//tools/python gcmn@ws 2020-12-04 09:46 ~/src/llvm-bazel/llvm-bazel$ bazel clean --expunge INFO: Invocation ID: 128e6c6d-d8df-456c-9ecd-04522493d167 INFO: Starting clean (this may take a while). Consider using --async if the clean takes more than several minutes. gcmn@ws 2020-12-04 09:46 ~/src/llvm-bazel/llvm-bazel$ bazel query //... + @llvm-project//... | xargs bazel test --config=rbe --test_output=errors --test_tag_filters=-nobuildkite --build_tag_filters=-nobuildkite Starting local Bazel server and connecting to it... Loading: 0 packages loaded Loading: 0 packages loaded Loading: 7 packages loaded currently loading: @llvm-project//llvm ... (3 packages) Loading: 10 packages loaded Loading: 10 packages loaded INFO: Invocation ID: 91c2b599-14fc-4580-87d2-7591a4366b6a DEBUG: /usr/local/google/home/gcmn/.cache/bazel/_bazel_gcmn/1655d0ec87ba8569e84422cbb0aeec46/external/bazel_toolchains/rules/rbe_repo.bzl:491:10: Bazel 3.3.1 is used in rbe_default. WARNING: /usr/local/google/home/gcmn/.cache/bazel/_bazel_gcmn/1655d0ec87ba8569e84422cbb0aeec46/external/remote_java_tools_linux/BUILD:671:11: in hdrs attribut e of cc_library rule @remote_java_tools_linux//:combiners: Artifact 'external/remote_java_tools_linux/java_tools/src/tools/singlejar/zip_headers.h' is duplica ted (through '@remote_java_tools_linux//:transient_bytes' and '@remote_java_tools_linux//:zip_headers'). Since this rule was created by the macro 'cc_library' , the error might have been caused by the macro implementation INFO: Analyzed 1122 targets (40 packages loaded, 9963 targets configured). INFO: Found 1060 targets and 62 test targets... INFO: Deleting stale sandbox base /dev/shm/bazel-sandbox.1e0a6a1c4a637621705c5b01258506dea855313953e40dc24fd817800e5f67b8 INFO: From Executing genrule @llvm-project//mlir:LinalgNamedStructuredOpsIncGen__gen_impl_genrule: bazel-out/host/bin/external/llvm-project/mlir/mlir-linalg-ods-gen -gen-impl external/llvm-project/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps Spec.tc -o bazel-out/k8-fastbuild/bin/external/llvm-project/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.cpp.inc INFO: From Executing genrule @llvm-project//mlir:LinalgNamedStructuredOpsIncGen__gen_ods_decl_genrule: bazel-out/host/bin/external/llvm-project/mlir/mlir-linalg-ods-gen -gen-ods-decl external/llvm-project/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructure dOpsSpec.tc -o bazel-out/k8-fastbuild/bin/external/llvm-project/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.td INFO: Elapsed time: 258.725s, Critical Path: 207.72s INFO: 5726 processes: 4180 remote cache hit, 1 local, 1545 remote. INFO: Build completed successfully, 8324 total actions ```
GMNGeoffrey commented 3 years ago

This is a dupe of #12630. I think I double-posted because it seemed like GitHub had lost the issue the first time or something