bazel-3.3.0 fails to bootstrap on ppc64le
Description of the problem / feature request:
While bootstrapping bazel-3.3.0 on ppc64le:
In file included from src/main/java/com/google/devtools/build/lib/syntax/cpu_profiler_posix.cc:20:0:
bazel-out/ppc-opt/bin/external/bazel_tools/tools/jdk/include/jni.h:45:10: fatal error: jni_md.h: No such file or directory
#include "jni_md.h"
^~~~~~~~~~
compilation terminated.
Target //src:bazel_nojdk failed to build
INFO: Elapsed time: 173.915s, Critical Path: 19.09s
INFO: 735 processes: 735 local.
FAILED: Build did NOT complete successfully
This is probably because jni_md.h is in jdk/include/linux, not jdk/include. Looking at the JDK installation path on Ubuntu 18.04:
ubuntu@horus:~$ sudo find / -name jni_md.h
/usr/lib/jvm/java-8-openjdk-ppc64el/include/linux/jni_md.h
/usr/lib/jvm/java-11-openjdk-ppc64el/include/linux/jni_md.h
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Just try a bootstrap build on ppc64le.
What operating system are you running Bazel on?
Ubuntu 18.04.3
I had this problem on a raspberry pi 4 b (Debian 10 buster). I managed to build version 3.2.0 by doing the following edits:
1.cd {bazel_root}/tools/jdk
2.Open BUILD file
3.Edit the ares marked in bold:
# TODO(adonovan): add cases for //src/conditions:linux_{ppc,s390x} when released in Bazel. # TODO(adonovan): why is there no //src/conditions target meaning "just linux"? cc_library( name = "jni", hdrs = [":jni_header"] + select({ "//src/conditions:linux_x86_64": [":jni_md_header-linux"], "//src/conditions:linux_aarch64": [":jni_md_header-linux"], "//src/conditions:darwin": [":jni_md_header-darwin"], "//src/conditions:freebsd": [":jni_md_header-freebsd"], "//src/conditions:openbsd": [":jni_md_header-openbsd"], "//src/conditions:windows": [":jni_md_header-windows"], "//conditions:default": [], }), includes = ["include"] + select({ "//src/conditions:linux_x86_64": ["include/linux"], "//src/conditions:linux_aarch64": ["include/linux"], "//src/conditions:darwin": ["include/darwin"], "//src/conditions:freebsd": ["include/freebsd"], "//src/conditions:openbsd": ["include/openbsd"], "//src/conditions:windows": ["include/win32"], "//conditions:default": [], }), )
To the following:
# TODO(adonovan): add cases for //src/conditions:linux_{ppc,s390x} when released in Bazel. # TODO(adonovan): why is there no //src/conditions target meaning "just linux"? cc_library( name = "jni", hdrs = [":jni_header"] + select({ "//src/conditions:linux_x86_64": [":jni_md_header-linux"], "//src/conditions:linux_aarch64": [":jni_md_header-linux"], "//src/conditions:darwin": [":jni_md_header-darwin"], "//src/conditions:freebsd": [":jni_md_header-freebsd"], "//src/conditions:openbsd": [":jni_md_header-openbsd"], "//src/conditions:windows": [":jni_md_header-windows"], "//conditions:default": [":jni_md_header-linux"], }), includes = ["include"] + select({ "//src/conditions:linux_x86_64": ["include/linux"], "//src/conditions:linux_aarch64": ["include/linux"], "//src/conditions:darwin": ["include/darwin"], "//src/conditions:freebsd": ["include/freebsd"], "//src/conditions:openbsd": ["include/openbsd"], "//src/conditions:windows": ["include/win32"], "//conditions:default": ["include/linux"], }), )
4. (Optional) I also did the following commands to make sure the headers files are seen:
cd /usr/lib/jvm/java-11-openjdk-armhf/include
cp ./linux/* .
After that bazel compiled succesfully. Also i'm using g++ (Debian 9.3.0-14) 9.3.0
@redsigma Thanks.
If the maintainers are interested, this fixes the build for both ppc64/ppc64le: https://github.com/ceseo/bazel/commit/2c49a93a13424a899556453e1dfad83168877433
I already have a Google CLA signed for golang, so I think I'm clear.