Skip to content

Commit 42e16f3

Browse files
committed
ci: Build statically linked bpf-linker in CI
- Download LLVM builds from Rust CI. - Always link libLLVM statically. - For now, do it only for x86_64.
1 parent 6f4c969 commit 42e16f3

File tree

6 files changed

+43
-44
lines changed

6 files changed

+43
-44
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ on:
1414

1515
env:
1616
CARGO_TERM_COLOR: always
17+
LLVM_SHA: 0b5eb7ba7bd796fb39c8bb6acd9ef6c140f28b65
18+
LLVM_SYS_191_PREFIX: /opt/rust-dev
19+
LLVM_TARGET: x86_64-unknown-linux-musl
1720

1821
jobs:
19-
llvm:
20-
uses: ./.github/workflows/llvm.yml
21-
2222
lint-stable:
2323
runs-on: ubuntu-22.04
2424

@@ -55,18 +55,12 @@ jobs:
5555
rust:
5656
- stable
5757
- beta
58-
# TODO: unpin nightly. There was a regression in
59-
# https://github.com/rust-lang/rust/compare/1cec373f6...becebb315 that causes
60-
# tests/btf/assembly/anon_struct_c.rs to fail to link.
61-
- nightly-2024-04-16
62-
llvm:
63-
- 18
64-
- source
58+
- nightly
6559
name: rustc=${{ matrix.rust }} llvm=${{ matrix.llvm }}
66-
needs: llvm
6760

6861
env:
6962
RUST_BACKTRACE: full
63+
RUSTFLAGS: -L /opt/rust-dev/lib
7064

7165
steps:
7266
- uses: actions/checkout@v4
@@ -114,15 +108,11 @@ jobs:
114108
sudo apt -y install clang gcc-multilib
115109
116110
- name: Install LLVM
117-
if: matrix.llvm != 'source'
118111
run: |
119112
set -euxo pipefail
120-
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
121-
echo -e deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-${{ matrix.llvm }} main | sudo tee /etc/apt/sources.list.d/llvm.list
122-
123-
sudo apt update
124-
sudo apt -y install llvm-${{ matrix.llvm }}-dev
125-
echo /usr/lib/llvm-${{ matrix.llvm }}/bin >> $GITHUB_PATH
113+
wget https://ci-artifacts.rust-lang.org/rustc-builds/${{ env.LLVM_SHA }}/rust-dev-nightly-${{ env.LLVM_TARGET }}.tar.xz
114+
tar -xpf rust-dev-nightly-${{ env.LLVM_TARGET }}.tar.xz --strip-components 1 -C /opt
115+
echo /opt/rust-dev/bin >> $GITHUB_PATH
126116
127117
- name: Restore LLVM
128118
if: matrix.llvm == 'source'
@@ -152,14 +142,14 @@ jobs:
152142
- uses: taiki-e/install-action@cargo-hack
153143

154144
- name: Check
155-
run: cargo hack check --feature-powerset --features llvm-sys/force-dynamic
145+
run: cargo hack check --feature-powerset --features llvm-sys/force-static
156146

157147
- name: Build
158-
run: cargo hack build --feature-powerset --features llvm-sys/force-dynamic
148+
run: cargo hack build --feature-powerset --features llvm-sys/force-static
159149

160150
- name: Test
161151
if: matrix.rust == 'nightly'
162-
run: cargo hack test --feature-powerset --features llvm-sys/force-dynamic
152+
run: cargo hack test --feature-powerset --features llvm-sys/force-static
163153

164154
- uses: actions/checkout@v4
165155
if: matrix.rust == 'nightly'
@@ -170,7 +160,7 @@ jobs:
170160

171161
- name: Install
172162
if: matrix.rust == 'nightly'
173-
run: cargo install --path . --no-default-features --features llvm-sys/force-dynamic
163+
run: cargo install --path . --no-default-features --features llvm-sys/force-static
174164

175165
# TODO: Remove this and run the integration tests on the local machine when they pass on 5.15.
176166
- name: Download debian kernels

