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

Issue with google cloud cpp #185

Closed
lromor opened this issue Feb 3, 2023 · 2 comments
Closed

Issue with google cloud cpp #185

lromor opened this issue Feb 3, 2023 · 2 comments

Comments

@lromor
Copy link

lromor commented Feb 3, 2023

Hi, I noticed that when including https://github.com/googleapis/google-cloud-cpp

with the following simple WORKSPACE:

workspace(name = "com_github_foo")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "platforms",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz",
        "https://github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz",
    ],
    sha256 = "5308fc1d8865406a49427ba24a9ab53087f17f5266a7aabbfc28823f3916e1ca",
)

BAZEL_TOOLCHAIN_TAG = "0.8.2"
BAZEL_TOOLCHAIN_SHA = "0fc3a2b0c9c929920f4bed8f2b446a8274cad41f5ee823fd3faa0d7641f20db0"

http_archive(
    name = "com_grail_bazel_toolchain",
    sha256 = BAZEL_TOOLCHAIN_SHA,
    strip_prefix = "bazel-toolchain-{tag}".format(tag = BAZEL_TOOLCHAIN_TAG),
    canonical_id = BAZEL_TOOLCHAIN_TAG,
    url = "https://github.com/grailbio/bazel-toolchain/archive/refs/tags/{tag}.tar.gz".format(tag = BAZEL_TOOLCHAIN_TAG),
)

load("@com_grail_bazel_toolchain//toolchain:deps.bzl", "bazel_toolchain_dependencies")

bazel_toolchain_dependencies()

load("@com_grail_bazel_toolchain//toolchain:rules.bzl", "llvm_toolchain")

llvm_toolchain(
    name = "llvm_toolchain",
    llvm_version = "15.0.6",
)

load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains")

llvm_register_toolchains()

http_archive(
    name = "com_github_googleapis_google_cloud_cpp",
    url = "https://github.com/googleapis/google-cloud-cpp/archive/refs/tags/v2.6.0.tar.gz",
    strip_prefix = "google-cloud-cpp-2.6.0",
    sha256 = "56b2dcbb30c14335f2c0d9a77ac46a9ef780acf78eaa17a03db474c54a4acb2c",
)

load("@com_github_googleapis_google_cloud_cpp//bazel:google_cloud_cpp_deps.bzl", "google_cloud_cpp_deps")

google_cloud_cpp_deps()

plus a simple target:

cc_binary(
    name = "foo",
    srcs = ["foo.cc"],
    deps = [
        "@com_github_googleapis_google_cloud_cpp//:common"
    ]
)

I get:

ERROR: /home/lromor/.cache/bazel/_bazel_lromor/b20d3c85bdc11961f7016eec49f26f9b/external/com_github_googleapis_google_cloud_cpp/google/cloud/BUILD.bazel:21:19: in capture_build_info rule @com_github_googleapis_google_cloud_cpp//google/cloud:generate_build_info: 
Traceback (most recent call last):
	File "/home/lromor/.cache/bazel/_bazel_lromor/b20d3c85bdc11961f7016eec49f26f9b/external/com_github_googleapis_google_cloud_cpp/google/cloud/capture_build_info.bzl", line 39, column 35, in _capture_build_info_impl
		toolchain = find_cpp_toolchain(ctx)
	File "/home/lromor/.cache/bazel/_bazel_lromor/b20d3c85bdc11961f7016eec49f26f9b/external/rules_cc/cc/toolchain_utils.bzl", line 31, column 29, in find_cpp_toolchain
		return find_cc_toolchain(ctx)
	File "/home/lromor/.cache/bazel/_bazel_lromor/b20d3c85bdc11961f7016eec49f26f9b/external/rules_cc/cc/find_cc_toolchain.bzl", line 68, column 13, in find_cc_toolchain
		fail("In order to use find_cc_toolchain, your rule has to depend on C++ toolchain. See find_cc_toolchain.bzl docs for details.")
Error in fail: In order to use find_cc_toolchain, your rule has to depend on C++ toolchain. See find_cc_toolchain.bzl docs for details.

Any clues? Shall I open an issue on their repo?

@lromor
Copy link
Author

lromor commented Feb 3, 2023

Alright, not sure what's the issue, but I found that manually importing rules_cc fixes the problem:

http_archive(
    name = "rules_cc",
    urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.4/rules_cc-0.0.4.tar.gz"],
    sha256 = "af6cc82d87db94585bceeda2561cb8a9d55ad435318ccb4ddfee18a43580fb5d",
    strip_prefix = "rules_cc-0.0.4",
)

The relevant file seems to be:

https://github.com/googleapis/google-cloud-cpp/blob/main/google/cloud/capture_build_info.bzl

It looks like that in Bazel 6.0.0 the rules_cc uses:
https://github.com/bazelbuild/rules_cc/blob/d5d830baafdf0c6f95d7af1577dbaa610fa76a92/cc/find_cc_toolchain.bzl#L66

but the newest ones uses a different target:
https://github.com/bazelbuild/rules_cc/blob/aa7ff810cf5ec99ca34f784743b33631b74c2d16/cc/find_cc_toolchain.bzl#L66

@siddharthab
Copy link
Contributor

Thanks for reporting here. Closing because it looks like the solution has been found.

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