JDK14 cross-compile to arm64 fails with linking error

David Holmes david.holmes at oracle.com
Mon Oct 19 21:25:51 UTC 2020


Hi,

On 19/10/2020 12:53 pm, Choe, Jiwon wrote:
> Hello all,
> 
> 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

It appears to me that your sysroot contains static libraries that are 
incompatible with the link settings for the dynamic library you are 
trying to build. But that is just a guess.

Cheers,
David

> /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):
> unresolvable R_AARCH64_ADR_PREL_PG_HI21 relocation against symbol
> `__stack_chk_guard@@GLIBC_2.17'
> /usr/lib/gcc-cross/aarch64-linux-gnu/7/../../../../aarch64-linux-gnu/bin/ld:
> final link failed: Bad value
> collect2: error: ld returned 1 exit status
> Awt2dLibraries.gmk:597: recipe for target
> '/home/jiwon/jdk14/build/linux-aarch64-server-release/support/modules_libs/java.desktop/libfontmanager.so'
> failed
> make[3]: ***
> [/home/jiwon/jdk14/build/linux-aarch64-server-release/support/modules_libs/java.desktop/libfontmanager.so]
> Error 1
> make/Main.gmk:211: recipe for target 'java.desktop-libs' failed
> make[2]: *** [java.desktop-libs] Error 2
> 
> 
> Could anyone familiar with this issue help me out on fixing it? If this
> should be sent to a different mailing list, please let me know.
> 
> I have pasted the parameters and output from the configuration step below,
> in case that will be needed.
> 
> Thanks,
> Jiwon
> 
> 
> 
>  From configure:
> 
> $ CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ bash configure
> --openjdk-target=aarch64-linux-gnu --with-boot-jdk=/opt/jdk-13.0.2
> --with-build-jdk=build/linux-x86_64-server-release/images/jdk
> --with-sysroot=/opt/sysroot --with-toolchain-path=/opt/sysroot
> --with-stdc++lib=static
> configure: Configuration created at Tue Oct  6 20:18:38 EDT 2020.
> checking for basename... /usr/bin/basename
> checking for bash... /bin/bash
> checking for cat... /bin/cat
> checking for chmod... /bin/chmod
> checking for cmp... /usr/bin/cmp
> checking for comm... /usr/bin/comm
> checking for cp... /bin/cp
> checking for cut... /usr/bin/cut
> checking for date... /bin/date
> checking for gdiff... no
> checking for diff... /usr/bin/diff
> checking for dirname... /usr/bin/dirname
> checking for echo... /bin/echo
> checking for expr... /usr/bin/expr
> checking for file... /usr/bin/file
> checking for find... /usr/bin/find
> checking for head... /usr/bin/head
> checking for gunzip... /bin/gunzip
> checking for pigz... no
> checking for gzip... /bin/gzip
> checking for ln... /bin/ln
> checking for ls... /bin/ls
> checking for gmkdir... no
> checking for mkdir... /bin/mkdir
> checking for mktemp... /bin/mktemp
> checking for mv... /bin/mv
> checking for nawk... /usr/bin/nawk
> checking for printf... /usr/bin/printf
> checking for greadlink... no
> checking for readlink... /bin/readlink
> checking for rm... /bin/rm
> checking for rmdir... /bin/rmdir
> checking for sh... /bin/sh
> checking for sort... /usr/bin/sort
> checking for tail... /usr/bin/tail
> checking for gtar... no
> checking for tar... /bin/tar
> checking for tee... /usr/bin/tee
> checking for touch... /usr/bin/touch
> checking for tr... /usr/bin/tr
> checking for uname... /bin/uname
> checking for uniq... /usr/bin/uniq
> checking for wc... /usr/bin/wc
> checking for which... /usr/bin/which
> checking for xargs... /usr/bin/xargs
> checking for gawk... no
> checking for mawk... mawk
> checking for grep that handles long lines and -e... /bin/grep
> checking for egrep... /bin/grep -E
> checking for fgrep... /bin/grep -F
> checking for a sed that does not truncate output... /bin/sed
> checking for cygpath... no
> checking for wslpath... no
> checking for df... /bin/df
> checking for cpio... /bin/cpio
> checking for nice... /usr/bin/nice
> checking for lsb_release... /usr/bin/lsb_release
> checking for cmd.exe... no
> checking for /mnt/c/Windows/System32/cmd.exe... no
> checking build system type... x86_64-unknown-linux-gnu
> checking host system type... aarch64-unknown-linux-gnu
> checking target system type... aarch64-unknown-linux-gnu
> checking openjdk-build os-cpu... linux-x86_64
> checking openjdk-target os-cpu... linux-aarch64
> checking compilation type... cross
> checking for top-level directory... /home/jiwon/jdk14
> checking if custom source is suppressed (openjdk-only)... no
> checking which debug level to use... release
> checking which variants of the JVM to build... server
> checking for sysroot... /opt/sysroot
> checking for toolchain path... /opt/sysroot
> checking for extra path...
> checking where to store configuration... in default location
> checking what configuration name to use... linux-aarch64-server-release
> checking for zypper... no
> checking for apt-get... apt-get
> checking for pandoc... no
> checking for gmake... no
> checking for make... /usr/bin/make
> configure: Testing potential make at /usr/bin/make, found using make in PATH
> configure: Using GNU make at /usr/bin/make (version: GNU Make 4.1)
> checking if make --output-sync is supported... yes
> checking for output-sync value... none
> checking if find supports -delete... yes
> checking what type of tar was found... gnu
> checking that grep (/bin/grep) -Fx handles empty lines in the pattern list
> correctly... yes
> checking for unzip... /usr/bin/unzip
> checking for zip... /usr/bin/zip
> checking for ldd... /usr/bin/ldd
> checking for greadelf... no
> checking for readelf... /usr/bin/readelf
> checking for dot... no
> checking for hg... /usr/bin/hg
> checking for git... no
> checking for stat... /usr/bin/stat
> checking for time... /usr/bin/time
> checking for flock... /usr/bin/flock
> checking for dtrace... no
> checking for gpatch... no
> checking for patch... /usr/bin/patch
> checking for ulimit... no
> configure: Required tool ulimit not found in PATH, checking built-in
> configure: Found ulimit as shell built-in. Using it
> checking bash version... 4.4.20
> checking if bash supports pipefail... yes
> checking if bash supports errexit (-e)... yes
> checking for aarch64-linux-gnu-pkg-config...
> /usr/bin/aarch64-linux-gnu-pkg-config
> checking pkg-config is at least version 0.9.0... yes
> checking for default LOG value...
> checking headless only... no
> checking for graphviz dot... no, cannot generate full docs
> checking for pandoc... no, cannot generate full docs
> checking full docs... no, missing dependencies
> checking for cacerts file... default
> checking for jni library path... default
> checking if packaged modules are kept... yes (default)
> checking for version string... 14-internal+0-adhoc.jiwon.jdk14
> configure: Found potential Boot JDK using configure arguments
> checking for Boot JDK... /opt/jdk-13.0.2
> checking Boot JDK version... java version "13.0.2" 2020-01-14 Java(TM) SE
> Runtime Environment (build 13.0.2+8) Java HotSpot(TM) 64-Bit Server VM
> (build 13.0.2+8, mixed mode, sharing)
> checking for java in Boot JDK... ok
> checking for javac in Boot JDK... ok
> checking for javadoc in Boot JDK... ok
> checking for jar in Boot JDK... ok
> checking for jarsigner in Boot JDK... ok
> checking if Boot JDK is 32 or 64 bits... 64
> checking for local Boot JDK Class Data Sharing (CDS)... yes, created
> configure: Found potential Build JDK using configure arguments
> checking for Build JDK...
> /home/jiwon/jdk14/build/linux-x86_64-server-release/images/jdk
> checking Build JDK version... openjdk version "14-internal" 2020-03-17
> OpenJDK Runtime Environment (build 14-internal+0-adhoc.jiwon.jdk14) OpenJDK
> 64-Bit Server VM (build 14-internal+0-adhoc.jiwon.jdk14, mixed mode,
> sharing)
> configure: Using default toolchain gcc (GNU Compiler Collection)
> configure: Will use user supplied compiler CC=aarch64-linux-gnu-gcc
> checking for aarch64-linux-gnu-gcc... /usr/bin/aarch64-linux-gnu-gcc
> checking resolved symbolic links for CC... /usr/bin/aarch64-linux-gnu-gcc-7
> configure: Using gcc C compiler version 7.5.0 [aarch64-linux-gnu-gcc
> (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) 7.5.0]
> checking for aarch64-linux-gnu-/usr/bin/aarch64-linux-gnu-gcc...
> /usr/bin/aarch64-linux-gnu-gcc
> checking whether the C compiler works... yes
> checking for C compiler default output file name... a.out
> checking for suffix of executables...
> checking whether we are cross compiling... yes
> checking for suffix of object files... o
> checking whether we are using the GNU C compiler... yes
> checking whether /usr/bin/aarch64-linux-gnu-gcc accepts -g... yes
> checking for /usr/bin/aarch64-linux-gnu-gcc option to accept ISO C89...
> none needed
> configure: Will use user supplied compiler CXX=aarch64-linux-gnu-g++
> checking for aarch64-linux-gnu-g++... /usr/bin/aarch64-linux-gnu-g++
> checking resolved symbolic links for CXX... /usr/bin/aarch64-linux-gnu-g++-7
> configure: Using gcc C++ compiler version 7.5.0 [aarch64-linux-gnu-g++
> (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) 7.5.0]
> checking whether we are using the GNU C++ compiler... yes
> checking whether /usr/bin/aarch64-linux-gnu-g++ accepts -g... yes
> checking how to run the C preprocessor... /usr/bin/aarch64-linux-gnu-gcc -E
> checking how to run the C++ preprocessor... /usr/bin/aarch64-linux-gnu-g++
> -E
> checking for aarch64-linux-gnu-ld... aarch64-linux-gnu-ld
> configure: Rewriting LD_JAOTC to "/usr/bin/aarch64-linux-gnu-ld"
> configure: Using gcc linker version 2.30 [GNU ld (GNU Binutils for Ubuntu)
> 2.30]
> checking for aarch64-linux-gnu-ar... aarch64-linux-gnu-ar
> configure: Rewriting AR to "/usr/bin/aarch64-linux-gnu-ar"
> checking for aarch64-linux-gnu-strip... aarch64-linux-gnu-strip
> configure: Rewriting STRIP to "/usr/bin/aarch64-linux-gnu-strip"
> checking for aarch64-linux-gnu-nm... aarch64-linux-gnu-nm
> configure: Rewriting NM to "/usr/bin/aarch64-linux-gnu-nm"
> checking for aarch64-linux-gnu-gobjcopy... no
> checking for aarch64-linux-gnu-objcopy... aarch64-linux-gnu-objcopy
> configure: Rewriting OBJCOPY to "/usr/bin/aarch64-linux-gnu-objcopy"
> checking for aarch64-linux-gnu-gobjdump... no
> checking for aarch64-linux-gnu-objdump... aarch64-linux-gnu-objdump
> configure: Rewriting OBJDUMP to "/usr/bin/aarch64-linux-gnu-objdump"
> checking for aarch64-linux-gnu-c++filt... aarch64-linux-gnu-c++filt
> configure: Rewriting CXXFILT to "/usr/bin/aarch64-linux-gnu-c++filt"
> checking for cl... no
> checking for cc... /usr/bin/cc
> checking for cl... no
> checking for CC... no
> checking for g++... /usr/bin/g++
> checking for nm... /usr/bin/nm
> checking for ar... /usr/bin/ar
> checking for objcopy... /usr/bin/objcopy
> checking for strip... /usr/bin/strip
> configure: Using gcc BuildC compiler version 7.5.0 [cc (Ubuntu
> 7.5.0-3ubuntu1~18.04) 7.5.0]
> configure: Using gcc BuildC++ compiler version 7.5.0 [g++ (Ubuntu
> 7.5.0-3ubuntu1~18.04) 7.5.0]
> configure: Using gcc build linker version 2.30 [GNU ld (GNU Binutils for
> Ubuntu) 2.30]
> checking for jtreg... no
> checking for jtreg test harness... no, not found
> checking for jmh (Java Microbenchmark Harness)... no, disabled
> checking for jib... no
> checking if @file is supported by gcc... yes
> checking if CC supports "-m64"... no
> checking if CXX supports "-m64"... no
> checking if both CC and CXX support "-m64"... no
> checking for ANSI C header files... yes
> checking for sys/types.h... yes
> checking for sys/stat.h... yes
> checking for stdlib.h... yes
> checking for string.h... yes
> checking for memory.h... yes
> checking for strings.h... yes
> checking for inttypes.h... yes
> checking for stdint.h... yes
> checking for unistd.h... yes
> checking stdio.h usability... yes
> checking stdio.h presence... yes
> checking for stdio.h... yes
> checking size of int *... 8
> checking for target address size... 64 bits
> checking whether byte ordering is bigendian... no
> checking if native warnings are errors... true (default)
> checking for library containing clock_gettime... none required
> checking if CC supports "-Xassembler -mrelax-relocations=no"... no
> checking if CXX supports "-Xassembler -mrelax-relocations=no"... no
> checking if both CC and CXX support "-Xassembler -mrelax-relocations=no"...
> no
> checking if CXX supports "-std=gnu++98 -Werror"... yes
> checking if CC supports "-fno-delete-null-pointer-checks -Werror"... yes
> checking if CXX supports "-fno-delete-null-pointer-checks -Werror"... yes
> checking if both CC and CXX support "-fno-delete-null-pointer-checks
> -Werror"... yes
> checking if CC supports "-fno-lifetime-dse -Werror"... yes
> checking if CXX supports "-fno-lifetime-dse -Werror"... yes
> checking if both CC and CXX support "-fno-lifetime-dse -Werror"... yes
> checking if CC supports "-fmacro-prefix-map=/home/jiwon/jdk14/="... no
> checking if CXX supports "-fmacro-prefix-map=/home/jiwon/jdk14/="... no
> checking if both CC and CXX support
> "-fmacro-prefix-map=/home/jiwon/jdk14/="... no
> checking if CC supports "-ffp-contract=off"... yes
> checking if CXX supports "-ffp-contract=off"... yes
> checking if both CC and CXX support "-ffp-contract=off"... yes
> checking if BUILD_CXX supports "-std=gnu++98 -Werror"... yes
> checking if BUILD_CC supports "-fno-delete-null-pointer-checks -Werror"...
> yes
> checking if BUILD_CXX supports "-fno-delete-null-pointer-checks -Werror"...
> yes
> checking if both BUILD_CC and BUILD_CXX support
> "-fno-delete-null-pointer-checks -Werror"... yes
> checking if BUILD_CC supports "-fno-lifetime-dse -Werror"... yes
> checking if BUILD_CXX supports "-fno-lifetime-dse -Werror"... yes
> checking if both BUILD_CC and BUILD_CXX support "-fno-lifetime-dse
> -Werror"... yes
> checking if BUILD_CC supports "-fmacro-prefix-map=/home/jiwon/jdk14/="... no
> checking if BUILD_CXX supports "-fmacro-prefix-map=/home/jiwon/jdk14/="...
> no
> checking if both BUILD_CC and BUILD_CXX support
> "-fmacro-prefix-map=/home/jiwon/jdk14/="... no
> checking if BUILD_CC supports "-ffp-contract=off"... yes
> checking if BUILD_CXX supports "-ffp-contract=off"... yes
> checking if both BUILD_CC and BUILD_CXX support "-ffp-contract=off"... yes
> checking what type of native debug symbols to use... external
> checking for dtrace tool... not found, cannot build dtrace
> checking sys/sdt.h usability... no
> checking sys/sdt.h presence... no
> checking for sys/sdt.h... no
> checking if dtrace should be built... no, missing dependencies
> checking if Hotspot gtest unit tests should be built... yes
> checking if static link of stdc++ is possible... yes
> checking how to link with libstdc++... static
> checking for X... libraries , headers /opt/sysroot/usr/include
> checking for gethostbyname... yes
> checking for connect... yes
> checking for remove... yes
> checking for shmat... yes
> checking for IceConnectionNumber in -lICE... yes
> checking for X11/extensions/shape.h... yes
> checking for X11/extensions/Xrender.h... yes
> checking for X11/extensions/XTest.h... yes
> checking for X11/Intrinsic.h... yes
> checking for X11/extensions/Xrandr.h... yes
> checking if XlinearGradient is defined in Xrender.h... yes
> checking cups/cups.h usability... yes
> checking cups/cups.h presence... yes
> checking for cups/cups.h... yes
> checking cups/ppd.h usability... yes
> checking cups/ppd.h presence... yes
> checking for cups/ppd.h... yes
> checking fontconfig/fontconfig.h usability... yes
> checking fontconfig/fontconfig.h presence... yes
> checking for fontconfig/fontconfig.h... yes
> configure: Found freetype include files at
> /opt/sysroot/usr/include/freetype2 using well-known location
> configure: Could not find /opt/sysroot/usr/lib/libfreetype.so. Ignoring
> location.
> configure: Found freetype include files at
> /opt/sysroot/usr/include/freetype2 using well-known location
> checking for freetype includes... /opt/sysroot/usr/include/freetype2
> checking for freetype libraries... /opt/sysroot/usr/lib/aarch64-linux-gnu
> Using freetype: system
> checking alsa/asoundlib.h usability... yes
> checking alsa/asoundlib.h presence... yes
> checking for alsa/asoundlib.h... yes
> checking for which libjpeg to use... bundled
> checking for which giflib to use... bundled
> checking for PNG... no
> checking for which libpng to use... bundled
> checking for compress in -lz... yes
> checking for which zlib to use... system
> checking for system zlib functionality... ok
> checking for which lcms to use... bundled
> checking for cos in -lm... yes
> checking for dlopen in -ldl... yes
> checking if shenandoah can be built... yes
> checking if zgc can be built... yes
> checking if jvmci module jdk.internal.vm.ci should be built... yes
> checking if graal module jdk.internal.vm.compiler should be built... yes
> checking if aot should be enabled... yes
> checking if cds should be enabled... yes
> checking if elliptic curve crypto implementation is present... yes
> checking if jtreg failure handler should be built... no, missing jtreg
> checking if the CDS classlist generation should be enabled... yes
> checking if any translations should be excluded... no
> checking if static man pages should be copied... yes
> checking if a default CDS archive should be generated... no, not possible
> with cross compilation
> checking for number of cores... 1
> checking for memory size... 3936 MB
> checking for appropriate number of jobs to run in parallel... 1
> checking flags for boot jdk java command ...  -Duser.language=en
> -Duser.country=US  -XX:+UnlockDiagnosticVMOptions -XX:-VerifySharedSpaces
> -XX:SharedArchiveFile=/home/jiwon/jdk14/build/linux-aarch64-server-release/configure-support/classes.jsa
> -Xshare:auto
> checking flags for boot jdk java command for big workloads...  -Xms64M
> -Xmx1600M -XX:ThreadStackSize=1536
> checking flags for bootcycle boot jdk java command for big workloads...
> -Xms64M -Xmx1600M -XX:ThreadStackSize=1536
> checking flags for boot jdk java command for small workloads...
>   -XX:+UseSerialGC -Xms32M -Xmx512M -XX:TieredStopAtLevel=1
> checking whether to use sjavac... no
> checking whether to use javac server... yes
> checking If precompiled header is enabled... yes
> checking that precompiled headers work... yes
> checking is ccache enabled... no
> checking if build directory is on local disk... yes
> checking JVM features for JVM variant 'server'... "aot cds compiler1
> compiler2 epsilongc g1gc graal jfr jni-check jvmci jvmti management nmt
> parallelgc serialgc services shenandoahgc vm-structs zgc"
> configure: creating
> /home/jiwon/jdk14/build/linux-aarch64-server-release/configure-support/config.status
> config.status: creating
> /home/jiwon/jdk14/build/linux-aarch64-server-release/spec.gmk
> config.status: creating
> /home/jiwon/jdk14/build/linux-aarch64-server-release/bootcycle-spec.gmk
> config.status: creating
> /home/jiwon/jdk14/build/linux-aarch64-server-release/buildjdk-spec.gmk
> config.status: creating
> /home/jiwon/jdk14/build/linux-aarch64-server-release/compare.sh
> config.status: creating
> /home/jiwon/jdk14/build/linux-aarch64-server-release/Makefile
> 
> ====================================================
> A new configuration has been successfully created in
> /home/jiwon/jdk14/build/linux-aarch64-server-release
> using configure arguments '--openjdk-target=aarch64-linux-gnu
> --with-boot-jdk=/opt/jdk-13.0.2
> --with-build-jdk=build/linux-x86_64-server-release/images/jdk
> --with-sysroot=/opt/sysroot --with-toolchain-path=/opt/sysroot
> --with-stdc++lib=static'.
> 
> Configuration summary:
> * Debug level:    release
> * HS debug level: product
> * JVM variants:   server
> * JVM features:   server: 'aot cds compiler1 compiler2 epsilongc g1gc graal
> jfr jni-check jvmci jvmti management nmt parallelgc serialgc services
> shenandoahgc vm-structs zgc'
> * OpenJDK target: OS: linux, CPU architecture: aarch64, address length: 64
> * Version string: 14-internal+0-adhoc.jiwon.jdk14 (14-internal)
> 
> Tools summary:
> * Boot JDK:       java version "13.0.2" 2020-01-14 Java(TM) SE Runtime
> Environment (build 13.0.2+8) Java HotSpot(TM) 64-Bit Server VM (build
> 13.0.2+8, mixed mode, sharing)  (at /opt/jdk-13.0.2)
> * Toolchain:      gcc (GNU Compiler Collection)
> * C Compiler:     Version 7.5.0 (at /usr/bin/aarch64-linux-gnu-gcc)
> * C++ Compiler:   Version 7.5.0 (at /usr/bin/aarch64-linux-gnu-g++)
> 
> Build performance summary:
> * Cores to use:   1
> * Memory limit:   3936 MB
> 



More information about the build-dev mailing list