1 #
  2 # Copyright (c) 2022, 2023, 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       extra-conf-options:
 35         required: false
 36         type: string
 37       configure-arguments:
 38         required: false
 39         type: string
 40       make-arguments:
 41         required: false
 42         type: string
 43 
 44 jobs:
 45   build-cross-compile:
 46     name: build
 47     runs-on: ubuntu-22.04
 48 
 49     strategy:
 50       fail-fast: false
 51       matrix:
 52         target-cpu:
 53           - aarch64
 54           - arm



 55         include:
 56           - target-cpu: aarch64
 57             gnu-arch: aarch64
 58             debian-arch: arm64
 59             debian-repository: https://httpredir.debian.org/debian/
 60             debian-version: bullseye
 61           - target-cpu: arm
 62             gnu-arch: arm
 63             debian-arch: armhf
 64             debian-repository: https://httpredir.debian.org/debian/
 65             debian-version: bullseye
 66             gnu-abi: eabihf















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