rules_android_ndk
rules_android_ndk copied to clipboard
Building cc_binary with rules unable to find cc_toolchain_suite
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:
-
cpuinfois acc_binaryso i'm using--cpuand--crosstool_topinstead of the--fat_apk_cpuand--android_crosstool_topbased on https://github.com/bazelbuild/rules_android_ndk/issues/19#issuecomment-1251257261
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