Skip to content

Commit

Permalink
CI: revamp installer to support ARM
Browse files Browse the repository at this point in the history
  • Loading branch information
mratsim committed Jan 25, 2025
1 parent 4a1b5bc commit f80f5b3
Show file tree
Hide file tree
Showing 2 changed files with 414 additions and 73 deletions.
148 changes: 75 additions & 73 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,55 +26,64 @@ jobs:
rust_toolchain: [stable] # [beta, nightly]
go_toolchain: [stable]
target:
# We only need to test 32-bit for targets like RISC-V that don't have ASM.
- os: linux
cpu: i386
BACKEND: NO_ASM

# We only need to test 32-bit for targets like RISC-V that don't have ASM.
# - os: linux
# cpu: i386
# BACKEND: ASM
nim_channel: nightly
ctt_backend: NO_ASM

- os: linux
cpu: amd64
BACKEND: NO_ASM
nim_channel: nightly
ctt_backend: NO_ASM
- os: linux
cpu: amd64
BACKEND: ASM
- os: linux
cpu: arm64
builder: ubuntu-22.04-arm
BACKEND: NO_ASM
nim_channel: nightly
ctt_backend: ASM

# ASM for ARM Linux is not available yet
- os: linux
cpu: arm64
nim_channel: nightly
builder: ubuntu-22.04-arm
BACKEND: ASM
ctt_backend: NO_ASM
# - os: linux
# cpu: arm64
# nim_channel: nightly
# builder: ubuntu-22.04-arm
# ctt_backend: ASM

- os: windows
cpu: amd64
BACKEND: NO_ASM
nim_channel: nightly
ctt_backend: NO_ASM
- os: windows
cpu: amd64
BACKEND: ASM

# MacOS Github agents are now using ARM and we need Nim ARM nightlies: https://github.com/mratsim/constantine/issues/372
# - os: macos
# cpu: amd64
# BACKEND: NO_ASM
# - os: macos
# cpu: amd64
# BACKEND: ASM
nim_channel: nightly
ctt_backend: ASM

# MacOS Github agents are now using ARM and there are no ARM nightlies:
# https://github.com/mratsim/constantine/issues/372
# So we build from source
- os: macos
cpu: arm64
nim_channel: source
ctt_backend: NO_ASM
- os: macos
cpu: arm64
nim_channel: source
ctt_backend: ASM
include:
- target:
os: linux
builder: ubuntu-latest
# - target:
# os: macos
# builder: macos-latest
- target:
os: macos
builder: macos-latest
- target:
os: windows
builder: windows-latest
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ matrix.target.BACKEND }} (${{ matrix.nim_version }})'
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ matrix.target.ctt_backend }} (${{ matrix.nim_version }})'
runs-on: ${{ matrix.builder }}
steps:
- name: Get branch name
Expand Down Expand Up @@ -149,27 +158,43 @@ jobs:
echo '${{ github.workspace }}'"/external/mingw-${{ matrix.target.cpu }}/bin" >> $GITHUB_PATH
echo '${{ github.workspace }}'"/external/dlls-${{ matrix.target.cpu }}" >> $GITHUB_PATH
- name: Restore Nim from cache
if: matrix.nim_version != 'devel'
- name: Get latest Nim commit hash & install dir
id: versions
shell: bash
run: |
getHash() {
git ls-remote "https://github.com/$1" "${2:-HEAD}" | cut -f 1
}
nimHash=$(getHash nim-lang/Nim '${{ matrix.branch }}')
csourcesHash=$(getHash nim-lang/csources)
echo "::set-output name=nim::$nimHash"
echo "::set-output name=csources::$csourcesHash"
echo "::set-output name=installdir::nim-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ matrix.nim_version }}-$nimHash"
# Nightlies are already on Github
- name: Restore Nim from cache (except nightlies)
if: matrix.target.nim_channel != 'nightly'
id: nim-compiler-cache
uses: actions/cache@v4
with:
path: '${{ github.workspace }}/nim-${{ matrix.nim_version }}-${{ matrix.target.cpu }}'
key: 'nim-${{ matrix.target.cpu }}-${{ matrix.nim_version }}'
path: '${{ github.workspace }}/${{ steps.versions.outputs.installdir }}'
key: '${{ steps.versions.outputs.installdir }}'