.github/workflows/llvm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- id: ls-remote
1717
run: |
1818
set -euxo pipefail
19-
value=$(git ls-remote https://github.com/aya-rs/llvm-project.git refs/heads/rustc/18.0-2024-02-13 | cut -f1)
19+
value=$(git ls-remote https://github.com/aya-rs/llvm-project.git refs/heads/rustc/19.1-2024-07-30 | cut -f1)
2020
echo "sha=$value" >> "$GITHUB_OUTPUT"
2121
2222
- id: cache-key

.github/workflows/release.yml

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,22 @@ name: Release
33
on:
44
release:
55
types: [published]
6+
7+
env:
8+
LLVM_SHA: 0b5eb7ba7bd796fb39c8bb6acd9ef6c140f28b65
9+
LLVM_TARGET: x86_64-unknown-linux-musl
610

711
jobs:
8-
llvm:
9-
uses: ./.github/workflows/llvm.yml
10-
1112
upload-bins:
1213
# TODO: Build for macos someday.
1314
runs-on: ubuntu-22.04
14-
needs: llvm
1515
steps:
16-
- name: Restore LLVM
17-
uses: actions/cache/restore@v4
18-
with:
19-
path: llvm-install
20-
key: ${{ needs.llvm.outputs.cache-key }}
21-
fail-on-cache-miss: true
22-
23-
- name: Add LLVM to PATH
16+
- name: Install LLVM
2417
run: |
25-
echo "${{ github.workspace }}/llvm-install/bin" >> $GITHUB_PATH
26-
echo "$PATH"
18+
set -euxo pipefail
19+
wget https://ci-artifacts.rust-lang.org/rustc-builds/${{ env.LLVM_SHA }}/rust-dev-nightly-${{ env.LLVM_TARGET }}.tar.xz
20+
tar -xpf rust-dev-nightly-${{ env.LLVM_TARGET }}.tar.xz --strip -C /opt
21+
echo /opt/rust-dev/bin >> $GITHUB_PATH
2722
2823
- uses: actions/checkout@v4
2924
- uses: Swatinem/rust-cache@v2

Cargo.lock

Lines changed: 16 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ ar = { version = "0.9.0" }
2828
aya-rustc-llvm-proxy = { version = "0.9.2", optional = true }
2929
gimli = { version = "0.30.0" }
3030
libc = { version = "0.2.155" }
31-
llvm-sys = { features = ["disable-alltargets-init"], version = "180.0.0-rc2" }
31+
llvm-sys = { features = ["disable-alltargets-init"], version = "191.0.0-rc1" }
3232
log = { version = "0.4.22" }
3333
thiserror = { version = "1.0.61" }
3434
tracing = "0.1"

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ files with embedded bitcode (.o), optionally stored inside ar archives (.a).
1717

1818
## Installation
1919

20-
The linker requires LLVM 18. It can use the same LLVM used by the rust compiler,
20+
The linker requires LLVM 19. It can use the same LLVM used by the rust compiler,
2121
or it can use an external LLVM installation.
2222

2323
If your target is `aarch64-unknown-linux-gnu` (i.e. Linux on Apple Silicon) you
@@ -33,14 +33,14 @@ cargo install bpf-linker
3333

3434
### Using external LLVM
3535

36-
On Debian based distributions you need to install the `llvm-18-dev`, `libclang-18-dev`
37-
and `libpolly-18-dev` packages. If your distro doesn't have them you can get them
36+
On Debian based distributions you need to install the `llvm-19-dev`, `libclang-19-dev`
37+
and `libpolly-19-dev` packages. If your distro doesn't have them you can get them
3838
from the official LLVM repo at https://apt.llvm.org.
3939

4040
On rpm based distribution you need the `llvm-devel` and `clang-devel` packages.
4141
If your distro doesn't have them you can get them from Fedora Rawhide.
4242

43-
Once you have installed LLVM 18 you can install the linker running:
43+
Once you have installed LLVM 19 you can install the linker running:
4444

4545
```sh
4646
cargo install bpf-linker --no-default-features

0 commit comments

Comments
 (0)