Skip to content

Commit c362c1e

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 c362c1e

File tree

6 files changed

+42
-44
lines changed

6 files changed

+42
-44
lines changed

.github/workflows/ci.yml

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

1515
env:
1616
CARGO_TERM_COLOR: always
17+
LLVM_SHA: 0b5eb7ba7bd796fb39c8bb6acd9ef6c140f28b65
18+
LLVM_TARGET: x86_64-unknown-linux-musl
1719

1820
jobs:
19-
llvm:
20-
uses: ./.github/workflows/llvm.yml
21-
2221
lint-stable:
2322
runs-on: ubuntu-22.04
2423

@@ -55,18 +54,12 @@ jobs:
5554
rust:
5655
- stable
5756
- 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
57+
- nightly
6558
name: rustc=${{ matrix.rust }} llvm=${{ matrix.llvm }}
66-
needs: llvm
6759

6860
env:
6961
RUST_BACKTRACE: full
62+
RUSTFLAGS: -L /opt/rust-dev/lib
7063

7164
steps:
7265
- uses: actions/checkout@v4
@@ -114,15 +107,11 @@ jobs:
114107
sudo apt -y install clang gcc-multilib
115108
116109
- name: Install LLVM
117-
if: matrix.llvm != 'source'
118110
run: |
119111
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
112+
wget https://ci-artifacts.rust-lang.org/rustc-builds/${{ env.LLVM_SHA }}/rust-dev-nightly-${{ env.LLVM_TARGET }}.tar.xz
113+
tar -xpf rust-dev-nightly-${{ env.LLVM_TARGET }}.tar.xz --strip-components 1 -C /opt
114+
echo /opt/rust-dev/bin >> $GITHUB_PATH
126115
127116
- name: Restore LLVM
128117
if: matrix.llvm == 'source'
@@ -152,14 +141,14 @@ jobs:
152141
- uses: taiki-e/install-action@cargo-hack
153142

154143
- name: Check
155-
run: cargo hack check --feature-powerset --features llvm-sys/force-dynamic
144+
run: cargo hack check --feature-powerset --features llvm-sys/force-static
156145

157146
- name: Build
158-
run: cargo hack build --feature-powerset --features llvm-sys/force-dynamic
147+
run: cargo hack build --feature-powerset --features llvm-sys/force-static
159148

160149
- name: Test
161150
if: matrix.rust == 'nightly'
162-
run: cargo hack test --feature-powerset --features llvm-sys/force-dynamic
151+
run: cargo hack test --feature-powerset --features llvm-sys/force-static
163152

164153
- uses: actions/checkout@v4
165154
if: matrix.rust == 'nightly'
@@ -170,7 +159,7 @@ jobs:
170159

171160
- name: Install
172161
if: matrix.rust == 'nightly'
173-
run: cargo install --path . --no-default-features --features llvm-sys/force-dynamic
162+
run: cargo install --path . --no-default-features --features llvm-sys/force-static
174163

175164
# TODO: Remove this and run the integration tests on the local machine when they pass on 5.15.
176165
- 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)