Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
codeNick7 opened this issue Jul 4, 2020 · 4 comments
Labels
team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug untriaged

Comments

@codeNick7
Copy link

codeNick7 commented Jul 4, 2020

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 bazel-discuss@googlegroups.com
  • 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: #10746

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

Logs attached above.

Thanks guys for your help!

@greenpdx
Copy link

greenpdx commented Jul 5, 2020

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

@gregestren gregestren added team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug untriaged labels Jul 6, 2020
@koenvervloesem
Copy link

koenvervloesem commented Jul 7, 2020

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.

@james-stephenson
Copy link

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?

@codeNick7
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug untriaged
Projects
None yet
Development

No branches or pull requests

5 participants