Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Commit

Permalink
Add linux-cross-compile testing on RISC-V
Browse files Browse the repository at this point in the history
  • Loading branch information
luhenry committed Aug 2, 2023
1 parent 6f76b65 commit 808ad3c
Show file tree
Hide file tree
Showing 9 changed files with 753 additions and 98 deletions.
83 changes: 83 additions & 0 deletions .github/actions/create-sysroot/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#
# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

name: 'Create sysroot'
description: 'Create the sysroot to cross-compile and test the OpenJDK'
inputs:
target-cpu:
description: 'Target CPU architecture'
required: true
gnu-arch:
description: 'GNU CPU architecture'
required: true
debian-arch:
description: 'Debian CPU architecture'
required: true
debian-repository:
description: 'Debian repository'
required: true
debian-version:
description: 'Debian version'
required: true
debian-keyring:
description: 'Debian keyring'
required: false

runs:
using: composite
steps:
- name: 'Check cache for sysroot'
id: get-cached-sysroot
uses: actions/cache@v3
with:
path: sysroot
key: sysroot-${{ inputs.debian-arch }}-${{ inputs.debian-version }}-${{ hashFiles('./.github/actions/create-sysroot/action.yml') }}

- name: 'Install sysroot dependencies'
run: sudo apt-get install debootstrap qemu-user-static
shell: bash
if: steps.get-cached-sysroot.outputs.cache-hit != 'true'

- name: 'Create sysroot'
run: >
sudo qemu-debootstrap
--arch=${{ inputs.debian-arch }}
--verbose
--include=fakeroot,symlinks,build-essential,make,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev,libatomic1,zlib1g-dev
--resolve-deps
$(test -n "${{ inputs.debian-keyring }}" && echo "--keyring=${{ inputs.debian-keyring }}")
${{ inputs.debian-version }}
sysroot
${{ inputs.debian-repository }}
shell: bash
if: steps.get-cached-sysroot.outputs.cache-hit != 'true'

- name: 'Prepare sysroot'
run: |
# Prepare sysroot and remove unused files to minimize cache
sudo chroot sysroot symlinks -cr .
sudo rm -rf sysroot/{dev,proc,run,sys}
shell: bash
if: steps.get-cached-sysroot.outputs.cache-hit != 'true'
38 changes: 21 additions & 17 deletions .github/actions/get-bundles/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ inputs:
debug-suffix:
description: 'File name suffix denoting debug level, possibly empty'
required: false
path:
description: 'Path to the installed JDK bundle'
required: false
default: 'bundles'
outputs:
jdk-path:
description: 'Path to the installed JDK bundle'
Expand All @@ -51,40 +55,40 @@ runs:
uses: actions/download-artifact@v3
with:
name: bundles-${{ inputs.platform }}${{ inputs.debug-suffix }}
path: bundles
path: ${{ inputs.path }}
continue-on-error: true

- name: 'Download bundles artifact (retry)'
uses: actions/download-artifact@v3
with:
name: bundles-${{ inputs.platform }}${{ inputs.debug-suffix }}
path: bundles
path: ${{ inputs.path }}
if: steps.download-bundles.outcome == 'failure'

- name: 'Unpack bundles'
run: |
if [[ -e bundles/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.zip ]]; then
if [[ -e ${{ inputs.path }}/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.zip ]]; then
echo 'Unpacking jdk bundle...'
mkdir -p bundles/jdk
unzip -q bundles/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.zip -d bundles/jdk
mkdir -p ${{ inputs.path }}/jdk
unzip -q ${{ inputs.path }}/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.zip -d ${{ inputs.path }}/jdk
fi
if [[ -e bundles/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz ]]; then
if [[ -e ${{ inputs.path }}/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz ]]; then
echo 'Unpacking jdk bundle...'
mkdir -p bundles/jdk
tar -xf bundles/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz -C bundles/jdk
mkdir -p ${{ inputs.path }}/jdk
tar -xf ${{ inputs.path }}/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz -C ${{ inputs.path }}/jdk
fi
if [[ -e bundles/symbols-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz ]]; then
if [[ -e ${{ inputs.path }}/symbols-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz ]]; then
echo 'Unpacking symbols bundle...'
mkdir -p bundles/symbols
tar -xf bundles/symbols-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz -C bundles/symbols
mkdir -p ${{ inputs.path }}/symbols
tar -xf ${{ inputs.path }}/symbols-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz -C ${{ inputs.path }}/symbols
fi
if [[ -e bundles/tests-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz ]]; then
if [[ -e ${{ inputs.path }}/tests-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz ]]; then
echo 'Unpacking tests bundle...'
mkdir -p bundles/tests
tar -xf bundles/tests-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz -C bundles/tests
mkdir -p ${{ inputs.path }}/tests
tar -xf ${{ inputs.path }}/tests-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz -C ${{ inputs.path }}/tests
fi
shell: bash

