Skip to content

Commit

Permalink
ci: get bpf clang from pinned nixpkgs
Browse files Browse the repository at this point in the history
This PR represents a move towards reproducible builds starting with the clang
version, which causes possible complications due to subtle differences in BPF
assembly generation. This specifically moves us from `18.1.3 (ubuntu)`, bundled
with the CI system, to `18.1.8` (Nix's version). Moreover, it pins the version
in perpetuity. If the Nix caches dry up for some reason, we will build clang
and its dependencies from source, making this specific part of our CI fully
reproducible.

This PR does not go any further in making the build reproducible, only the BPF
ASM generation part of the meson build. We can see this version reported
correctly in the CI logs. The BPF generation is very specific to clang version
and this change pulls a more recently patched version & ensures it never
changes on old commits.

While this change doesn't force any user of the repository to use Nix in the
build, it begins to offer the option. Other open source repositories[1] are
taking advantage of Nix's ability to offer devshells in a more complete way,
which enable reproducible builds regardless of the end user's operating system
and package setup, that don't interfere with whatever they have setup already.
This is future work - one of the most frustrating things as a developer is when
the CI fails and you can't reproduce it locally. `nix develop` fixes this, and
should come down the line to make our builds fully reproducible.

Test plan:
- CI

[1] https://github.com/bpftrace/bpftrace/blob/master/flake.nix
  • Loading branch information
JakeHillion committed Dec 2, 2024
1 parent 91b147c commit 71c0d80
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .github/actions/install-deps-action/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ runs:
### DOWNLOAD AND INSTALL DEPENDENCIES ###

# Get some packages from nixpkgs for newer revisions
- uses: DeterminateSystems/nix-installer-action@main
- run: |
nix registry add nixpkgs github:NixOS/nixpkgs/8edf06bea5bcbee082df1b7369ff973b91618b8d
echo "BPF_CLANG=$(nix build --print-out-paths --no-link nixpkgs#clang)/bin/clang" >> $GITHUB_ENV
shell: bash
# Download dependencies packaged by Ubuntu
- run: |
sudo apt install -f -y bison busybox-static cmake coreutils \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/caching-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ jobs:
- run: sudo chmod +x /usr/bin/veristat && sudo chmod 755 /usr/bin/veristat

# The actual build:
- run: meson setup build -Dkernel=../linux/arch/x86/boot/bzImage -Dkernel_headers=../linux -Denable_stress=true -Dvng_rw_mount=true
- run: meson setup build -Dkernel=../linux/arch/x86/boot/bzImage -Dkernel_headers=../linux -Denable_stress=true -Dvng_rw_mount=true -Dbpf_clang="$BPF_CLANG"
- run: meson compile -C build ${{ matrix.scheduler }}

# Print CPU model before running the tests (this can be useful for
Expand Down

0 comments on commit 71c0d80

Please sign in to comment.