diff --git a/doc/building.html b/doc/building.html index 4d5cdf67c3a..022b1d94899 100644 --- a/doc/building.html +++ b/doc/building.html @@ -76,7 +76,7 @@
  • Specifying the Target Platform
  • Toolchain Considerations
  • Native Libraries
  • -
  • Creating And Using Sysroots With qemu-deboostrap
  • +
  • Cross compiling with Debian sysroots
  • Building for ARM/aarch64
  • Building for musl
  • Verifying the Build
  • @@ -628,7 +628,7 @@ cp: cannot stat `arm-linux-gnueabihf/libSM.so': No such file or directory cp: cannot stat `arm-linux-gnueabihf/libXt.so': No such file or directory
  • If the X11 libraries are not properly detected by configure, you can point them out by --with-x.

  • -

    Creating And Using Sysroots With qemu-deboostrap

    +

    Cross compiling with Debian sysroots

    Fortunately, you can create sysroots for foreign architectures with tools provided by your OS. On Debian/Ubuntu systems, one could use qemu-deboostrap to create the target system chroot, which would have the native libraries and headers specific to that target system. After that, we can use the cross-compiler on the build system, pointing into chroot to get the build dependencies right. This allows building for foreign architectures with native compilation speed.

    For example, cross-compiling to AArch64 from x86_64 could be done like this:

    The build does not create new files in that chroot, so it can be reused for multiple builds without additional cleanup.

    +

    The build system should automatically detect the toolchain paths and dependencies, but sometimes it might require a little nudge with:

    +

    Architectures that are known to successfully cross-compile like this are:

    - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    TargetCCCXX--arch=...Debian treeDebian arch --openjdk-target=...--with-jvm-variants=...
    x86defaultdefaultbuster i386 i386-linux-gnu(all)
    armhfgcc-arm-linux-gnueabihfg++-arm-linux-gnueabihfarmbuster armhf arm-linux-gnueabihf(all)
    aarch64gcc-aarch64-linux-gnug++-aarch64-linux-gnubuster arm64 aarch64-linux-gnu(all)
    ppc64elgcc-powerpc64le-linux-gnug++-powerpc64le-linux-gnuppc64lebuster ppc64el powerpc64le-linux-gnu(all)
    s390xgcc-s390x-linux-gnug++-s390x-linux-gnubuster s390x s390x-linux-gnu(all)
    mipslebustermipselmipsel-linux-gnuzero
    mips64lebustermips64elmips64el-linux-gnueabi64zero
    armelbusterarmarm-linux-gnueabizero
    ppcsidpowerpcpowerpc-linux-gnuzero
    ppc64besidppc64powerpc64-linux-gnu(all)
    m68ksidm68km68k-linux-gnuzero
    alphasidalphaalpha-linux-gnuzero
    sh4sidsh4sh4-linux-gnuzero
    -

    Additional architectures might be supported by Debian/Ubuntu Ports.

    Building for ARM/aarch64

    A common cross-compilation target is the ARM CPU. When building for ARM, it is useful to set the ABI profile. A number of pre-defined ABI profiles are available using --with-abi-profile: arm-vfp-sflt, arm-vfp-hflt, arm-sflt, armv5-vfp-sflt, armv6-vfp-hflt. Note that soft-float ABIs are no longer properly supported by the JDK.

    Building for musl

    diff --git a/doc/building.md b/doc/building.md index 69b7fe640e8..766298d7d44 100644 --- a/doc/building.md +++ b/doc/building.md @@ -1089,7 +1089,7 @@ Note that X11 is needed even if you only want to build a headless JDK. * If the X11 libraries are not properly detected by `configure`, you can point them out by `--with-x`. -### Creating And Using Sysroots With qemu-deboostrap +### Cross compiling with Debian sysroots Fortunately, you can create sysroots for foreign architectures with tools provided by your OS. On Debian/Ubuntu systems, one could use `qemu-deboostrap` to @@ -1110,7 +1110,7 @@ For example, cross-compiling to AArch64 from x86_64 could be done like this: sudo qemu-debootstrap \ --arch=arm64 \ --verbose \ - --include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev \ + --include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev,libffi-dev \ --resolve-deps \ buster \ ~/sysroot-arm64 \ @@ -1124,13 +1124,9 @@ For example, cross-compiling to AArch64 from x86_64 could be done like this: * Configure and build with newly created chroot as sysroot/toolchain-path: ``` - CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ sh ./configure \ - --openjdk-target=aarch64-linux-gnu \ - --with-sysroot=~/sysroot-arm64 \ - --with-toolchain-path=~/sysroot-arm64 \ - --with-freetype-lib=~/sysroot-arm64/usr/lib/aarch64-linux-gnu/ \ - --with-freetype-include=~/sysroot-arm64/usr/include/freetype2/ \ - --x-libraries=~/sysroot-arm64/usr/lib/aarch64-linux-gnu/ + sh ./configure \ + --openjdk-target=aarch64-linux-gnu \ + --with-sysroot=~/sysroot-arm64 make images ls build/linux-aarch64-server-release/ ``` @@ -1138,17 +1134,34 @@ For example, cross-compiling to AArch64 from x86_64 could be done like this: The build does not create new files in that chroot, so it can be reused for multiple builds without additional cleanup. +The build system should automatically detect the toolchain paths and dependencies, but sometimes +it might require a little nudge with: + + * Native compilers: override `CC` or `CXX` for `./configure` + + * Freetype lib location: override `--with-freetype-lib`, for example `${sysroot}/usr/lib/${target}/` + + * Freetype includes location: override `--with-freetype-include` for example `${sysroot}/usr/include/freetype2/` + + * X11 libraries location: override `--x-libraries`, for example `${sysroot}/usr/lib/${target}/` + Architectures that are known to successfully cross-compile like this are: - Target `CC` `CXX` `--arch=...` `--openjdk-target=...` - ------------ ------------------------- --------------------------- ------------- ----------------------- - x86 default default i386 i386-linux-gnu - armhf gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf armhf arm-linux-gnueabihf - aarch64 gcc-aarch64-linux-gnu g++-aarch64-linux-gnu arm64 aarch64-linux-gnu - ppc64el gcc-powerpc64le-linux-gnu g++-powerpc64le-linux-gnu ppc64el powerpc64le-linux-gnu - s390x gcc-s390x-linux-gnu g++-s390x-linux-gnu s390x s390x-linux-gnu - -Additional architectures might be supported by Debian/Ubuntu Ports. + Target Debian tree Debian arch `--openjdk-target=...` `--with-jvm-variants=...` + ------------ ------------ ------------- ------------------------ -------------- + x86 buster i386 i386-linux-gnu (all) + arm buster armhf arm-linux-gnueabihf (all) + aarch64 buster arm64 aarch64-linux-gnu (all) + ppc64le buster ppc64el powerpc64le-linux-gnu (all) + s390x buster s390x s390x-linux-gnu (all) + mipsle buster mipsel mipsel-linux-gnu zero + mips64le buster mips64el mips64el-linux-gnueabi64 zero + armel buster arm arm-linux-gnueabi zero + ppc sid powerpc powerpc-linux-gnu zero + ppc64be sid ppc64 powerpc64-linux-gnu (all) + m68k sid m68k m68k-linux-gnu zero + alpha sid alpha alpha-linux-gnu zero + sh4 sid sh4 sh4-linux-gnu zero ### Building for ARM/aarch64