JDK14 cross-compile to arm64 fails with linking error

Choe, Jiwon jiwon_choe at brown.edu
Fri Oct 23 21:52:22 UTC 2020


Hi,


On Tue, Oct 20, 2020 at 5:26 AM Andrew Haley <aph at redhat.com> wrote:

> Hi,
>
> On 19/10/2020 03:53, Choe, Jiwon wrote:
>
> > I'm trying to cross-compile JDK 14 to target aarch64-linux-gnu, from a
> > 64-bit x86 Linux (Ubuntu 18.04).
> >
> > I followed the steps described in the documentation (
> >
> https://hg.openjdk.java.net/jdk/jdk14/raw-file/tip/doc/building.html#creating-and-using-sysroots-with-qemu-deboostrap
> ),
> > but when I try to make the target image, I get the following error:
> >
> >
> /usr/lib/gcc-cross/aarch64-linux-gnu/7/../../../../aarch64-linux-gnu/bin/ld:
> > /opt/sysroot/usr/lib/aarch64-linux-gnu/libm.a(e_pow.o): relocation
> > R_AARCH64_ADR_PREL_PG_HI21 against symbol `__stack_chk_guard@
> @GLIBC_2.17'
> > which may bind externally can not be used when making a shared object;
> > recompile with -fPIC
> >
> /usr/lib/gcc-cross/aarch64-linux-gnu/7/../../../../aarch64-linux-gnu/bin/ld:
> > /opt/sysroot/usr/lib/aarch64-linux-gnu/libm.a(e_pow.o)(.text+0xdc):
>
> ^ This looks wrong. You should be linking with /usr/whatever/libm.so, not
> /usr/whatever/libm.a. Is libm.so missing from that directory?
>


Thank you so much for pointing this out.  This was actually the issue.

/opt/sysroot/usr/lib/aarch64-linux-gnu/libm.so was linking to
/lib/aarch64-linux-gnu/libm.so.6,
but my machine didn't have the directory /lib/aarch64-linux-gnu.
(There were a whole bunch of other libraries that linked to some library
file in that location, too.)

On my machine, the libm.so.6 file for aarch64-linux-gnu was in
/usr/aarch64-linux-gnu/lib,
so I simply created a symlink from /lib/aarch64-linux-gnu to
/usr/aarch64-linux-gnu/lib, and the build ran perfectly.

(I'm sending this update so that if anyone runs into a similar issue in the
future, they can find this in the mailing list archive...)

Thanks again!
-Jiwon

>
> --
> Andrew Haley  (he/him)
> Java Platform Lead Engineer
> Red Hat UK Ltd. <https://www.redhat.com>
> https://keybase.io/andrewhaley
> EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671
>
>



More information about the build-dev mailing list