1 # 2 # Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 # 5 # This code is free software; you can redistribute it and/or modify it 6 # under the terms of the GNU General Public License version 2 only, as 7 # published by the Free Software Foundation. Oracle designates this 8 # particular file as subject to the "Classpath" exception as provided 9 # by Oracle in the LICENSE file that accompanied this code. 10 # 11 # This code is distributed in the hope that it will be useful, but WITHOUT 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 # version 2 for more details (a copy is included in the LICENSE file that 15 # accompanied this code). 16 # 17 # You should have received a copy of the GNU General Public License version 18 # 2 along with this work; if not, write to the Free Software Foundation, 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 # 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 # or visit www.oracle.com if you need additional information or have any 23 # questions. 24 # 25 26 name: 'Build (cross-compile)' 27 28 on: 29 workflow_call: 30 inputs: 31 gcc-major-version: 32 required: true 33 type: string 34 apt-gcc-version: 35 required: true 36 type: string 37 apt-gcc-cross-version: 38 required: true 39 type: string 40 extra-conf-options: 41 required: false 42 type: string 43 configure-arguments: 44 required: false 45 type: string 46 make-arguments: 47 required: false 48 type: string 49 50 jobs: 51 build-cross-compile: 52 name: build 53 runs-on: ubuntu-22.04 54 55 strategy: 56 fail-fast: false 57 matrix: 58 target-cpu: 59 - aarch64 60 - arm 61 include: 62 - target-cpu: aarch64 63 gnu-arch: aarch64 64 debian-arch: arm64 65 debian-repository: https://httpredir.debian.org/debian/ 66 debian-version: bullseye 67 - target-cpu: arm 68 gnu-arch: arm 69 debian-arch: armhf 70 debian-repository: https://httpredir.debian.org/debian/ 71 debian-version: bullseye 72 gnu-abi: eabihf 73 74 steps: 75 - name: 'Checkout the JDK source' 76 uses: actions/checkout@v3 77 78 - name: 'Get the BootJDK' 79 id: bootjdk 80 uses: ./.github/actions/get-bootjdk 81 with: 82 platform: linux-x64 83 84 # Use linux-x64 JDK bundle as build JDK 85 - name: 'Get build JDK' 86 id: buildjdk 87 uses: ./.github/actions/get-bundles 88 with: 89 platform: linux-x64 90 91 # Upgrading apt to solve libc6 installation bugs, see JDK-8260460. 92 - name: 'Install toolchain and dependencies' 93 run: | 94 # Install dependencies using apt-get 95 sudo apt-get update 96 sudo apt-get install --only-upgrade apt 97 sudo apt-get install \ 98 gcc-${{ inputs.gcc-major-version }}=${{ inputs.apt-gcc-version }} \ 99 g++-${{ inputs.gcc-major-version }}=${{ inputs.apt-gcc-version }} \ 100 gcc-${{ inputs.gcc-major-version }}-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}=${{ inputs.apt-gcc-cross-version }} \ 101 g++-${{ inputs.gcc-major-version }}-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}=${{ inputs.apt-gcc-cross-version }} \ 102 libxrandr-dev libxtst-dev libcups2-dev libasound2-dev \ 103 debian-ports-archive-keyring 104 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ inputs.gcc-major-version }} 100 --slave /usr/bin/g++ g++ /usr/bin/g++-${{ inputs.gcc-major-version }} 105 106 - name: 'Check cache for sysroot' 107 id: get-cached-sysroot 108 uses: actions/cache@v3 109 with: 110 path: sysroot 111 key: sysroot-${{ matrix.debian-arch }}-${{ hashFiles('./.github/workflows/build-cross-compile.yml') }} 112 113 - name: 'Install sysroot dependencies' 114 run: sudo apt-get install debootstrap qemu-user-static 115 if: steps.get-cached-sysroot.outputs.cache-hit != 'true' 116 117 - name: 'Create sysroot' 118 run: > 119 sudo debootstrap 120 --arch=${{ matrix.debian-arch }} 121 --verbose 122 --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 123 --resolve-deps 124 $(test -n "${{ matrix.debian-keyring }}" && echo "--keyring=${{ matrix.debian-keyring }}") 125 ${{ matrix.debian-version }} 126 sysroot 127 ${{ matrix.debian-repository }} 128 if: steps.get-cached-sysroot.outputs.cache-hit != 'true' 129 130 - name: 'Prepare sysroot' 131 run: | 132 # Prepare sysroot and remove unused files to minimize cache 133 sudo chroot sysroot symlinks -cr . 134 sudo chown ${USER} -R sysroot 135 rm -rf sysroot/{dev,proc,run,sys,var} 136 rm -rf sysroot/usr/{sbin,bin,share} 137 rm -rf sysroot/usr/lib/{apt,udev,systemd} 138 if: steps.get-cached-sysroot.outputs.cache-hit != 'true' 139 140 - name: 'Configure' 141 run: > 142 bash configure 143 --with-conf-name=linux-${{ matrix.target-cpu }} 144 --with-version-opt=${GITHUB_ACTOR}-${GITHUB_SHA} 145 --with-boot-jdk=${{ steps.bootjdk.outputs.path }} 146 --with-zlib=system 147 --enable-debug 148 --disable-precompiled-headers 149 --openjdk-target=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}} 150 --with-sysroot=sysroot 151 --with-build-jdk=${{ steps.buildjdk.outputs.jdk-path }} 152 --with-jmod-compress=zip-1 153 CC=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}-gcc-${{ inputs.gcc-major-version }} 154 CXX=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}-g++-${{ inputs.gcc-major-version }} 155 ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( 156 echo "Dumping config.log:" && 157 cat config.log && 158 exit 1) 159 160 - name: 'Build' 161 id: build 162 uses: ./.github/actions/do-build 163 with: 164 make-target: 'hotspot ${{ inputs.make-arguments }}' 165 platform: linux-${{ matrix.target-cpu }}