bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
23.06k stars 4.04k forks source link

ERROR: does not contain a toolchain for cpu 'arm' #7471

Closed protossw512 closed 5 years ago

protossw512 commented 5 years ago

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.

hlopko commented 5 years ago

CC @meisterT @iirina

vielmetti commented 5 years ago

attn @ArielleA

scentini commented 5 years ago

Re building from scratch: Seems that we propagate the 'aarch64' correctly during autoconfiguration, but when Bazel tries to detect the current architecture using Java system properties, os.arch returns 'arm' instead of 'aarch64'. If this is the case, you can change the os.arch property to 'aarch64' to match the output from uname -m.

vielmetti commented 5 years ago

@protossw512 - which Java JDK are you using?

protossw512 commented 5 years ago

@vielmetti unfortunately we switched to another embedded system and this system is not in my hand right now, but I remember the JDK is installed with apt-get in ubuntu 16.04.

vielmetti commented 5 years ago

Thanks @protossw512 - I know there are a number of choices for a JDK these days, and wonder if we can figure out if this problem is isolated to that distribution or more widespread.

protossw512 commented 5 years ago

@vielmetti I also recall I installed dependencies with the command provided from official website: sudo apt-get install build-essential openjdk-8-jdk python zip unzip Not sure if it is helpful.

ArielleA commented 5 years ago

This is unlikely to be an issue with the host, but instead the embedded jdk. I'll have to have a look at where the problem is coming from.

protossw512 commented 5 years ago

@ArielleA I think you are right, I am trying to build the same bazel version on another embedded system with similar chipset, the building process ended up without any issue.

$ hostnamectl
   Static hostname: localhost.localdomain
         Icon name: computer
        Machine ID: 019126b158794aa0a917f58462e27699
           Boot ID: fddeda07e24243869fac709bcb9a7b7d
  Operating System: Fedora 28 (Server Edition)
       CPE OS Name: cpe:/o:fedoraproject:fedora:28
            Kernel: Linux 4.4.167
      Architecture: arm64
$ uname -m
aarch64
$ java -version
openjdk version "1.8.0_201"
OpenJDK Runtime Environment (build 1.8.0_201-b09)
OpenJDK 64-Bit Server VM (build 25.201-b09, mixed mode)
ArielleA commented 5 years ago

Just check both systems are running 64 bit userland with getconf LONG_BIT that could cause all kinds of weirdness.

ArielleA commented 5 years ago

I just built 0.25.2 in both Debian Stretch and Ubuntu bionic without any issue on aarch64 as part of #8143. Could you check you're still having issues, it may be due to memory exhaustion.

protossw512 commented 5 years ago

@ArielleA Thank you for the follow-ups, I tried again and there is no problem at all.

fbaldassarri commented 5 years ago

Same issue, but with "arm" instead of "armv6l". (I am not sure this is really caused by the same issue.)

pi@raspberrypi:~/bazel-dist $ env EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk//:jdk" BAZEL_JAVAC_OPTS="-J-Xmx512M -J-Xms512M" 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". DEBUG: /tmp/bazel_55EbxDW9/out/external/build_bazel_rules_nodejs/internal/common/check_bazel_version.bzl:49:5: Current Bazel is not a release version, cannot check for compatibility. DEBUG: /tmp/bazel_55EbxDW9/out/external/build_bazel_rules_nodejs/internal/common/check_bazel_version.bzl:51:5: Make sure that you are running at least Bazel 0.17.1. ERROR: /tmp/bazel_55EbxDW9/out/external/local_config_cc/BUILD:46: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: 71.657s INFO: 0 processes. FAILED: Build did NOT complete successfully (16 packages loaded, 65 targets co\ nfigured) ERROR: Could not build Bazel

On a Raspberry Pi Zero W, Rasbpian OS (Debian) 9 Stretch kernel 4.19.42+ 32bit - bazel-0.26.1-dist

This is the verbose

