azul-research / jdk-riscv

GNU General Public License v2.0
3 stars 4 forks source link

OpenJDK zero build #7

Closed AntonKozlov closed 5 years ago

AntonKozlov commented 5 years ago

zero build for x86 (host).

To be combined #3 and get a first RISC-V working binary. Be able to start it emulator (#2)

AntonKozlov commented 5 years ago

May be useful: https://bugs.openjdk.java.net/browse/JDK-8199138

tsarn commented 5 years ago

I've managed to build it and it seems to work (takes more than a minute to run hello world, but whatever). I've documented everything here: https://github.com/azul-research/jdk-riscv/blob/zero-compiling/dev-riscv/docs/CROSS_COMPILING.md

Now we need somebody to create docker image with the toolchain and jdk's dependencies.

AntonKozlov commented 5 years ago

https://github.com/azul-research/jdk-riscv/blob/zero-compiling/dev-riscv/docs/CROSS_COMPILING.md

Wow, great! Dependencies up to "Building OpenJDK zero" will be required to cross-compilation too. I propose to persist them once and reuse.

A docker image with toolchain is good place to store these

tsarn commented 5 years ago

I dockerized toolchain with OpenJDK dependencies: https://github.com/azul-research/jdk-riscv/tree/riscv/dev-riscv/toolchain

AntonKozlov commented 5 years ago

Thank you!

A couple of notes:

  1. Can "Usage" section be a script? We could avoid copy-pasting commands
  2. I think not only JDK12/13 is missing in the image, but zip/unzip are as well
  3. Having JDK12/13 out-of-box would be nice. This way seems to work (even on debian) https://github.com/zulu-openjdk/zulu-openjdk/blob/2c23dc0d2b2366b5fcbb36db0fbc1714095f852a/13-latest/Dockerfile#L18
AntonKozlov commented 5 years ago

I see zero builds, great! Can you make a Pull Request after those minors fixed?

AntonKozlov commented 5 years ago

I see zero builds, great! Can you make a Pull Request after those minors fixed?

Sorry, I meant zero-compiling branch

AntonKozlov commented 5 years ago

Seems like cross-compiling environment and target emu-user are different. This leads to problems like

$ ./build/linux-riscv64-zero-release/jdk/bin/java -version
Error: dl failure on line 603
Error: failed /jdk/build/linux-riscv64-zero-release/jdk/lib/server/libjvm.so, because libffi.so.7: cannot open shared object file: No such file or directory

The problem is that for user-emu repos have only ffi.so.6

$ ldd /lib/riscv64-linux-gnu/libffi.so.6
    libc.so.6 => /lib/riscv64-linux-gnu/libc.so.6 (0x0000004000827000)
    /lib/ld-linux-riscv64-lp64d.so.1 (0x0000004000000000)
tsarn commented 5 years ago

This is solved by mounting /opt/riscv/sysroot and configuring the dynamic linker to look for libraries at appropriate locations.

AntonKozlov commented 5 years ago

This works!

$ docker ps
f2d86469ddb6        tsarn/riscv-toolchain
$ docker cp f2d86469ddb6:/opt/riscv/sysroot riscv-sysroot
cont$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/riscv-sysroot/usr/lib/
cont$ time ./build/linux-riscv64-zero-release/jdk/bin/java -version
openjdk version "13-internal" 2019-09-17
OpenJDK Runtime Environment (build 13-internal+0-adhoc..jdk)
OpenJDK 64-Bit Zero VM (build 13-internal+0-adhoc..jdk, interpreted mode)

real    1m48.637s
user    1m47.335s
sys 0m0.810s