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

Building cc_binary with rules unable to find cc_toolchain_suite #43

Open
ngzhian opened this issue Aug 23, 2023 · 0 comments
Open

Building cc_binary with rules unable to find cc_toolchain_suite #43

ngzhian opened this issue Aug 23, 2023 · 0 comments

Comments

@ngzhian
Copy link

ngzhian commented Aug 23, 2023

I'm trying to upgrade a project to use rules_android_ndk (from the packaged one) and am facing some issues:

$ bazel build :cpuinfo --cpu=arm64-v8a --crosstool_top=@androidndk//:toolchain --host_crosstool_top=@bazel_tools//tools/cpp:toolchain 
ERROR: /usr/local/google/home/zhin/.cache/bazel/_bazel_zhin/6c29bbe1edd74d1c184bd5850967e7c9/external/androidndk/BUILD:9:6: no such target '@androidndk//toolchains/llvm/prebuilt/linux-x86_64:cc_toolchain_suite': target 'cc_toolchain_suite' not declared in package 'toolchains/llvm/prebuilt/linux-x86_64' defined by /usr/local/google/home/zhin/.cache/bazel/_bazel_zhin/6c29bbe1edd74d1c184bd5850967e7c9/external/androidndk/toolchains/llvm/prebuilt/linux-x86_64/BUILD.bazel (Tip: use `query "@androidndk//toolchains/llvm/prebuilt/linux-x86_64:*"` to see all the targets in that package) and referenced by '@androidndk//:toolchain'
ERROR: Analysis of target '//:cpuinfo' failed; build aborted:
INFO: Elapsed time: 0.126s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)

I've read a couple of related issues here:

  1. cpuinfo is a cc_binary so i'm using --cpu and --crosstool_top instead of the --fat_apk_cpu and --android_crosstool_top based on Cross compilation issues #19 (comment)

I also tried passing --extra_toolchains=@androidndk//..., and after resolving something related to @rules_python:

INFO: Build option --extra_toolchains has changed, discarding analysis cache.
ERROR: /usr/local/google/home/zhin/src/cpuinfo/BUILD.bazel:176:11: While resolving toolchains for target //:cpuinfo: invalid registered toolchain '@androidndk//...': error loading package under directory '': error loading package '@androidndk//sources/third_party/googletest/test': Unable to find package for @rules_python//python:defs.bzl: The repository '@rules_python' could not be resolved: Repository '@rules_python' is not defined.
ERROR: Analysis of target '//:cpuinfo' failed; build aborted:
INFO: Elapsed time: 0.231s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 6 targets configured)
    currently loading: @androidndk//sources/third_party/googletest/test ... (2 packages)

by adding to WORKSPACE:

SHA = "84aec9e21cc56fbc7f1335035a71c850d1b9b5cc6ff497306f84cced9a769841"

VERSION = "0.23.1"

http_archive(
    name = "rules_python",
    sha256 = SHA,
    strip_prefix = "rules_python-{}".format(VERSION),
    url = "https://github.com/bazelbuild/rules_python/releases/download/{}/rules_python-{}.tar.gz".format(VERSION, VERSION),
)

load("@rules_python//python:repositories.bzl", "py_repositories")

py_repositories(

I get the same error about no such target '@androidndk//toolchains/llvm/prebuilt/linux-x86_64:cc_toolchain_suite'.

To reproduce:

git clone https://github.com/ngzhian/cpuinfo.git
cd cpuinfo
git checkout workspace
export ANDROID_NDK_HOME=/path/to/ndk/r25c # i'm using r25c
bazel build :cpuinfo --cpu=arm64-v8a --crosstool_top=@androidndk//:toolchain --host_crosstool_top=@bazel_tools//tools/cpp:toolchain  --fat_apk_cpu=arm64-v8a --android_crosstool_top=@androidndk//:toolchain
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

1 participant