🍃 Building Bazel from scratch../usr/lib/jvm/java-8-openjdk-armhf/bin/javac -classpath third_party/flogger/flogger-system-backend-0.3.1.jar:third_party/flogger/flogger-0.3.1.jar:third_party/flogger/google-extensions-0.3.1.jar:third_party/checker_framework_annotations/checker-compat-qual-2.6.0.jar:third_party/checker_framework_annotations/checker-qual-2.6.0.jar:third_party/jackson2/jackson-core-2.8.6.jar:third_party/jimfs/jimfs-1.1.jar:third_party/apache_velocity/velocity-1.7.jar:third_party/hamcrest/hamcrest-core-1.3.jar:third_party/maven/maven-settings-3.3.3.jar:third_party/maven/maven-settings-builder-3.3.3.jar:third_party/maven/maven-builder-support-3.3.3.jar:third_party/hungarian_algorithm/software-and-algorithms-1.0-src.jar:third_party/hungarian_algorithm/software-and-algorithms-1.0.jar:third_party/error_prone/error_prone_check_api-2.3.2-SNAPSHOT.jar:third_party/error_prone/error_prone_annotation-2.3.2-SNAPSHOT.jar:third_party/error_prone/error_prone_type_annotations-2.3.2-SNAPSHOT.jar:third_party/error_prone/error_prone_annotations-2.2.0.jar:third_party/guava/guava-25.1-jre.jar:third_party/auth/google-auth-library-oauth2-http-0.15.0.jar:third_party/auth/google-auth-library-credentials-0.15.0.jar:third_party/compile_testing/compile-testing-0.13.jar:third_party/jsch/jsch-0.1.54.jar:third_party/apache_commons_codec/commons-codec-1.9.jar:third_party/asm/asm-commons-7.0-sources.jar:third_party/asm/asm-tree-7.0.jar:third_party/asm/asm-commons-7.0.jar:third_party/asm/asm-analysis-7.0.jar:third_party/asm/asm-util-7.0.jar:third_party/asm/asm-util-7.0-sources.jar:third_party/asm/asm-tree-7.0-sources.jar:third_party/asm/asm-analysis-7.0-sources.jar:third_party/asm/asm-7.0-sources.jar:third_party/asm/asm-7.0.jar:third_party/protobuf/3.6.1/libprotobuf_java_util.jar:third_party/protobuf/3.6.1/libprotobuf_java.jar:third_party/truth8/truth-java8-extension-0.44.jar:third_party/xz/xz-1.5.jar:third_party/bazel_bootstrap/libautocodec-processor.jar:third_party/bazel_bootstrap/libregistered-singleton.jar:third_party/bazel_bootstrap/libserialization.jar:third_party/bazel_bootstrap/libautocodec-annotation.jar:third_party/bazel_bootstrap/libunsafe-provider.jar:third_party/jsr330_inject/javax.inject.jar:third_party/api_client/google-http-client-1.22.0-SNAPSHOT.jar:third_party/api_client/google-api-client-jackson2-1.22.0.jar:third_party/api_client/google-api-client-1.22.0.jar:third_party/api_client/google-http-client-jackson2-1.22.0.jar:third_party/apache_commons_collections/commons-collections-3.2.2.jar:third_party/tomcat_annotations_api/tomcat-annotations-api-8.0.5.jar:third_party/opencensus/opencensus-contrib-grpc-metrics-0.19.2.jar:third_party/opencensus/opencensus-api-0.19.2.jar:third_party/jcip_annotations/jcip-annotations-1.0-1.jar:third_party/diffutils/diffutils-1.3.0.jar:third_party/plexus_component_annotations/plexus-component-annotations-1.6.jar:third_party/java/android_databinding/v2_3_1/exec.jar:third_party/java/jdk/langtools/javac-9+181-r4173-1.jar:third_party/java/jdk/langtools/jdk_compiler-src.jar:third_party/java/jdk/langtools/java_compiler-src.jar:third_party/java/jdk/langtools/jdk_compiler.jar:third_party/java/jdk/langtools/java_compiler.jar:third_party/java/jcommander/jcommander-1.48.jar:third_party/java/javapoet/javapoet-1.8.0.jar:third_party/java/jacoco/org.jacoco.report-0.7.5.201505241946.jar:third_party/java/jacoco/org.jacoco.core-0.7.5.201505241946-src.jar:third_party/java/jacoco/org.jacoco.core-0.7.5.201505241946.jar:third_party/java/jacoco/org.jacoco.report-0.7.5.201505241946-src.jar:third_party/java/jacoco/org.jacoco.agent-0.7.5.201505241946.jar:third_party/java/jacoco/org.jacoco.agent-0.7.5.201505241946-src.jar:third_party/java/jacoco/jacocoagent.jar:third_party/java/proguard/proguard5.3.3/examples/annotations/lib/annotations.jar:third_party/java/proguard/proguard5.3.3/lib/proguard.jar:third_party/java/proguard/proguard5.3.3/lib/retrace.jar:third_party/java/proguard/proguard5.3.3/lib/proguardgui.jar:third_party/auto/auto-service-1.0-rc4.jar:third_party/auto/auto-value-annotations-1.6.3rc1.jar:third_party/auto/auto-common-0.10.jar:third_party/auto/auto-value-1.6.3rc1.jar:third_party/ijar/test/jar-with-manifest-and-target-label.jar:third_party/ijar/test/libwrongcentraldir.jar:third_party/ijar/test/jar-without-manifest.jar:third_party/ijar/test/nestmates/nestmates.jar:third_party/ijar/test/jar-with-manifest.jar:third_party/apache_commons_lang/commons-lang-2.6.jar:third_party/instrumentation/instrumentation-api-0.4.3.jar:third_party/apache_commons_logging/commons-logging-1.1.1.jar:third_party/allocation_instrumenter/java-allocation-instrumenter-3.0.1.jar:third_party/pcollections/pcollections-2.1.2.jar:third_party/apache_httpcore/httpcore-4.4.6.jar:third_party/plexus_utils/plexus-utils-3.0.21.jar:third_party/maven_model/maven-model-builder-3.2.3.jar:third_party/maven_model/maven-aether-provider-3.2.3.jar:third_party/maven_model/maven-model-3.2.3.jar:third_party/maven_model/maven-repository-metadata-3.2.3.jar:third_party/objenesis/objenesis-1_3.jar:third_party/plexus_interpolation/plexus-interpolation-1.22.jar:third_party/gson/gson-2.2.4.jar:third_party/apache_httpclient/httpclient-4.5.3.jar:third_party/bytebuddy/byte-buddy-1.9.7.jar:third_party/bytebuddy/byte-buddy-agent-1.9.7.jar:third_party/apache_commons_pool2/commons-pool2-2.3.jar:third_party/turbine/turbine_direct.jar:third_party/jsr305/jsr-305.jar:third_party/netty_tcnative/netty-tcnative-boringssl-static-2.0.24.Final.jar:third_party/aether/aether-transport-wagon-1.0.0.v20140518.jar:third_party/aether/aether-transport-file-1.0.0.v20140518.jar:third_party/aether/aether-transport-http-1.0.0.v20140518.jar:third_party/aether/aether-impl-1.0.0.v20140518.jar:third_party/aether/aether-api-1.0.0.v20140518.jar:third_party/aether/aether-util-1.0.0.v20140518.jar:third_party/aether/aether-spi-1.0.0.v20140518.jar:third_party/aether/aether-connector-basic-1.0.0.v20140518.jar:third_party/aether/aether-transport-classpath-1.0.0.v20140518.jar:third_party/android_common/com.android.tools_sdk-common_25.0.0-stripped.jar:third_party/android_common/com.android.tools_sdk-common_25.0.0.jar:third_party/android_common/com.android.tools.layoutlib_layoutlib_26.1.2.jar:third_party/android_common/com.android.tools_common_25.0.0.jar:third_party/android_common/com.android.tools_sdklib_25.0.0.jar:third_party/android_common/com.android.tools.build_builder-model_2.0.0.jar:third_party/android_common/com.android.tools.external.lombok_lombok-ast_0.2.3.jar:third_party/android_common/com.android.tools.lint_lint-api_25.0.0.jar:third_party/android_common/com.android.tools.layoutlib_layoutlib_26.1.2-stripped.jar:third_party/android_common/com.android.tools.build_manifest-merger_25.0.0-patched.jar:third_party/android_common/com.android.tools_repository_25.0.0.jar:third_party/android_common/com.android.tools.build_builder_2.0.0.jar:third_party/android_common/com.android.tools_dvlib_25.0.0.jar:third_party/android_common/com.android.tools.lint_lint-checks_25.0.0.jar:third_party/android_common/com.android_annotations_25.0.0.jar:third_party/android_common/com.android.tools.build_builder-test-api_2.0.0.jar:third_party/junit/junit-4.12.jar:third_party/apache_commons_compress/apache-commons-compress-1.9.jar:third_party/javax_annotations/javax.annotation-api-1.3.2.jar:third_party/javax_annotations/javax.annotation-api-1.3.2-sources.jar:third_party/checker_framework_dataflow/dataflow-2.5.3.jar:third_party/checker_framework_dataflow/dataflow-2.5.3-sources.jar:third_party/mockito/mockito-core-2.25.1.jar:third_party/jaxb/jaxb-api-2.3.1-patched.jar:third_party/jaxb/jaxb-api-2.3.1.jar:third_party/jaxb/jaxb-api-2.3.1-sources.jar:third_party/netty/netty-all-4.1.34.Final.jar:third_party/truth/truth-0.44.jar:third_party/slf4j/slf4j-api-1.7.7.jar:third_party/slf4j/slf4j-jdk14-1.7.7.jar:third_party/checker_framework_javacutil/javacutil-2.5.3.jar:third_party/checker_framework_javacutil/javacutil-2.5.3-sources.jar:third_party/grpc/grpc-context-1.20.0.jar:third_party/grpc/grpc-netty-1.20.0.jar:third_party/grpc/grpc-protobuf-lite-1.20.0.jar:third_party/grpc/grpc-stub-1.20.0.jar:third_party/grpc/grpc-core-1.20.0.jar:third_party/grpc/grpc-auth-1.20.0.jar:third_party/grpc/grpc-protobuf-1.20.0.jar:third_party/guava/guava-testlib-25.1-jre.jar:third_party/error_prone/error_prone_core-2.3.2-SNAPSHOT.jar:/tmp/bazel_oTzlyLI0 -sourcepath src/java_tools/singlejar/java/com/google/devtools/build/zip:src/main/java:src/tools/xcode-common/java/com/google/devtools/build/xcode/common:src/tools/xcode-common/java/com/google/devtools/build/xcode/util:tools/java/runfiles:third_party/java/dd_plist/java:/tmp/bazel_oTzlyLI0/src -d /tmp/bazel_oTzlyLI0/classes -source 1.8 -target 1.8 -encoding UTF-8 --J-Xmx512M -J-Xms512m @/tmp/bazel_qVgNSO0j/param