- name: Setup Nim
if: steps.nim-compiler-cache.outputs.cache-hit != 'true'
uses: alaviss/[email protected]
with:
path: 'nim-${{ matrix.nim_version }}-${{ matrix.target.cpu }}'
version: ${{ matrix.nim_version }}
architecture: ${{ matrix.target.cpu }}
add-to-path: false
shell: bash
run: |
bash constantine/.github/workflows/install_nim.sh \
--nim-channel ${{ matrix.target.nim_channel }} \
--nim-version ${{ matrix.nim_version }} \
--os ${{ matrix.target.os }} \
--arch ${{ matrix.target.cpu }} \
--install-dir ${{ steps.versions.outputs.installdir }}
- name: Path to cached Nim
shell: bash
run: |
echo '${{ github.workspace }}'"/nim-${{ matrix.nim_version }}-${{ matrix.target.cpu }}/bin" >> $GITHUB_PATH
echo '${{ github.workspace }}'"${{ steps.versions.outputs.installdir }}" >> $GITHUB_PATH
echo '${{ github.workspace }}'"/.nimble/bin" >> $GITHUB_PATH
- name: Install test dependencies (Linux amd64)
Expand Down Expand Up @@ -211,29 +236,6 @@ jobs:
if: runner.os == 'macOS'
run: |
brew install gmp
- name: Install Clang with Intel Assembly support (macOS)
if: runner.os == 'macOS'
# Apple Clang does not support Intel syntax due to missing
# commit: https://github.com/llvm/llvm-project/commit/ae98182cf7341181e4aa815c372a072dec82779f
# Revision: https://reviews.llvm.org/D113707
# Apple upstream: FB12137688

# Furthermore, Apple Clang can delete symbols when building a static library
# in particular the hasAdxImpl bool for CPU runtime detection.

