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 - s390x 62 - ppc64le 63 - riscv64 64 include: 65 - target-cpu: aarch64 66 gnu-arch: aarch64 67 debian-arch: arm64 68 debian-repository: https://httpredir.debian.org/debian/ 69 debian-version: bullseye 70 - target-cpu: arm 71 gnu-arch: arm 72 debian-arch: armhf 73 debian-repository: https://httpredir.debian.org/debian/ 74 debian-version: bullseye 75 gnu-abi: eabihf 76 - target-cpu: s390x 77 gnu-arch: s390x 78 debian-arch: s390x 79 debian-repository: https://httpredir.debian.org/debian/ 80 debian-version: bullseye 81 - target-cpu: ppc64le 82 gnu-arch: powerpc64le 83 debian-arch: ppc64el 84 debian-repository: https://httpredir.debian.org/debian/ 85 debian-version: bullseye 86 - target-cpu: riscv64 87 gnu-arch: riscv64 88 debian-arch: riscv64 89 debian-repository: https://httpredir.debian.org/debian/ 90 debian-version: sid 91 92 steps: 93 - name: 'Checkout the JDK source' 94 uses: actions/checkout@v3 95 96 - name: 'Get the BootJDK' 97 id: bootjdk 98 uses: ./.github/actions/get-bootjdk 99 with: 100 platform: linux-x64 101 102 # Use linux-x64 JDK bundle as build JDK 103 - name: 'Get build JDK' 104 id: buildjdk 105 uses: ./.github/actions/get-bundles 106 with: 107 platform: linux-x64 108 109 # Upgrading apt to solve libc6 installation bugs, see JDK-8260460. 110 - name: 'Install toolchain and dependencies' 111 run: | 112 # Install dependencies using apt-get 113 sudo apt-get update 114 sudo apt-get install --only-upgrade apt 115 sudo apt-get install \ 116 gcc-${{ inputs.gcc-major-version }}=${{ inputs.apt-gcc-version }} \ 117 g++-${{ inputs.gcc-major-version }}=${{ inputs.apt-gcc-version }} \ 118 gcc-${{ inputs.gcc-major-version }}-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}=${{ inputs.apt-gcc-cross-version }} \ 119 g++-${{ inputs.gcc-major-version }}-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}=${{ inputs.apt-gcc-cross-version }} \ 120 libxrandr-dev libxtst-dev libcups2-dev libasound2-dev \ 121 debian-ports-archive-keyring 122 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 }} 123 124 - name: 'Check cache for sysroot' 125 id: get-cached-sysroot 126 uses: actions/cache@v3 127 with: 128 path: sysroot 129 key: sysroot-${{ matrix.debian-arch }}-${{ hashFiles('./.github/workflows/build-cross-compile.yml') }} 130 131 - name: 'Install sysroot dependencies' 132 run: sudo apt-get install debootstrap qemu-user-static 133 if: steps.get-cached-sysroot.outputs.cache-hit != 'true' 134 135 - name: 'Create sysroot' 136 run: > 137 sudo debootstrap 138 --arch=${{ matrix.debian-arch }} 139 --verbose 140 --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 141 --resolve-deps 142 --variant=minbase 143 $(test -n "${{ matrix.debian-keyring }}" && echo "--keyring=${{ matrix.debian-keyring }}") 144 ${{ matrix.debian-version }} 145 sysroot 146 ${{ matrix.debian-repository }} 147 if: steps.get-cached-sysroot.outputs.cache-hit != 'true' 148 149 - name: 'Prepare sysroot' 150 run: | 151 # Prepare sysroot and remove unused files to minimize cache 152 sudo chroot sysroot symlinks -cr . 153 sudo chown ${USER} -R sysroot 154 rm -rf sysroot/{dev,proc,run,sys,var} 155 rm -rf sysroot/usr/{sbin,bin,share} 156 rm -rf sysroot/usr/lib/{apt,udev,systemd} 157 if: steps.get-cached-sysroot.outputs.cache-hit != 'true' 158 159 - name: 'Configure' 160 run: > 161 bash configure 162 --with-conf-name=linux-${{ matrix.target-cpu }} 163 --with-version-opt=${GITHUB_ACTOR}-${GITHUB_SHA} 164 --with-boot-jdk=${{ steps.bootjdk.outputs.path }} 165 --with-zlib=system 166 --enable-debug 167 --disable-precompiled-headers 168 --openjdk-target=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}} 169 --with-sysroot=sysroot 170 --with-build-jdk=${{ steps.buildjdk.outputs.jdk-path }} 171 --with-jmod-compress=zip-1 172 CC=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}-gcc-${{ inputs.gcc-major-version }} 173 CXX=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}-g++-${{ inputs.gcc-major-version }} 174 ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( 175 echo "Dumping config.log:" && 176 cat config.log && 177 exit 1) 178 179 - name: 'Build' 180 id: build 181 uses: ./.github/actions/do-build 182 with: 183 make-target: 'hotspot ${{ inputs.make-arguments }}' 184 platform: linux-${{ matrix.target-cpu }}