bazelbuild / bazelbuild/rules_cc
@bazel_tools//tools/cpp:toolchain_utils.bzl does not contain the symbol use_cpp_toolchain required by cc_flag_supplier.bzl on a fresh build
- Dominant language
- Starlark
- Stars
- 247
- Forks
- 196
- PR merge metrics
- No merged PRs in 30d
Description
### Description of the problem / feature request:
My repository using `rules_cc` no longer builds correctly because it cannot find the symbols `use_cpp_toolchain` in `@bazel_tools//tools/cpp:toolchain_utils.bzl`. When removing the cache (`rm -rf ~/.cache/bazel`) and rebuilding, the definition of `use_cpp_toolchain` is indeed not in the file located at `~/.cache/bazel/install/[hash]/embedded_tools/tools/cpp`. But when looking in the bazel repo at `tools/cpp/toolchain_utils.bzl`. There is a definition of `use_cpp_toolchain`.
### Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
If you remove `~/.cache/bazel` folder, clone [mediapipe](https://github.com/google/mediapipe), and build any of the desktop examples, it should cause the problem (tested on 2 computers).
### What operating system are you running Bazel on?
Ubuntu 20.04 LTS
### What's the output of `bazel info release`?
5.0.0
### What version of rules_cc do you use? Can you paste the workspace rule used to fetch rules_cc? What other relevant dependencies does your project have?
```py
# In WORKSPACE
http_archive(
name = "rules_cc",
strip_prefix = "rules_cc-main",
urls = ["https://github.com/bazelbuild/rules_cc/archive/main.zip"],
)
http_archive(
name = "rules_foreign_cc",
strip_prefix = "rules_foreign_cc-0.1.0",
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.1.0.zip",
)
load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies")
rules_foreign_cc_dependencies()
```
### What Bazel options do you use to trigger the issue? What C++ toolchain do you use?
`bazel clean --expunge` then
`bazel build --verbose_failure -c opt --copt -DMESA_EGL_NO_X11_HEADERS --copt -DEGL_NO_X11 \
mediapipe/examples/desktop/face_detection:face_detection_gpu`
### Have you found anything relevant by searching the web?
> Replace these lines with your answer.
>
> Places to look:
> * StackOverflow: http://stackoverflow.com/questions/tagged/bazel
> * GitHub issues:
> * https://github.com/bazelbuild/rules_cc/issues
> * https://github.com/bazelbuild/bazel/issues
> * email threads:
> * https://groups.google.com/forum/#!forum/bazel-discuss
> * https://groups.google.com/forum/#!forum/cc-bazel-discuss
I have found nothing relevant on these websites
### Any other information, logs, or outputs that you want to share?
I have tried:
```
DEBUG: Rule 'rules_foreign_cc' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "c2cdcf55ffaf49366725639e45dedd449b8c3fe22b54e31625eb80ce3a240f1e"
DEBUG: Repository rules_foreign_cc instantiated at:
/home/nicoloprudo/codews/mediapipe-build-test/mediapipe/WORKSPACE:42:13: in
Repository rule http_archive defined at:
/home/nicoloprudo/.cache/bazel/_bazel_nicoloprudo/0fce4159c1f0512cb74241a5b13bc2e4/external/bazel_tools/tools/build_defs/repo/http.bzl:364:31: in
WARNING: Download from https://storage.googleapis.com/mirror.tensorflow.org/github.com/tensorflow/runtime/archive/2f6de37d68a4c69e2ff9eec3cebbf1369e496940.tar.gz failed: class java.io.FileNotFoundException GET returned 404 Not Found
DEBUG: /home/nicoloprudo/.cache/bazel/_bazel_nicoloprudo/0fce4159c1f0512cb74241a5b13bc2e4/external/org_tensorflow/third_party/repo.bzl:124:14:
Warning: skipping import of repository 'com_google_absl' because it already exists.
DEBUG: /home/nicoloprudo/.cache/bazel/_bazel_nicoloprudo/0fce4159c1f0512cb74241a5b13bc2e4/external/org_tensorflow/third_party/repo.bzl:124:14:
Warning: skipping import of repository 'com_google_benchmark' because it already exists.
DEBUG: /home/nicoloprudo/.cache/bazel/_bazel_nicoloprudo/0fce4159c1f0512cb74241a5b13bc2e4/external/org_tensorflow/third_party/repo.bzl:124:14:
Warning: skipping import of repository 'pybind11_bazel' because it already exists.
DEBUG: /home/nicoloprudo/.cache/bazel/_bazel_nicoloprudo/0fce4159c1f0512cb74241a5b13bc2e4/external/org_tensorflow/third_party/repo.bzl:124:14:
Warning: skipping import of repository 'com_google_protobuf' because it already exists.
DEBUG: /home/nicoloprudo/.cache/bazel/_bazel_nicoloprudo/0fce4159c1f0512cb74241a5b13bc2e4/external/org_tensorflow/third_party/repo.bzl:124:14:
Warning: skipping import of repository 'com_google_googletest' because it already exists.
DEBUG: /home/nicoloprudo/.cache/bazel/_bazel_nicoloprudo/0fce4159c1f0512cb74241a5b13bc2e4/external/org_tensorflow/third_party/repo.bzl:124:14:
Warning: skipping import of repository 'com_github_gflags_gflags' because it already exists.
DEBUG: /home/nicoloprudo/.cache/bazel/_bazel_nicoloprudo/0fce4159c1f0512cb74241a5b13bc2e4/external/org_tensorflow/third_party/repo.bzl:124:14:
Warning: skipping import of repository 'build_bazel_rules_apple' because it already exists.
DEBUG: /home/nicoloprudo/.cache/bazel/_bazel_nicoloprudo/0fce4159c1f0512cb74241a5b13bc2e4/external/org_tensorflow/third_party/repo.bzl:124:14:
Warning: skipping import of repository 'build_bazel_rules_swift' because it already exists.
DEBUG: /home/nicoloprudo/.cache/bazel/_bazel_nicoloprudo/0fce4159c1f0512cb74241a5b13bc2e4/external/org_tensorflow/third_party/repo.bzl:124:14:
Warning: skipping import of repository 'build_bazel_apple_support' because it already exists.
DEBUG: /home/nicoloprudo/.cache/bazel/_bazel_nicoloprudo/0fce4159c1f0512cb74241a5b13bc2e4/external/org_tensorflow/third_party/repo.bzl:124:14:
Warning: skipping import of repository 'xctestrunner' because it already exists.
DEBUG: /home/nicoloprudo/.cache/bazel/_bazel_nicoloprudo/0fce4159c1f0512cb74241a5b13bc2e4/external/org_tensorflow/third_party/repo.bzl:124:14:
Warning: skipping import of repository 'pybind11' because it already exists.
DEBUG: Rule 'rules_cc' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "73106859751c2bc314861adc136d5cbecee3f7ae7d05539dc8235efbf4efdcbe"
DEBUG: Repository rules_cc instantiated at:
/home/nicoloprudo/codews/mediapipe-build-test/mediapipe/WORKSPACE:36:13: in
Repository rule http_archive defined at:
/home/nicoloprudo/.cache/bazel/_bazel_nicoloprudo/0fce4159c1f0512cb74241a5b13bc2e4/external/bazel_tools/tools/build_defs/repo/http.bzl:364:31: in
ERROR: Traceback (most recent call last):
File "/home/nicoloprudo/.cache/bazel/_bazel_nicoloprudo/0fce4159c1f0512cb74241a5b13bc2e4/external/rules_cc/cc/private/rules_impl/cc_flags_supplier.bzl", line 16, column 76, in
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain", "use_cpp_toolchain")
Error: file '@bazel_tools//tools/cpp:toolchain_utils.bzl' does not contain symbol 'use_cpp_toolchain' (did you mean 'find_cpp_toolchain'?)
ERROR: /home/nicoloprudo/codews/mediapipe-build-test/mediapipe/mediapipe/examples/desktop/face_detection/BUILD:36:10: error loading package 'mediapipe/graphs/face_detection': at /home/nicoloprudo/codews/mediapipe-build-test/mediapipe/mediapipe/framework/tool/mediapipe_graph.bzl:23:6: at /home/nicoloprudo/.cache/bazel/_bazel_nicoloprudo/0fce4159c1f0512cb74241a5b13bc2e4/external/org_tensorflow/tensorflow/lite/core/shims/cc_library_with_tflite.bzl:4:5: at /home/nicoloprudo/.cache/bazel/_bazel_nicoloprudo/0fce4159c1f0512cb74241a5b13bc2e4/external/org_tensorflow/tensorflow/lite/build_def.bzl:4:5: at /home/nicoloprudo/.cache/bazel/_bazel_nicoloprudo/0fce4159c1f0512cb74241a5b13bc2e4/external/org_tensorflow/tensorflow/tensorflow.bzl:13:5: at /home/nicoloprudo/.cache/bazel/_bazel_nicoloprudo/0fce4159c1f0512cb74241a5b13bc2e4/external/org_tensorflow/tensorflow/core/platform/rules_cc.bzl:4:5: at /home/nicoloprudo/.cache/bazel/_bazel_nicoloprudo/0fce4159c1f0512cb74241a5b13bc2e4/external/org_tensorflow/tensorflow/core/platform/default/rules_cc.bzl:11:5: at /home/nicoloprudo/.cache/bazel/_bazel_nicoloprudo/0fce4159c1f0512cb74241a5b13bc2e4/external/rules_cc/cc/defs.bzl:17:6: initialization of module 'cc/private/rules_impl/cc_flags_supplier.bzl' failed and referenced by '//mediapipe/examples/desktop/face_detection:face_detection_gpu'
ERROR: Analysis of target '//mediapipe/examples/desktop/face_detection:face_detection_gpu' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.224s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)
currently loading: mediapipe/graphs/face_detection
Fetching @local_config_cc; fetching
```
> Replace these lines with your answer.
>
> If the files are large, upload as attachment or provide link.
Contributor guide
Research direction
Reproduce the failure with the stated Bazel 5.0.0 command after clearing ~/.cache/bazel. Compare external/rules_cc/cc/private/rules_impl/cc_flags_supplier.bzl with @bazel_tools//tools/cpp:toolchain_utils.bzl, which the error identifies as missing use_cpp_toolchain. Done means the fresh MediaPipe face_detection_gpu build completes without the missing-symbol error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100