bazel: ERROR: does not contain a toolchain for cpu 'arm'
I am having bazel 0.17.2 installed on aarch64 cpu with linux, but wanted to upgrade to bazel 0.22.0.
Followed the instruction on official documentation here.
First I tried building bazel with existing bazel, but not working:
$ bazel build //src:bazel
ERROR: /home/pi/bazel-0.22/tools/jdk/BUILD:195:1: //tools/jdk:toolchain_hostjdk8: no such attribute 'header_compiler_direct' in 'java_toolchain' rule
ERROR: /home/pi/bazel-0.22/tools/jdk/BUILD:204:1: //tools/jdk:toolchain: no such attribute 'header_compiler_direct' in 'java_toolchain' rule
ERROR: /home/pi/bazel-0.22/tools/jdk/BUILD:224:1: //tools/jdk:toolchain_vanilla: no such attribute 'header_compiler_direct' in 'java_toolchain' rule
ERROR: /home/pi/bazel-0.22/tools/jdk/BUILD:234:5: //tools/jdk:toolchain_java8: no such attribute 'header_compiler_direct' in 'java_toolchain' rule
ERROR: /home/pi/bazel-0.22/tools/jdk/BUILD:234:5: //tools/jdk:toolchain_java9: no such attribute 'header_compiler_direct' in 'java_toolchain' rule
ERROR: /home/pi/bazel-0.22/tools/jdk/BUILD:47:1: Target '//tools/jdk:include/jni.h' contains an error and its package is in error and referenced by '//tools/jdk:jni_header'
ERROR: /home/pi/bazel-0.22/src/main/native/BUILD:15:1: Target '//tools/jdk:jni_header' contains an error and its package is in error and referenced by '//src/main/native:copy_link_jni_header'
ERROR: Analysis of target '//src:bazel' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.534s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
currently loading: @com_google_protobuf// ... (2 packages)
Then I tried to compile bazel from scratch, and it shows below error:
$ env EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk//:jdk" bash ./compile.sh
���� Building Bazel from scratch......
���� Building Bazel with Bazel.
.WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
INFO: Invocation ID: 86eceadf-6877-4953-a61b-9eccefa8edc3
ERROR: /tmp/bazel_Qg693GSE/out/external/local_config_cc/BUILD:47:1: in cc_toolchain_suite rule @local_config_cc//:toolchain: cc_toolchain_suite '@local_config_cc//:toolchain' does not contain a toolchain for cpu 'arm'
ERROR: Analysis of target '//src:bazel_nojdk' failed; build aborted: Analysis of target '@local_config_cc//:toolchain' failed; build aborted
INFO: Elapsed time: 11.584s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (100 packages loaded, 852 targets \
configured)
currently loading: third_party/grpc ... (2 packages)
ERROR: Could not build Bazel
Here is the output of hostnamectl
:
Static hostname: FriendlyELEC
Icon name: computer
Machine ID: a67d910fd5e04030a06b86fccf7fc716
Boot ID: 2eac78eee0db4c25962a05d16ce11782
Operating System: Ubuntu 16.04.5 LTS
Kernel: Linux 4.4.143
Architecture: arm64
and uname -m
:
aarch64
Somehow the cpu is recognized as ‘arm’ instead of ‘aarch64’ when “Building Bazel with Bazel” after “Building Bazel from scratch”? The hardware I am running on is this with RK3399 chip.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 3
- Comments: 15 (5 by maintainers)
I was able to get around this by editing
com/google/devtools/build/lib/analysis/config/AutoCpuConverter.java
and replacingreturn "arm"
withreturn "aarch64"
.