Bazel: Raspberry Pi: Bazel build fails with fatal error: jni_md.h: No such file or directory

Created on 4 Jul 2020  路  4Comments  路  Source: bazelbuild/bazel

ATTENTION! Please read and follow:

  • if this is a _question_ about how to build / test / query / deploy using Bazel, or a _discussion starter_, send it to [email protected]
  • if this is a _bug_ or _feature request_, fill the form below as best as you can.

Description of the problem / feature request:

Raspberry Pi: Bazel build fails with fatal error: jni_md.h: No such file or directory. While building 3.3.1 distribution on JDK11, Raspberry Pi 4B, the build fails with the following error:

````
ERROR: /home/pi/workspace/mediapipe/bazel/src/main/java/com/google/devtools/build/lib/syntax/BUILD:139:10: 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_jLqe6uBU/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/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: 754.797s, Critical Path: 78.28s
INFO: 805 processes: 805 local.
FAILED: Build did NOT complete successfully

ERROR: Could not build Bazel

````

Feature requests: what underlying problem are you trying to solve with this feature?

Bazel build issue on ARM (Raspberry Pi)

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Download the distribution: https://docs.bazel.build/versions/master/install-compile-source.html#bootstrap-bazel (followed all instructions from here). In addition to the instructions from this page, I have set the JVM heap as J-Xmx500M at line 142 of compile.sh script.

What operating system are you running Bazel on?

Linux raspberrypi 4.19.118-v7l+ #1311 SMP Mon Apr 27 14:26:42 BST 2020 armv7l GNU/Linux

What's the output of bazel info release?

Can't run this command since the build is unsuccessful.

If bazel info release returns "development version" or "(@non-git)", tell us how you built Bazel.

NA

What's the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?

NA

Have you found anything relevant by searching the web?

Similar issue reported on ppc: https://github.com/bazelbuild/bazel/issues/10746

Any other information, logs, or outputs that you want to share?

Logs attached above.

Thanks guys for your help!

team-XProduct bug untriaged

Most helpful comment

Is there any reason the Bazel build doesn't simply specify "//conditions:default": [":jni_md_header-linux"] for the JNI header within the select statements? It seems like this is the safest default to provide, rather than guaranteeing it will never build on something that was left out of the select statement.

I've been manually patching this myself for a while, and apparently so have dozens of other people. What is the downside to setting this as the default clause?

All 4 comments

I am having the same problem building, I set the
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-armhf
but it still fails

The only thing you need to make Bazel build on the Raspberry Pi is this fix by @redsigma. Have a look at my Bazel on ARM project for an easy-to-use build script and some recent binary releases I built.

Is there any reason the Bazel build doesn't simply specify "//conditions:default": [":jni_md_header-linux"] for the JNI header within the select statements? It seems like this is the safest default to provide, rather than guaranteeing it will never build on something that was left out of the select statement.

I've been manually patching this myself for a while, and apparently so have dozens of other people. What is the downside to setting this as the default clause?

The above hack solved the build issue on RPI 4B. Thanks!

Was this page helpful?
0 / 5 - 0 ratings