我和我的团队正在研究Beaglebone Black,我们需要在其上安装Bazel。 我们尝试使用Bazel 0.18.1(启动时可获得的最新版本)和Java JDK的最新版本。 我们遇到的第一个问题是缺少Java堆空间,并出现以下错误:
The system is out of resources.
Consult the following stack trace for details.
java.lang.OutOfMemoryError: Java heap space
at java.util.HashMap.resize(HashMap.java:704)
at java.util.HashMap.putVal(HashMap.java:663)
at java.util.HashMap.put(HashMap.java:612)
at com.sun.tools.javac.parser.LazyDocCommentTable.putComment(LazyDocCommentTable.java:89)
at com.sun.tools.javac.parser.JavacParser.attach(JavacParser.java:538)
at com.sun.tools.javac.parser.JavacParser.methodDeclaratorRest(JavacParser.java:3609)
at com.sun.tools.javac.parser.JavacParser.classOrInterfaceBodyDeclaration(JavacParser.java:3532)
at com.sun.tools.javac.parser.JavacParser.classOrInterfaceBody(JavacParser.java:3436)
at com.sun.tools.javac.parser.JavacParser.classDeclaration(JavacParser.java:3285)
at com.sun.tools.javac.parser.JavacParser.classOrInterfaceOrEnumDeclaration(JavacParser.java:3226)
at com.sun.tools.javac.parser.JavacParser.classOrInterfaceBodyDeclaration(JavacParser.java:3486)
at com.sun.tools.javac.parser.JavacParser.classOrInterfaceBody(JavacParser.java:3436)
at com.sun.tools.javac.parser.JavacParser.classDeclaration(JavacParser.java:3285)
at com.sun.tools.javac.parser.JavacParser.classOrInterfaceOrEnumDeclaration(JavacParser.java:3226)
at com.sun.tools.javac.parser.JavacParser.typeDeclaration(JavacParser.java:3215)
at com.sun.tools.javac.parser.JavacParser.parseCompilationUnit(JavacParser.java:3155)
at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:628)
at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:665)
at com.sun.tools.javac.main.JavaCompiler.parseFiles(JavaCompiler.java:950)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:857)
at com.sun.tools.javac.main.Main.compile(Main.java:523)
at com.sun.tools.javac.main.Main.compile(Main.java:381)
at com.sun.tools.javac.main.Main.compile(Main.java:370)
at com.sun.tools.javac.main.Main.compile(Main.java:361)
at com.sun.tools.javac.Main.compile(Main.java:56)
at com.sun.tools.javac.Main.main(Main.java:42)
在对互联网进行研究后,我们尝试增加可用的堆空间,如下所示导出BAZEL_JAVAC_OPTS
(请参见compile.sh - The system is out of resources):
$ export BAZEL_JAVAC_OPTS="-J-Xms256m -J-Xmx384m"
但是之后我们将无法继续,我们看到以下代码:
Building Bazel from scratch..scripts/bootstrap/buildenv.sh: line 186: 1740 Killed "${@}" >> "${errfile}" 2>&1
/usr/lib/jvm/java-8-openjdk-armhf/bin/javac -classpath third_party/opencensus/opencensus-contrib-grpc-metrics-0.11.0.jar:third_party/opencensus/opencensus-api-0.11.0.jar:third_party/mockito/mockito-all-1.10.19.jar:third_party/hamcrest/ha
mcrest-core-1.3.jar:third_party/apache_commons_pool2/commons-pool2-2.3.jar:third_party/netty_tcnative/netty-tcnative-boringssl-static-2.0.7.Final.jar:third_party/apache_httpcore/httpcore-4.4.6.jar:third_party/checker_framework_javacutil/
javacutil-2.5.3-sources.jar:third_party/checker_framework_javacutil/javacutil-2.5.3.jar:third_party/apache_commons_logging/commons-logging-1.1.1.jar:third_party/hungarian_algorithm/software-and-algorithms-1.0-src.jar:third_party/hungaria
n_algorithm/software-and-algorithms-1.0.jar:third_party/guava/guava-testlib-25.1-jre.jar:third_party/error_prone/error_prone_annotation-2.3.2-SNAPSHOT.jar:third_party/error_prone/error_prone_check_api-2.3.2-SNAPSHOT.jar:third_party/error
_prone/error_prone_annotations-2.2.0.jar:third_party/error_prone/error_prone_type_annotations-2.3.2-SNAPSHOT.jar:third_party/netty/netty-all-4.1.17.Final.jar:third_party/jcip_annotations/jcip-annotations-1.0-1.jar:third_party/jsch/jsch-0
.1.54.jar:third_party/checker_framework_dataflow/dataflow-2.5.3.jar:third_party/checker_framework_dataflow/dataflow-2.5.3-sources.jar:third_party/jimfs/jimfs-1.1.jar:third_party/turbine/turbine.jar:third_party/instrumentation/instrumenta
tion-api-0.4.3.jar:third_party/apache_commons_lang/commons-lang-2.6.jar:third_party/apache_httpclient/httpclient-4.5.3.jar:third_party/gson/gson-2.2.4.jar:third_party/apache_commons_compress/apache-commons-compress-1.9.jar:third_party/ae
ther/aether-impl-1.0.0.v20140518.jar:third_party/aether/aether-transport-http-1.0.0.v20140518.jar:third_party/aether/aether-transport-file-1.0.0.v20140518.jar:third_party/aether/aether-connector-basic-1.0.0.v20140518.jar:third_party/aeth
er/aether-transport-wagon-1.0.0.v20140518.jar:third_party/aether/aether-util-1.0.0.v20140518.jar:third_party/aether/aether-transport-classpath-1.0.0.v20140518.jar:third_party/aether/aether-spi-1.0.0.v20140518.jar:third_party/aether/aethe
r-api-1.0.0.v20140518.jar:third_party/auth/google-auth-library-credentials-0.6.0.jar:third_party/auth/google-auth-library-oauth2-http-0.6.0.jar:third_party/plexus_interpolation/plexus-interpolation-1.22.jar:third_party/ijar/test/libwrong
centraldir.jar:third_party/ijar/test/jar-with-manifest.jar:third_party/ijar/test/nestmates/nestmates.jar:third_party/ijar/test/jar-without-manifest.jar:third_party/ijar/test/jar-with-manifest-and-target-label.jar:third_party/javax_annota
tions/javax.annotation-api-1.3.2-sources.jar:third_party/javax_annotations/javax.annotation-api-1.3.2.jar:third_party/objenesis/objenesis-1_3.jar:third_party/plexus_utils/plexus-utils-3.0.21.jar:third_party/allocation_instrumenter/java-a
llocation-instrumenter-3.0.1.jar:third_party/truth8/truth-java8-extension-0.42.jar:third_party/slf4j/slf4j-jdk14-1.7.7.jar:third_party/slf4j/slf4j-api-1.7.7.jar:third_party/pcollections/pcollections-2.1.2.jar:third_party/apache_commons_c
ollections/commons-collections-3.2.2.jar:third_party/bazel_bootstrap/libregistered-singleton.jar:third_party/bazel_bootstrap/libautocodec-processor.jar:third_party/bazel_bootstrap/libserialization.jar:third_party/bazel_bootstrap/libautoc
odec-annotation.jar:third_party/bazel_bootstrap/libunsafe-provider.jar:third_party/compile_testing/compile-testing-0.13.jar:third_party/maven/maven-settings-3.3.3.jar:third_party/maven/maven-settings-builder-3.3.3.jar:third_party/maven/m
aven-builder-support-3.3.3.jar:third_party/truth/truth-0.42.jar:third_party/asm/asm-6.2.1-sources.jar:third_party/asm/asm-tree-6.2.1.jar:third_party/asm/asm-tree-6.2.1-sources.jar:third_party/asm/asm-util-6.2.1-sources.jar:third_party/as
m/asm-util-6.2.1.jar:third_party/asm/asm-6.2.1.jar:third_party/asm/asm-commons-6.2.1.jar:third_party/asm/asm-analysis-6.2.1.jar:third_party/asm/asm-commons-6.2.1-sources.jar:third_party/asm/asm-analysis-6.2.1-sources.jar:third_party/apac
he_commons_codec/commons-codec-1.9.jar:third_party/maven_model/maven-model-builder-3.2.3.jar:third_party/maven_model/maven-repository-metadata-3.2.3.jar:third_party/maven_model/maven-model-3.2.3.jar:third_party/maven_model/maven-aether-p
rovider-3.2.3.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/java_compiler-src.jar:third_party/java/jdk/langtools/jdk_compiler-src.jar:third_
party/java/jdk/langtools/java_compiler.jar:third_party/java/jdk/langtools/jdk_compiler.jar:third_party/java/proguard/proguard5.3.3/lib/retrace.jar:third_party/java/proguard/proguard5.3.3/lib/proguard.jar:third_party/java/proguard/proguar
d5.3.3/lib/proguardgui.jar:third_party/java/proguard/proguard5.3.3/examples/annotations/lib/annotations.jar:third_party/java/jacoco/org.jacoco.agent-0.7.5.201505241946-src.jar:third_party/java/jacoco/org.jacoco.core-0.7.5.201505241946.ja
r:third_party/java/jacoco/jacocoagent.jar:third_party/java/jacoco/org.jacoco.report-0.7.5.201505241946-src.jar:third_party/java/jacoco/org.jacoco.report-0.7.5.201505241946.jar:third_party/java/jacoco/org.jacoco.core-0.7.5.201505241946-sr
c.jar:third_party/java/jacoco/org.jacoco.agent-0.7.5.201505241946.jar:third_party/java/javapoet/javapoet-1.8.0.jar:third_party/java/jcommander/jcommander-1.48.jar:third_party/android_common/com.android.tools.external.lombok_lombok-ast_0.
2.3.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.build_builder-test-api_2.0.0.jar:third_party/a
ndroid_common/com.android.tools_dvlib_25.0.0.jar:third_party/android_common/com.android.tools_common_25.0.0.jar:third_party/android_common/com.android.tools_sdk-common_25.0.0.jar:third_party/android_common/com.android_annotations_25.0.0.
jar:third_party/android_common/com.android.tools.lint_lint-checks_25.0.0.jar:third_party/android_common/com.android.tools_repository_25.0.0.jar:third_party/android_common/com.android.tools_ddmlib_25.0.0.jar:third_party/android_common/com
.android.tools.layoutlib_layoutlib_26.1.2.jar:third_party/android_common/com.android.tools.build_manifest-merger_25.0.0.jar:third_party/android_common/com.android.tools.build_builder_2.0.0.jar:third_party/android_common/com.android.tools
.lint_lint-api_25.0.0.jar:third_party/auto/auto-service-1.0-rc2.jar:third_party/auto/auto-value-1.5.4.jar:third_party/auto/auto-common-0.3.jar:third_party/tomcat_annotations_api/tomcat-annotations-api-8.0.5.jar:third_party/xz/xz-1.5.jar:
third_party/jsr330_inject/javax.inject.jar:third_party/apache_velocity/velocity-1.7.jar:third_party/junit/junit-4.12.jar:third_party/diffutils/diffutils-1.3.0.jar:third_party/jsr305/jsr-305.jar:third_party/protobuf/3.6.1/libprotobuf_java
_util.jar:third_party/protobuf/3.6.1/libprotobuf_java.jar:third_party/api_client/google-api-client-jackson2-1.22.0.jar:third_party/api_client/google-http-client-1.22.0-SNAPSHOT.jar:third_party/api_client/google-http-client-jackson2-1.22.
0.jar:third_party/api_client/google-api-client-1.22.0.jar:third_party/jackson2/jackson-core-2.8.6.jar:third_party/jgit/org.eclipse.jgit-4.10.0.201712302008-r.jar:third_party/plexus_component_annotations/plexus-component-annotations-1.6.j
ar:third_party/grpc/grpc-core-1.10.0.jar:third_party/grpc/grpc-stub-1.10.0.jar:third_party/grpc/grpc-context-1.10.0.jar:third_party/grpc/grpc-protobuf-1.10.0.jar:third_party/grpc/grpc-protobuf-lite-1.10.0.jar:third_party/grpc/grpc-netty-
1.10.0.jar:third_party/grpc/grpc-auth-1.10.0.jar:third_party/guava/guava-25.1-jre.jar:third_party/error_prone/error_prone_core-2.3.2-SNAPSHOT.jar:/tmp/bazel_b8bs0DpB -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:third_party/java/dd_plist/java:/tmp/bazel_b8bs0DpB/src -d /tmp/bazel_b8bs0DpB/classes -sou
rce 1.8 -target 1.8 -encoding UTF-8 -J-Xms256m -J-Xmx384m @/tmp/bazel_8YV1VpPi/param
有人曾尝试在arm32上编译bazel并有一些线索吗?
答案 0 :(得分:2)
我想Java编译器消耗了太多的内存,而OS杀死了它。 512MB RAM应该足以运行Bazel,但可能不足以引导Bazel。但是有希望。
开始之前:您的问题表明有必要在自举脚本中正确实现我将要描述的内容。遗憾的是,它目前尚未实现,因此您将不得不做大量的工作。
首先,您必须了解引导脚本(./compile.sh
和scripts/bootstrap
下的3个脚本)的工作方式。
compile.sh
驱动引导过程,该过程包括两个阶段:
第一步非常占用内存,因为它运行单个javac
来编译Bazel的每个.java
源。我相信第二步可能只需要512MB RAM。
我们将编辑引导脚本,以仅生成最小的Bazel jar。我对这一步骤的成功充满信心。
在台式计算机上:
echo "${ARCHIVE_DIR}/libblaze.jar" ; exit 0
(https://github.com/bazelbuild/bazel/blob/b18915752a69fbbc6ed94e1710198167593565fc/scripts/bootstrap/compile.sh#L411 ./compile.sh
这将产生libblaze.jar
。将此jar部署到设备上。
我们将编辑引导脚本,以跳过“从源编译”步骤,并使用上一步中的.jar
文件。对于此步骤的成功,我不太自信,因为我以前从未做过,但是请尝试一下。
在设备上:
$HOME/libblaze.jar
cp $HOME/libblaze.jar ${ARCHIVE_DIR}/libblaze.jar
代替./compile.sh
希望这会在设备上引导Bazel。请让它知道怎么回事!
更新1 :我应该提到该设备应该具有64位CPU。 Bazel的C ++代码需要64位体系结构。您还必须确保以与设备上JDK相同的位数和字节序对桌面JDK进行编译。
更新2 :第一个纯Java Bazel仅是Linux(可能是macOS)上的纯Java。在Windows上,它还包含一个从头开始here构建的JNI库。