I'm currently trying to compile the latest version of Bazel (2.2.0) from source on a headless Raspberry Pi 4 that has Raspbian Buster installed. I was using this page as an installation guide.
I had no issue following the instructions on that page (all dependencies installed, Java 8 installed, swapsize changed, etc etc) until the point where I started compiling. The build failed with this error:
ERROR: /home/pi/bazel/src/main/java/com/google/devtools/build/lib/syntax/BUILD:150:1: C++ compilation of rule '//src/main/java/com/google/devtools/build/lib/syntax:libcpu_profiler.so' failed (Exit 1): gcc failed: error executing command
(cd /tmp/bazel_hpBqNseU/out/execroot/io_bazel && \
exec env - \
PATH=/home/pi/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games \
PWD=/proc/self/cwd \
/usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections -fdata-sections '-std=c++0x' -MD -MF bazel-out/arm-opt/bin/src/main/java/com/google/devtools/build/lib/syntax/_objs/libcpu_profiler.so/cpu_profiler_unimpl.pic.d '-frandom-seed=bazel-out/arm-opt/bin/src/main/java/com/google/devtools/build/lib/syntax/_objs/libcpu_profiler.so/cpu_profiler_unimpl.pic.o' -fPIC -iquote . -iquote bazel-out/arm-opt/bin -iquote external/bazel_tools -iquote bazel-out/arm-opt/bin/external/bazel_tools -isystem external/bazel_tools/tools/jdk/include -isystem bazel-out/arm-opt/bin/external/bazel_tools/tools/jdk/include -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c src/main/java/com/google/devtools/build/lib/syntax/cpu_profiler_unimpl.cc -o bazel-out/arm-opt/bin/src/main/java/com/google/devtools/build/lib/syntax/_objs/libcpu_profiler.so/cpu_profiler_unimpl.pic.o)
Execution platform: //:default_host_platform
In file included from src/main/java/com/google/devtools/build/lib/syntax/cpu_profiler_unimpl.cc:17:
bazel-out/arm-opt/bin/external/bazel_tools/toolsls/jdk/include/jni.h:45:10: fatal error: jni_md.h: No such file or directory
#include "jni_md.h"
^~~~~~~~~~
compilation terminated.
However, running find / -name jni_md.h 2> /dev/null
returns
/usr/lib/jvm/java-8-openjdk-armhf/include/linux/jni_md.h
So it's not as if the header file is missing from my system.
From looking around online (this question specifically) I apparently need to include an additional argument for gcc so it can see the file? However, I'm not sure where exactly I can find the specific build file I would need to edit in order to do so.
If anyone can help point me in the right direction, or if there's another solution that can fix this error, it would be appreciated.