Skip to content

Commit 5f1f552

Browse files
committed
chore: Build bpf-linker and LLVM for multiple targets
Apart from the x86_64 Linux build, cross compile also to Linux arm64, macOS x86_64 and macoOS arm64.
1 parent cdcb6bd commit 5f1f552

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ jobs:
133133
if: matrix.llvm == 'source'
134134
run: |
135135
set -euxo pipefail
136-
echo "${{ github.workspace }}/llvm-install/bin" >> $GITHUB_PATH
136+
echo "${{ github.workspace }}/llvm-install/x86_64-linux-gnu/bin" >> $GITHUB_PATH
137137
# LD_LIBRARY_PATH is needed because we're going to link everything dynamically below. This
138138
# doesn't affect behavior, but greatly reduces disk usage.
139-
echo "LD_LIBRARY_PATH=${{ github.workspace }}/llvm-install/lib" >> $GITHUB_ENV
139+
echo "LD_LIBRARY_PATH=${{ github.workspace }}/llvm-install/x86_64-linux-gnu/lib" >> $GITHUB_ENV
140140
141141
# llvm-sys discovers link flags at build script time; these are cached by cargo. The cached
142142
# flags may be incorrect when the cache is reused across LLVM versions.

.github/workflows/llvm.yml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,18 @@ on:
88

99
jobs:
1010
llvm:
11-
runs-on: ubuntu-22.04
11+
strategy:
12+
matrix:
13+
include:
14+
- target: aarch64-linux-gnu
15+
os: ubuntu-latest
16+
- target: aarch64-apple-darwin
17+
os: macos-latest
18+
- target: x86_64-linux-gnu
19+
os: ubuntu-latest
20+
- target: x86_64-apple-darwin
21+
os: macos-latest
22+
runs-on: ${{ matrix.os }}
1223
name: llvm
1324
outputs:
1425
cache-key: ${{ steps.cache-key.outputs.cache-key }}
@@ -30,8 +41,8 @@ jobs:
3041
key: ${{ steps.cache-key.outputs.cache-key }}
3142
lookup-only: true
3243

33-
- name: Install Tools
34-
if: steps.cache-llvm.outputs.cache-hit != 'true'
44+
- name: Install Tools (Linux)
45+
if: steps.cache-llvm.outputs.cache-hit != 'true' && matrix.os == 'ubuntu-latest'
3546
run: |
3647
set -euxo pipefail
3748
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | \
@@ -43,6 +54,13 @@ jobs:
4354
sudo apt update
4455
sudo apt -y install cmake ninja-build clang lld
4556
57+
- name: Install Tools (macOS)
58+
if: steps.cache-llvm.outputs.cache-hit != 'true' && matrix.os == 'macos-latest'
59+
run: |
60+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
61+
echo "/usr/local/bin/brew" >> $GITHUB_PATH
62+
brew install cmake ninja
63+
4664
- name: Checkout LLVM Source
4765
if: steps.cache-llvm.outputs.cache-hit != 'true'
4866
uses: actions/checkout@v4
@@ -55,22 +73,28 @@ jobs:
5573
if: steps.cache-llvm.outputs.cache-hit != 'true'
5674
run: |
5775
set -euxo pipefail
76+
LLVM_USE_LINKER_OPTION=""
77+
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
78+
LLVM_USE_LINKER_OPTION="-DLLVM_USE_LINKER=lld"
79+
fi
5880
cmake \
5981
-S llvm-project/llvm \
6082
-B llvm-build \
6183
-G Ninja \
6284
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
6385
-DCMAKE_C_COMPILER=clang \
6486
-DCMAKE_CXX_COMPILER=clang++ \
65-
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/llvm-install" \
87+
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/llvm-install/${{ matrix.target }}" \
6688
-DLLVM_BUILD_LLVM_DYLIB=ON \
89+
-DLLVM_DEFAULT_TARGET_TRIPLE=${{ matrix.target }} \
6790
-DLLVM_ENABLE_ASSERTIONS=ON \
6891
-DLLVM_ENABLE_PROJECTS= \
6992
-DLLVM_ENABLE_RUNTIMES= \
93+
-DLLVM_HOST_TRIPLE=${{ matrix.target }} \
7094
-DLLVM_INSTALL_UTILS=ON \
7195
-DLLVM_LINK_LLVM_DYLIB=ON \
7296
-DLLVM_TARGETS_TO_BUILD=BPF \
73-
-DLLVM_USE_LINKER=lld
97+
$LLVM_USE_LINKER_OPTION
7498
7599
- name: Install LLVM
76100
if: steps.cache-llvm.outputs.cache-hit != 'true'

0 commit comments

Comments
 (0)