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://deb.debian.org/debian-ports 90 debian-keyring: /usr/share/keyrings/debian-ports-archive-keyring.gpg 91 debian-version: sid 92 93 steps: 94 - name: 'Checkout the JDK source' 95 uses: actions/checkout@v3 96 97 - name: 'Get the BootJDK' 98 id: bootjdk 99 uses: ./.github/actions/get-bootjdk 100 with: 101 platform: linux-x64 102 103 # Use linux-x64 JDK bundle as build JDK 104 - name: 'Get build JDK' 105 id: buildjdk 106 uses: ./.github/actions/get-bundles 107 with: 108 platform: linux-x64 109 110 # Upgrading apt to solve libc6 installation bugs, see JDK-8260460. 111 - name: 'Install toolchain and dependencies' 112 run: | 113 # Install dependencies using apt-get 114 sudo apt-get update 115 sudo apt-get install --only-upgrade apt 116 sudo apt-get install \ 117 gcc-${{ inputs.gcc-major-version }}=${{ inputs.apt-gcc-version }} \ 118 g++-${{ inputs.gcc-major-version }}=${{ inputs.apt-gcc-version }} \ 119 gcc-${{ inputs.gcc-major-version }}-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}=${{ inputs.apt-gcc-cross-version }} \ 120 g++-${{ inputs.gcc-major-version }}-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}=${{ inputs.apt-gcc-cross-version }} \ 121 libxrandr-dev libxtst-dev libcups2-dev libasound2-dev \ 122 debian-ports-archive-keyring 123 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 }} 124 125 - name: 'Check cache for sysroot' 126 id: get-cached-sysroot 127 uses: actions/cache@v3 128 with: 129 path: sysroot 130 key: sysroot-${{ matrix.debian-arch }}-${{ hashFiles('./.github/workflows/build-cross-compile.yml') }} 131 132 - name: 'Install sysroot dependencies' 133 run: sudo apt-get install debootstrap qemu-user-static 134 if: steps.get-cached-sysroot.outputs.cache-hit != 'true' 135 136 - name: 'Create sysroot' 137 run: > 138 sudo debootstrap 139 --arch=${{ matrix.debian-arch }} 140 --verbose 141 --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 142 --resolve-deps 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 }} --- EOF ---