From 462c31fbbb833d9fd030acc7a2711e8db91e6bfb Mon Sep 17 00:00:00 2001 From: thb-sb Date: Mon, 11 Sep 2023 16:14:38 +0200 Subject: [PATCH] Cross-compile to linux-aarch64 from linux-x64 in GitHub actions. This commit adds a new CI job called `linux_aarch64`. This new job builds OpenSSL 3.1, liboqs and oqs-provider for linux-aarch64 (`elf64-littleaarch64`). --- .github/workflows/linux.yml | 83 +++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 3a2bfd4e..ac37c59a 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -126,3 +126,86 @@ jobs: - name: Run tests run: ctest --test-dir build --output-on-failure + linux_aarch64: + name: "aarch64 cross-compilation" + runs-on: ubuntu-latest + strategy: + fail-fast: false + container: + image: openquantumsafe/ci-ubuntu-jammy:latest + env: + OPENSSL_BRANCH: "master" + INSTALL_DIR: "/opt/install" + CMAKE_TOOLCHAIN_FILE: "/opt/linux-aarch64-toolchain.cmake" + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install dependencies + run: apt-get update && apt-get install -y ninja-build git cmake nodejs gcc-aarch64-linux-gnu libc6-dev-arm64-cross + + - name: Prepare install directory + run: mkdir -p "${INSTALL_DIR}" + + - name: Clone and build OpenSSL(3) for linux-aarch64 + working-directory: /opt/ + run: | + git clone --depth=1 --branch "${OPENSSL_BRANCH}" https://github.com/openssl/openssl.git openssl + cd openssl + ./Configure linux-aarch64 no-tests --prefix="${INSTALL_DIR}" \ + --openssldir="${INSTALL_DIR}" \ + --cross-compile-prefix=aarch64-linux-gnu- \ + --release + make -j$(nproc) + make install_sw + cd .. + + - name: Write CMake toolchain file for liboqs and oqs-provider + run: | + echo "set(CMAKE_SYSTEM_NAME Linux) \n + set(CMAKE_SYSTEM_PROCESSOR aarch64) \n + set(CMAKE_C_COMPILER "/usr/bin/aarch64-linux-gnu-gcc")\n" > "${CMAKE_TOOLCHAIN_FILE}" + + - name: Clone and build liboqs for linux-aarch64 + working-directory: /opt/ + run: | + git clone --depth=1 --branch main https://github.com/open-quantum-safe/liboqs.git liboqs + cd liboqs + mkdir build install + cmake --toolchain "${CMAKE_TOOLCHAIN_FILE}" \ + -GNinja -B build \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \ + -DOQS_USE_OPENSSL=OFF + cmake --build build -j$(nproc) + cmake --install build + cd .. + + - name: Build oqs-provider for linux-aarch64 + run: | + cmake --toolchain "${CMAKE_TOOLCHAIN_FILE}" \ + -GNinja -B build \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \ + -DOPENSSL_ROOT_DIR="${INSTALL_DIR}" \ + -Dliboqs_DIR="${INSTALL_DIR}/lib/cmake/liboqs" + cmake --build build -j$(nproc) + cmake --install build + cd .. + + - name: Verify that binaries and libraries are built for linux-aarch64. + run: | + if ! aarch64-linux-gnu-objdump -a "${INSTALL_DIR}/lib/ossl-modules/oqsprovider.so" | grep -q elf64-littleaarch64; then + echo "File hasn't been built for linux-aarch64" + exit 1 + fi + + - name: Build .deb install package + run: cpack + working-directory: build + - name: Retain .deb installer + uses: actions/upload-artifact@v3 + with: + name: oqsprovider-aarch64 + path: build/*.deb