# run: |
# mkdir -p external/bin
# cat << EOF > external/bin/clang
# #!/bin/bash
# exec $(brew --prefix llvm@15)/bin/clang "\$@"
# EOF
# cat << EOF > external/bin/clang++
# #!/bin/bash
# exec $(brew --prefix llvm@15)/bin/clang++ "\$@"
# EOF
# chmod 755 external/bin/{clang,clang++}
# echo '${{ github.workspace }}/external/bin' >> $GITHUB_PATH
run: echo "$(brew --prefix llvm@15)/bin" >> $GITHUB_PATH
- name: Setup MSYS2 (Windows)
if: runner.os == 'Windows'
Expand Down Expand Up @@ -295,15 +297,15 @@ jobs:
go mod download -modfile=go_test.mod
- name: Run Constantine as C library tests (UNIX with Assembly)
if: runner.os != 'Windows' && matrix.target.BACKEND == 'ASM'
if: runner.os != 'Windows' && matrix.target.ctt_backend == 'ASM'
shell: bash
run: |
cd constantine
nimble make_lib --verbose
nimble make_headers --verbose
nimble test_lib --verbose
- name: Run Constantine as C library tests (UNIX no Assembly)
if: runner.os != 'Windows' && matrix.target.BACKEND == 'NO_ASM'
if: runner.os != 'Windows' && matrix.target.ctt_backend == 'NO_ASM'
shell: bash
run: |
cd constantine
Expand All @@ -313,7 +315,7 @@ jobs:
- name: Run Constantine as C library tests (Windows with Assembly)
# So "test_bindings" uses C and can find GMP
# but nim-gmp cannot find GMP on Windows CI
if: runner.os == 'Windows' && matrix.target.BACKEND == 'ASM'
if: runner.os == 'Windows' && matrix.target.ctt_backend == 'ASM'
shell: msys2 {0}
run: |
cd constantine
Expand All @@ -323,7 +325,7 @@ jobs:
- name: Run Constantine as C library tests (Windows no Assembly)
# So "test_bindings" uses C and can find GMP
# but nim-gmp cannot find GMP on Windows CI
if: runner.os == 'Windows' && matrix.target.BACKEND == 'NO_ASM'
if: runner.os == 'Windows' && matrix.target.ctt_backend == 'NO_ASM'
shell: msys2 {0}
run: |
cd constantine
Expand All @@ -340,14 +342,14 @@ jobs:
go test -modfile=../go_test.mod
- name: Run Constantine as Rust library tests (with Assembly)
if: matrix.target.BACKEND == 'ASM' && matrix.target.cpu != 'i386'
if: matrix.target.ctt_backend == 'ASM' && matrix.target.cpu != 'i386'
shell: bash
# We need to deactivate the assembly (used by default for benches)
run: |
cd constantine
cargo test -- --nocapture
- name: Run Constantine as Rust library tests (NO Assembly)
if: matrix.target.BACKEND == 'NO_ASM' && matrix.target.cpu != 'i386'
if: matrix.target.ctt_backend == 'NO_ASM' && matrix.target.cpu != 'i386'
shell: bash
# We need to deactivate the assembly (used by default for benches)
run: |
Expand All @@ -357,7 +359,7 @@ jobs:
- name: Compile Constantine Zkalc benchmark (no assembly)
# Skip 32-bit as that would need clang-multilib or -m32
# Skip Windows as clang throws fatal error LNK1107
if: matrix.target.BACKEND == 'NO_ASM' && matrix.target.cpu != 'i386' && runner.os != 'Windows'
if: matrix.target.ctt_backend == 'NO_ASM' && matrix.target.cpu != 'i386' && runner.os != 'Windows'
shell: bash
run: |
cd constantine
Expand All @@ -366,20 +368,20 @@ jobs:
- name: Compile Constantine Zkalc benchmark (with assembly)
# Skip 32-bit as that would need clang-multilib or -m32
# Skip Windows as clang throws fatal error LNK1107
if: matrix.target.BACKEND == 'ASM' && matrix.target.cpu != 'i386' && runner.os != 'Windows'
if: matrix.target.ctt_backend == 'ASM' && matrix.target.cpu != 'i386' && runner.os != 'Windows'
shell: bash
run: |
cd constantine
nimble make_zkalc
- name: Run Constantine in-depth tests (Unix - with GMP, with Assembly)
if: runner.os != 'Windows' && matrix.target.BACKEND == 'ASM'
if: runner.os != 'Windows' && matrix.target.ctt_backend == 'ASM'
shell: bash
run: |
cd constantine
nimble test_parallel --verbose
- name: Run Constantine in-depth tests (Unix - with GMP, no Assembly)
if: runner.os != 'Windows' && matrix.target.BACKEND == 'NO_ASM'
if: runner.os != 'Windows' && matrix.target.ctt_backend == 'NO_ASM'
shell: bash
run: |
cd constantine
Expand All @@ -390,7 +392,7 @@ jobs:
# but nim-gmp cannot find GMP on Windows CI
# Also need to workaround asynctools not being able to create pipes https://github.com/nim-lang/Nim/issues/23118
# And LTO impossible constraint in the deneb_kzg test (but not MSM for some reason)
if: runner.os == 'Windows' && matrix.target.BACKEND == 'ASM'
if: runner.os == 'Windows' && matrix.target.ctt_backend == 'ASM'
shell: msys2 {0}
run: |
cd constantine
Expand All @@ -403,7 +405,7 @@ jobs:
# So "test_bindings" uses C and can find GMP
# but nim-gmp cannot find GMP on Windows CI
# Also need to workaround asynctools not being able to create pipes https://github.com/nim-lang/Nim/issues/23118
if: runner.os == 'Windows' && matrix.target.BACKEND == 'NO_ASM'
if: runner.os == 'Windows' && matrix.target.ctt_backend == 'NO_ASM'
shell: msys2 {0}
run: |
cd constantine
Expand Down
Loading

0 comments on commit f80f5b3

Please sign in to comment.