在 MIPS 上构建 bazel-0.5.0rc9 失败

Build bazel-0.5.0rc9 fails on MIPS

BadExitStatusException: Process exited with status 50 构建 bazel-0.5.0rc9 失败。终端输出错误如下

ERROR: /home/xzy/bazel-0.5.0rc9/src/java_tools/singlejar/BUILD:77:1: error executing shell command: 'set -e;rm -rf bazel-out/host/bin/src/java_tools/singlejar/bootstrap_deploy.jar.build_output;mkdir bazel-out/host/bin/src/java_tools/singlejar/bootstrap_deploy.jar.build_output
unzip -qn bazel-out/h...' failed: bash failed: error executing command
  (cd /tmp/bazel_Qvcl1sVW/out/execroot/bazel-0.5.0rc9 && \
  exec env - \
    PATH=/opt/j2sdk-image/bin:/usr/local/bin/:/opt/j2sdk-image/bin:/usr/local/bin/:/opt/j2sdk-image/bin:/usr/local/bin/:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/home/xzy/.local/bin:/home/xzy/bin \
  /bin/bash -c 'set -e;rm -rf bazel-out/host/bin/src/java_tools/singlejar/bootstrap_deploy.jar.build_output;mkdir bazel-out/host/bin/src/java_tools/singlejar/bootstrap_deploy.jar.build_output
unzip -qn bazel-out/host/bin/src/java_tools/singlejar/libbootstrap.jar -d bazel-out/host/bin/src/java_tools/singlejar/bootstrap_deploy.jar.build_output
unzip -qn bazel-out/host/bin/src/java_tools/singlejar/libskylark-deps.jar -d bazel-out/host/bin/src/java_tools/singlejar/bootstrap_deploy.jar.build_output
unzip -qn third_party/auto/auto-common-0.3.jar -d bazel-out/host/bin/src/java_tools/singlejar/bootstrap_deploy.jar.build_output
unzip -qn third_party/error_prone/error_prone_annotation-2.0.20-SNAPSHOT.jar -d bazel-out/host/bin/src/java_tools/singlejar/bootstrap_deploy.jar.build_output
unzip -qn third_party/error_prone/error_prone_annotations-2.0.20-SNAPSHOT.jar -d bazel-out/host/bin/src/java_tools/singlejar/bootstrap_deploy.jar.build_output
unzip -qn third_party/error_prone/error_prone_check_api-2.0.20-SNAPSHOT.jar -d bazel-out/host/bin/src/java_tools/singlejar/bootstrap_deploy.jar.build_output
unzip -qn third_party/error_prone/error_prone_core-2.0.20-SNAPSHOT.jar -d bazel-out/host/bin/src/java_tools/singlejar/bootstrap_deploy.jar.build_output
unzip -qn third_party/guava/guava-21.0.jar -d bazel-out/host/bin/src/java_tools/singlejar/bootstrap_deploy.jar.build_output
unzip -qn third_party/jcip_annotations/jcip-annotations-1.0-1.jar -d bazel-out/host/bin/src/java_tools/singlejar/bootstrap_deploy.jar.build_output
unzip -qn third_party/jsr305/jsr-305.jar -d bazel-out/host/bin/src/java_tools/singlejar/bootstrap_deploy.jar.build_output
unzip -qn third_party/pcollections/pcollections-2.1.2.jar -d bazel-out/host/bin/src/java_tools/singlejar/bootstrap_deploy.jar.build_output
unzip -qn bazel-out/host/bin/third_party/checker_framework_dataflow/libbootstrap.jar -d bazel-out/host/bin/src/java_tools/singlejar/bootstrap_deploy.jar.build_output
unzip -qn bazel-out/host/bin/third_party/jformatstring/libbootstrap.jar -d bazel-out/host/bin/src/java_tools/singlejar/bootstrap_deploy.jar.build_output
unzip -qn bazel-out/host/bin/src/main/java/com/google/devtools/build/lib/libshell-skylark.jar -d bazel-out/host/bin/src/java_tools/singlejar/bootstrap_deploy.jar.build_output
external/local_jdk/bin/jar cmf bazel-out/host/bin/src/java_tools/singlejar/bootstrap_MANIFEST.MF bazel-out/host/bin/src/java_tools/singlejar/bootstrap_deploy.jar -C bazel-out/host/bin/src/java_tools/singlejar/bootstrap_deploy.jar.build_output .
touch bazel-out/host/bin/src/java_tools/singlejar/bootstrap_deploy.jar.build_output
'): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 50.
???????
ERROR: I/O error while writing action log: ???????.
Target //src:bazel failed to build
INFO: Elapsed time: 118.800s, Critical Path: 36.91s


$ java -version
openjdk version "1.8.0_25"
OpenJDK Runtime Environment (build 1.8.0_25-rc21-b17)
OpenJDK 64-Bit Server VM (build 25.25-b02, mixed mode)
$ uname -a
Linux localhost.localdomain 3.10.84 #1 SMP PREEMPT Wed Feb 8 16:03:10 CST 2017 mips64 mips64 mips64 GNU/Linux

我收到向上错误,因为我在 CrosstoolConfigurationLoader.java 文件中添加了一些打印信息以进行调试。删除它可以修复它。

...
String selectedIdentifier = null;
String desiredCpu = cpuTransformer.apply(config.getCpu());
System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
System.out.println("desiredCpu="+desiredCpu);
System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
for (CrosstoolConfig.DefaultCpuToolchain selector : 
release.getDefaultToolchainList()) {
System.out.println("#########selector.getCpu()="+selector.getCpu());
if (selector.getCpu().equals(desiredCpu)) {
selectedIdentifier = selector.getToolchainIdentifier();
break;
}
...

错误详情见bazel#3017bazel#3068,链接见上评论
构建成功补丁推断build-bazel-mips64.patch