pi@raspberrypi:~ $ hostnamectl Static hostname: raspberrypi Icon name: computer Machine ID: aab2e9df2c214a7a973208a33d079aed Boot ID: 82fd50b9f1e74e86863fd8a435742827 Operating System: Raspbian GNU/Linux 9 (stretch) Kernel: Linux 4.19.42+ Architecture: arm

pi@raspberrypi:~ $ uname -a Linux raspberrypi 4.19.42+ #1219 Tue May 14 21:16:38 BST 2019 armv6l GNU/Linux

ZxMYS commented 4 years ago

Seeing this too when trying to build bazel 0.26.1 on my raspberry pi

$ uname -a
Linux raspberrypi 4.19.83-v8+ #1277 SMP PREEMPT Mon Nov 11 16:53:30 GMT 2019 aarch64 GNU/Linux
$ java -version
openjdk version "11.0.5" 2019-10-15
OpenJDK Runtime Environment (build 11.0.5+10-post-Raspbian-1deb10u1)
OpenJDK Server VM (build 11.0.5+10-post-Raspbian-1deb10u1, mixed mode)
ZxMYS commented 4 years ago

I was able to get around this by editing com/google/devtools/build/lib/analysis/config/AutoCpuConverter.java and replacing return "arm" with return "aarch64".