Expand All @@ -93,9 +97,9 @@ runs:
run: |
# Export the paths
jdk_dir="$GITHUB_WORKSPACE/$(dirname $(find bundles/jdk -name bin -type d))"
symbols_dir="$GITHUB_WORKSPACE/$(dirname $(find bundles/symbols -name bin -type d))"
tests_dir="$GITHUB_WORKSPACE/bundles/tests"
jdk_dir="$GITHUB_WORKSPACE/$(dirname $(find ${{ inputs.path }}/jdk -name bin -type d))"
symbols_dir="$GITHUB_WORKSPACE/$(dirname $(find ${{ inputs.path }}/symbols -name bin -type d))"
tests_dir="$GITHUB_WORKSPACE/${{ inputs.path }}/tests"
if [[ '${{ runner.os }}' == 'Windows' ]]; then
jdk_dir="$(cygpath $jdk_dir)"
Expand Down
94 changes: 94 additions & 0 deletions .github/actions/init-platform-variables/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#
# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

name: 'Initialize Platform Variables'
description: 'Initialize the platform-specific variables used for cross-compilation'
inputs:
platform:
description: 'Target Platform'
required: true
outputs:
target-cpu:
description: 'Target CPU Archictecture'
value: ${{ steps.platform-variables.outputs.target-cpu }}
gnu-arch:
description: 'Target GNU Architecture'
value: ${{ steps.platform-variables.outputs.gnu-arch }}
debian-arch:
description: 'Target Debian Architecture'
value: ${{ steps.platform-variables.outputs.debian-arch }}
debian-repository:
description: 'Target Debian Repository'
value: ${{ steps.platform-variables.outputs.debian-repository }}
debian-version:
description: 'Target Debian Version'
value: ${{ steps.platform-variables.outputs.debian-version }}
gnu-abi:
description: 'Target GNU ABI'
value: ${{ steps.platform-variables.outputs.gnu-abi }}

runs:
using: composite
steps:
- name: 'Initialize platform variables'
id: platform-variables
run: |
if [[ '${{ inputs.platform }}' == 'linux-aarch64' ]]; then
echo "target-cpu=aarch64" >> $GITHUB_OUTPUT
echo "gnu-arch=aarch64" >> $GITHUB_OUTPUT
echo "debian-arch=arm64" >> $GITHUB_OUTPUT
echo "debian-repository=https://httpredir.debian.org/debian/" >> $GITHUB_OUTPUT
echo "debian-version=bullseye" >> $GITHUB_OUTPUT
elif [[ '${{ inputs.platform }}' == 'linux-arm' ]]; then
echo "target-cpu=arm" >> $GITHUB_OUTPUT
echo "gnu-arch=arm" >> $GITHUB_OUTPUT
echo "gnu-abi=eabihf" >> $GITHUB_OUTPUT
echo "debian-arch=armhf" >> $GITHUB_OUTPUT
echo "debian-repository=https://httpredir.debian.org/debian/" >> $GITHUB_OUTPUT
echo "debian-version=bullseye" >> $GITHUB_OUTPUT
elif [[ '${{ inputs.platform }}' == 'linux-s390x' ]]; then
echo "target-cpu=s390x" >> $GITHUB_OUTPUT
echo "gnu-arch=s390x" >> $GITHUB_OUTPUT
echo "debian-arch=s390x" >> $GITHUB_OUTPUT
echo "debian-repository=https://httpredir.debian.org/debian/" >> $GITHUB_OUTPUT
echo "debian-version=bullseye" >> $GITHUB_OUTPUT
elif [[ '${{ inputs.platform }}' == 'linux-ppc64le' ]]; then
echo "target-cpu=ppc64le" >> $GITHUB_OUTPUT
echo "gnu-arch=powerpc64le" >> $GITHUB_OUTPUT
echo "debian-arch=ppc64el" >> $GITHUB_OUTPUT
echo "debian-repository=https://httpredir.debian.org/debian/" >> $GITHUB_OUTPUT
echo "debian-version=bullseye" >> $GITHUB_OUTPUT
elif [[ '${{ inputs.platform }}' == 'linux-riscv64' ]]; then
echo "target-cpu=riscv64" >> $GITHUB_OUTPUT
echo "gnu-arch=riscv64" >> $GITHUB_OUTPUT
echo "debian-arch=riscv64" >> $GITHUB_OUTPUT
echo "debian-repository=https://deb.debian.org/debian-ports" >> $GITHUB_OUTPUT
echo "debian-keyring=/usr/share/keyrings/debian-ports-archive-keyring.gpg" >> $GITHUB_OUTPUT
echo "debian-version=sid" >> $GITHUB_OUTPUT
else
echo "Unknown platform ${{ inputs.platform }}"
exit 1
fi
shell: bash
Loading

0 comments on commit 808ad3c

Please sign in to comment.