Bazel 0.26.0, 0.29.0のbuildです。
1.準備
sudo apt install openjdk-8-jdk
jdk は下記では8がサポート対象となっている
8にしないとエラーが発生する。このような対応不能なエラーが発生した。
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (g1ConcurrentMark.cpp:1666), pid=5210, tid=5234
# fatal error: Overflow during reference processing, can not continue. Please increase MarkStackSizeMax (current value: 2097152) and restart.
#
# JRE version: OpenJDK Runtime Environment (11.0.3+7) (build 11.0.3+7-post-Raspbian-5)
https://docs.bazel.build/versions/master/install-compile-source.html
もし違う場合には、確認して変更またはインストールする
下の例は0だったので、2に変更した後に、再度確認した画面
sudo update-alternatives --config javac
There are 2 choices for the alternative javac (providing /usr/bin/javac).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-11-openjdk-armhf/bin/javac 1111 auto mode
1 /usr/lib/jvm/java-11-openjdk-armhf/bin/javac 1111 manual mode
* 2 /usr/lib/jvm/java-8-openjdk-armhf/bin/javac 1081 manual mode
Press <enter> to keep the current choice[*], or type selection number:
2. ソースのダウンロード
mkdir ~/prj/bazel;cd ~/prj/bazel
$ wget https://github.com/bazelbuild/bazel/releases/download/0.29.0/bazel-0.29.1-dist.zip
$ unzip bazel-0.29.0-dist.zip
3. build前の設定と変更
環境変数追加
$ EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk//:jdk"
2つのファイルを変更
compile.sh
before
bazel_build "src:bazel_nojdk${EXE_EXT}" \
--action_env=PATH \
--host_platform=@bazel_tools//platforms:host_platform \
--platforms=@bazel_tools//platforms:target_platform \
|| fail "Could not build Bazel"
after
bazel_build "src:bazel_nojdk${EXE_EXT}" \
--host_javabase=@local_jdk//:jdk \
--action_env=PATH \
--host_platform=@bazel_tools//platforms:host_platform \
--platforms=@bazel_tools//platforms:target_platform \
|| fail "Could not build Bazel"
scripts/bootstrap/compile.sh
before
run "${JAVAC}" -classpath "${classpath}" -sourcepath "${sourcepath}" \
-d "${output}/classes" -source "$JAVA_VERSION" -target "$JAVA_VERSION" \
-encoding UTF-8 ${BAZEL_JAVAC_OPTS} "@${paramfile}"
after
run "${JAVAC}" -classpath "${classpath}" -sourcepath "${sourcepath}" \
-d "${output}/classes" -source "$JAVA_VERSION" -target "$JAVA_VERSION" \
-encoding UTF-8 ${BAZEL_JAVAC_OPTS} "@${paramfile}" -J-Xmx1024M
で、Go!!!
time comple.sh
この文字列が出ればOK
Build successful! Binary is here: /home/pi/tmp/output/bazel
次にコピーして完了
sudo cp output/bazel /usr/local/bin
tころで、こんなエラーがでた。
これは、上記の一番目の変更をしなかったから。。。
ERROR: /tmp/bazel_SwJ5aUhR/out/external/bazel_tools/tools/jdk/BUILD:492:14: Configurable attribute "actual" doesn't match this configuration: Could not find a JDK for host execution environment, please explicitly provide one using `--host_javabase.`
Peace!!