Skip to content

Add risc-v cross llvm build #467

Add risc-v cross llvm build

Add risc-v cross llvm build #467

Workflow file for this run

name: cache_llvm
on:
push:
branches:
- main
paths:
- '.github/workflows/create_llvm.yml'
pull_request:
paths:
- '.github/workflows/create_llvm.yml'
workflow_dispatch:
permissions: {}
jobs:
create_llvm_cache:
strategy:
matrix:
version: [18, 19]
os: [ubuntu-22.04, ubuntu-24.04, windows-2019]
build_type: [Release, RelAssert]
arch : [x86, x86_64, aarch64, riscv64]
exclude:
# Reduce the versions of llvm for aarch64, riscv64 & x86 architectures and windows, as
# well as any windows os variants to reduce cache usage.
- arch: aarch64
version: 18
- arch: aarch64
build_type: Release
- arch: riscv64
version: 18
- arch: riscv64
build_type: Release
- arch: x86
version: 18
- arch: x86
build_type: Release
- os: windows-2019
version: 18
- os: windows-2019
build_type: Release
- os: windows-2019
arch: aarch64
- os: windows-2019
arch: x86
- os: windows-2019
arch: ubuntu-22.04
# Todo: for risc-v we need to build on ubuntu-24.04 as gcc 13 is required for the dynamic links flags to work
- os: ubuntu-22.04
arch: riscv64
# we build the other arches on 22.04
- os: ubuntu-24.04
arch: x86
- os: ubuntu-24.04
arch: x86_64
- os: ubuntu-24.04
arch: aarch64
include:
# We want to set flags related to particular matrix dimensions. To do this
# we need to create default values first, and then against particular matrix
# dimensions.
# Note that we need to use RelAssert as the cache key matching can match Release against ReleaseAssert
- os_flags:
- arch_flags:
- build_type_flags:
- build_type_flags: -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON
build_type: RelAssert
- arch_flags: -DCMAKE_TOOLCHAIN_FILE="$GITHUB_WORKSPACE/ock/platform/arm-linux/aarch64-toolchain.cmake"
-DLLVM_HOST_TRIPLE=aarch64-unknown-linux-gnu
arch: aarch64
- arch_flags: -DCMAKE_TOOLCHAIN_FILE="$GITHUB_WORKSPACE/ock/platform/riscv64-linux/riscv64-toolchain.cmake"
-DLLVM_HOST_TRIPLE=riscv64-unknown-linux-gnu
arch: riscv64
- arch_flags: -DLLVM_BUILD_32_BITS=ON -DLIBXML2_LIBRARIES=IGNORE -DLLVM_ENABLE_TERMINFO=OFF
-DLLVM_HOST_TRIPLE=i686-unknown-linux-gnu
arch: x86
- build_type: Release
build_type_flags: -DCMAKE_BUILD_TYPE=Release
- os: ubuntu-22.04
os_flags: -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON
- os: ubuntu-24.04
os_flags: -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON
runs-on: ${{ matrix.os }}
steps:
- name: Cache llvm
id: cache
uses: actions/cache@v4
with:
path:
llvm_install/**
key: llvm-${{ matrix.os }}-${{ matrix.arch }}-v${{ matrix.version }}-${{ matrix.build_type }}
- name: Setup Windows
if: startsWith(runner.os, 'Windows') && steps.cache.outputs.cache-hit != 'true'
uses: llvm/actions/setup-windows@main
with:
arch: amd64
- name: Checkout repo llvm
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
repository: llvm/llvm-project
ref: release/${{matrix.version}}.x
- name: Checkout repo ock platform
if: ${{ steps.cache.outputs.cache-hit != 'true' && matrix.arch != 'x86_64' }}
uses: actions/checkout@v4
with:
sparse-checkout: |
platform
path: ock
- name: Install Ninja
if: steps.cache.outputs.cache-hit != 'true'
uses: llvm/actions/install-ninja@main
- name: install aarch64 build tools
if: ${{ steps.cache.outputs.cache-hit != 'true' && matrix.arch == 'aarch64' }}
run:
sudo apt-get install --yes g++-11-aarch64-linux-gnu
- name: install x86 build tools
if: ${{ steps.cache.outputs.cache-hit != 'true' && matrix.arch == 'x86' }}
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install --yes gcc-multilib g++-multilib libc6-dev:i386 lib32tinfo-dev
- name: Flags checker
if: steps.cache.outputs.cache-hit != 'true'
run:
echo Building on "${{ matrix.os }}" with os_flags "${{ matrix.os_flags}}" arch "${{ matrix.arch }}" extra flags "${{ matrix.build_type_flags}}" and build_type "${{matrix.build_type}}"
- name: Run cmake
if: steps.cache.outputs.cache-hit != 'true'
run:
cmake llvm
-DLLVM_ENABLE_DIA_SDK=OFF
-DCMAKE_INSTALL_PREFIX=llvm_install
-DLLVM_ENABLE_ZLIB=FALSE
-DLLVM_ENABLE_ZSTD=FALSE
-DLLVM_ENABLE_Z3_SOLVER=FALSE
-DLLVM_ENABLE_PROJECTS="clang;lld"
-DLLVM_TARGETS_TO_BUILD="X86;ARM;AArch64;RISCV"
-Bbuild
-GNinja
${{ matrix.build_type_flags }}
${{ matrix.os_flags}}
${{ matrix.arch_flags}}
- name: Run build on llvm
if: steps.cache.outputs.cache-hit != 'true'
run:
cmake --build build --target install
- name: Copy lit tools
if: steps.cache.outputs.cache-hit != 'true'
run: |
cp build/bin/FileCheck* llvm_install/bin
cp build/bin/not* llvm_install/bin