1016 ``` |
1016 ``` |
1017 |
1017 |
1018 * If the X11 libraries are not properly detected by `configure`, you can |
1018 * If the X11 libraries are not properly detected by `configure`, you can |
1019 point them out by `--with-x`. |
1019 point them out by `--with-x`. |
1020 |
1020 |
|
1021 ### Creating And Using Sysroots With qemu-deboostrap |
|
1022 |
|
1023 Fortunately, you can create sysroots for foreign architectures with tools |
|
1024 provided by your OS. On Debian/Ubuntu systems, one could use `qemu-deboostrap` to |
|
1025 create the *target* system chroot, which would have the native libraries and headers |
|
1026 specific to that *target* system. After that, we can use the cross-compiler on the *build* |
|
1027 system, pointing into chroot to get the build dependencies right. This allows building |
|
1028 for foreign architectures with native compilation speed. |
|
1029 |
|
1030 For example, cross-compiling to AArch64 from x86_64 could be done like this: |
|
1031 |
|
1032 * Install cross-compiler on the *build* system: |
|
1033 ``` |
|
1034 apt install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu |
|
1035 ``` |
|
1036 |
|
1037 * Create chroot on the *build* system, configuring it for *target* system: |
|
1038 ``` |
|
1039 sudo qemu-debootstrap --arch=arm64 --verbose \ |
|
1040 --include=fakeroot,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng12-dev \ |
|
1041 --resolve-deps jessie /chroots/arm64 http://httpredir.debian.org/debian/ |
|
1042 ``` |
|
1043 |
|
1044 * Configure and build with newly created chroot as sysroot/toolchain-path: |
|
1045 ``` |
|
1046 CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ sh ./configure --openjdk-target=aarch64-linux-gnu --with-sysroot=/chroots/arm64/ --with-toolchain-path=/chroots/arm64/ |
|
1047 make images |
|
1048 ls build/linux-aarch64-normal-server-release/ |
|
1049 ``` |
|
1050 |
|
1051 The build does not create new files in that chroot, so it can be reused for multiple builds |
|
1052 without additional cleanup. |
|
1053 |
|
1054 Architectures that are known to successfully cross-compile like this are: |
|
1055 |
|
1056 Target `CC` `CXX` `--arch=...` `--openjdk-target=...` |
|
1057 ------------ ------------------------- --------------------------- ------------ ---------------------- |
|
1058 x86 default default i386 i386-linux-gnu |
|
1059 armhf gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf armhf arm-linux-gnueabihf |
|
1060 aarch64 gcc-aarch64-linux-gnu g++-aarch64-linux-gnu arm64 aarch64-linux-gnu |
|
1061 ppc64el gcc-powerpc64le-linux-gnu g++-powerpc64le-linux-gnu ppc64el powerpc64le-linux-gnu |
|
1062 s390x gcc-s390x-linux-gnu g++-s390x-linux-gnu s390x s390x-linux-gnu |
|
1063 |
|
1064 Additional architectures might be supported by Debian/Ubuntu Ports. |
|
1065 |
1021 ### Building for ARM/aarch64 |
1066 ### Building for ARM/aarch64 |
1022 |
1067 |
1023 A common cross-compilation target is the ARM CPU. When building for ARM, it is |
1068 A common cross-compilation target is the ARM CPU. When building for ARM, it is |
1024 useful to set the ABI profile. A number of pre-defined ABI profiles are |
1069 useful to set the ABI profile. A number of pre-defined ABI profiles are |
1025 available using `--with-abi-profile`: arm-vfp-sflt, arm-vfp-hflt, arm-sflt, |
1070 available using `--with-abi-profile`: arm-vfp-sflt, arm-vfp-hflt, arm-sflt, |