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_tools//tools/cpp:toolchain_utils.bzl does not contain the symbol use_cpp_toolchain required by cc_flag_supplier.bzl on a fresh build #133

Open
nickph7 opened this issue Jun 22, 2022 · 4 comments
Labels
P3 Accepted issue. Team is likely to fix this issue in the future, but no short-term promises are made.

Comments

@nickph7
Copy link

nickph7 commented Jun 22, 2022

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

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

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

@nickph7 nickph7 changed the title toolchain_utils.bzl does not contain the required symbol use_cpp_toolchain required by cc_flag_supplier.bzl on a fresh build toolchain_utils.bzl does not contain the symbol use_cpp_toolchain required by cc_flag_supplier.bzl on a fresh build Jun 22, 2022
@nickph7 nickph7 changed the title toolchain_utils.bzl does not contain the symbol use_cpp_toolchain required by cc_flag_supplier.bzl on a fresh build @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 Jun 22, 2022
@toreal
Copy link

toreal commented Jun 23, 2022

Yes. I have the same problem.
I tried using another forked repository instead.


# http_archive(
#     name = "rules_cc",
#     strip_prefix = "rules_cc-main",
#     urls = ["https://github.com/bazelbuild/rules_cc/archive/main.zip"],
# )



http_archive(
    name = "rules_cc",
    strip_prefix = "rules_cc-main",
    urls = ["https://github.com/lizan/rules_cc/archive/main.zip"],
)

@nickph7
Copy link
Author

nickph7 commented Jun 23, 2022

Similarly, I've been using a previous archive of rules_cc and now my builds work

http_archive(
    name = "rules_cc",
    strip_prefix = "rules_cc-8bb0eb5c5ccd96b91753bb112096bb6993d16d13",
    sha256 = "8cd53b3563a3f66daa1f06f97b78a35600986a547bb27bebcafb8b1f8f54efb0",
    urls = ["https://github.com/bazelbuild/rules_cc/archive/8bb0eb5c5ccd96b91753bb112096bb6993d16d13.zip"],
)

Additionally, I found that the bug is reproducible by just including rules_cc in your WORKSPACE folder and trying to build a simple target

@holylong
Copy link

This problem has not been fixed

@nickgooding
Copy link

I think 2f8c04c will have broken compatibility with Bazel < 5.1 (as use_cpp_toolchain was added in v5.1.0 - bazelbuild/bazel#14795).

@comius comius added the P3 Accepted issue. Team is likely to fix this issue in the future, but no short-term promises are made. label Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 Accepted issue. Team is likely to fix this issue in the future, but no short-term promises are made.
Projects
None yet
Development

No branches or pull requests

5 participants