Skip to content

eBPF-based security platform

ci: build and test with clang 23 in every job

Daniel Borkmann6442d4c270f6
diff --git a/.github/scripts/build-debian.sh b/.github/scripts/build-debian.sh
index 67840d02..01ac39bc 100755
--- a/.github/scripts/build-debian.sh
+++ b/.github/scripts/build-debian.sh
@@ -4,7 +4,8 @@
#
# .github/scripts/build-debian.sh -- build on a Debian testing container of
# any architecture, with the distribution's compiler and libraries, which
-# are new enough to need no toolchain of their own: the binary and the
+# are new enough to need no toolchain of their own, and clang 23 from
+# unstable through install-clang.sh: the binary and the
# shirudo-build helper, then the unit tests and the linkage check. The BPF
# objects are bytecode whatever the host, so the BTF can come from a
# kernel of another architecture.
@@ -32,9 +33,7 @@ apt-get update
apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
- clang \
git \
- llvm \
openssl \
pkgconf \
python3 \
@@ -44,6 +43,7 @@ apt-get install -y --no-install-recommends \
libssl-dev \
libtss2-dev \
zlib1g-dev
+sh .github/scripts/install-clang.sh
git config --global --add safe.directory "$PWD"
uname -m
diff --git a/.github/scripts/install-clang.sh b/.github/scripts/install-clang.sh
new file mode 100755
index 00000000..37654055
--- /dev/null
+++ b/.github/scripts/install-clang.sh
@@ -0,0 +1,85 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+#
+# .github/scripts/install-clang.sh -- install clang and LLVM 23, the release
+# CI builds and tests with, and make clang, llvm-strip, llvm-objcopy and
+# llvm-symbolizer name it, as shirudo-build runs /usr/bin/clang. Debian
+# unstable, as the LVH guests run it, and Fedora 45 ship it. Debian testing
+# takes it from unstable, at a priority that leaves every other package to
+# testing, and Ubuntu from apt.llvm.org, whose signing key must have the
+# fingerprint below. Further packages from the same sources, a sanitizer
+# runtime for instance, go on the command line.
+#
+# .github/scripts/install-clang.sh [<package>...]
+#
+# Runs as root in a runner, container or LVH guest that is discarded
+# afterwards: it adds package sources and replaces /usr/bin/clang.
+
+set -eu
+
+LLVM=23
+LLVM_APT_KEY=6084F3CF814B57C1CF12EFD515CF4D18AF4F7421
+
+. /etc/os-release
+
+case $ID in
+fedora)
+ dnf -q install -y clang llvm "$@"
+ ;;
+debian | ubuntu)
+ export DEBIAN_FRONTEND=noninteractive
+ apt-get update
+ release=
+ # Debian testing and unstable share one codename, so ask apt.
+ if ! apt-cache policy "clang-$LLVM" | grep -q 'Candidate: [0-9]'; then
+ if [ "$ID" = debian ]; then
+ echo 'deb http://deb.debian.org/debian unstable main' \
+ >/etc/apt/sources.list.d/unstable.list
+ printf 'Package: *\nPin: release a=unstable\nPin-Priority: 100\n' \
+ >/etc/apt/preferences.d/unstable
+ release=unstable
+ else
+ apt-get install -y --no-install-recommends ca-certificates \
+ curl gpg
+ key=$(mktemp)
+ curl -fsSL --retry 3 -o "$key" \
+ https://apt.llvm.org/llvm-snapshot.gpg.key
+ fpr=$(gpg --show-keys --with-colons "$key" |
+ awk -F: '/^fpr/ { print $10; exit }')
+ if [ "$fpr" != "$LLVM_APT_KEY" ]; then
+ printf 'install-clang: apt.llvm.org key %s is not %s\n' \
+ "$fpr" "$LLVM_APT_KEY" >&2
+ exit 1
+ fi
+ gpg --dearmor --yes -o /usr/share/keyrings/apt-llvm.gpg "$key"
+ rm -f "$key"
+ echo "deb [signed-by=/usr/share/keyrings/apt-llvm.gpg] http://apt.llvm.org/$VERSION_CODENAME/ llvm-toolchain-$VERSION_CODENAME-$LLVM main" \
+ >/etc/apt/sources.list.d/apt-llvm.list
+ fi
+ apt-get update
+ fi
+ set -- "clang-$LLVM" "llvm-$LLVM" "$@"
+ if [ -n "$release" ]; then
+ set -- -t "$release" "$@"
+ fi
+ apt-get install -y --no-install-recommends "$@"
+ for tool in clang llvm-strip llvm-objcopy llvm-symbolizer; do
+ ln -sf "/usr/lib/llvm-$LLVM/bin/$tool" "/usr/bin/$tool"
+ done
+ ;;
+*)
+ printf 'install-clang: %s is not supported\n' "$ID" >&2
+ exit 1
+ ;;
+esac
+
+version=$(clang -dumpversion)
+case $version in
+"$LLVM".*) ;;
+*)
+ printf 'install-clang: clang is %s, not %s\n' "$version" "$LLVM" >&2
+ exit 1
+ ;;
+esac
+printf 'install-clang: clang %s\n' "$version"
diff --git a/.github/scripts/lvh-prepare.sh b/.github/scripts/lvh-prepare.sh
index d6010ea6..572402f2 100644
--- a/.github/scripts/lvh-prepare.sh
+++ b/.github/scripts/lvh-prepare.sh
@@ -11,14 +11,13 @@ grep -aq 'signature_size' /sys/kernel/btf/vmlinux || {
}
cd /host
+sh .github/scripts/install-clang.sh
apt-get update
apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
- clang \
cryptsetup-bin \
e2fsprogs \
- llvm \
python3 \
pkg-config \
autoconf \
diff --git a/.github/scripts/tests.sh b/.github/scripts/tests.sh
index d93805b8..7416da3e 100755
--- a/.github/scripts/tests.sh
+++ b/.github/scripts/tests.sh
@@ -221,15 +221,11 @@ setup() {
mkdir -p build
sudo BPF_VMLINUX_BTF="$PWD/$kernel/vmlinux.btf" \
.github/scripts/vm-toolchain.sh \
- autoconf autoconf-archive automake clang-20 cloud-image-utils \
+ autoconf autoconf-archive automake cloud-image-utils \
dracut-core file isc-dhcp-client libguestfs-tools libltdl-dev \
libtool libzstd-dev cryptsetup-bin e2fsprogs qemu-system-x86 qemu-utils swtpm \
swtpm-tools tpm2-tools coccinelle
- # Ubuntu 24.04's clang 18 lacks the BPF address-space casts the
- # arena upatches need, and shirudo-build runs /usr/bin/clang.
- sudo ln -sf clang-20 /usr/bin/clang
-
# Ubuntu's dracut 060 looks for systemd-pcrphase, which systemd 255
# calls systemd-pcrextend, and so leaves out the PCR phase
# measurement shirudo's initrd needs.
diff --git a/.github/scripts/vm-toolchain.sh b/.github/scripts/vm-toolchain.sh
index ad231175..40a62a01 100755
--- a/.github/scripts/vm-toolchain.sh
+++ b/.github/scripts/vm-toolchain.sh
@@ -4,8 +4,9 @@
#
# .github/scripts/vm-toolchain.sh -- prepare the LVH guest a workflow builds
# in, or the runner itself: check that the kernel the BPF objects are
-# built for takes signed BPF, install the build dependencies and build an
-# OpenSSL 3.5 toolchain, since the distribution's predates ML-DSA. The
+# built for takes signed BPF, install clang 23 with install-clang.sh and the
+# build dependencies, and build an OpenSSL 3.5 toolchain, since the
+# distribution's predates ML-DSA. The
# environment the build then needs is written to build/vm-toolchain.env
# for the caller to source.
#
@@ -32,14 +33,13 @@ grep -aq 'signature_size' "$btf" || {
exit 1
}
+sh "$root/.github/scripts/install-clang.sh"
apt-get update
apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
- clang \
cryptsetup-bin \
e2fsprogs \
- llvm \
curl \
git \
pkg-config \
diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml
index 18ef5d3b..ef6c3948 100644
--- a/.github/workflows/coverity.yml
+++ b/.github/workflows/coverity.yml
@@ -58,8 +58,6 @@ jobs:
apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
- clang \
- llvm \
curl \
git \
pkg-config \
@@ -70,6 +68,7 @@ jobs:
libtpms-dev \
libtss2-dev \
zlib1g-dev
+ sh .github/scripts/install-clang.sh
git config --global --add safe.directory /host
diff --git a/.github/workflows/deb.yml b/.github/workflows/deb.yml
index 2c1c30b2..fd569760 100644
--- a/.github/workflows/deb.yml
+++ b/.github/workflows/deb.yml
@@ -255,14 +255,14 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
container:
- image: fedora:44
+ image: fedora:45
options: --ulimit memlock=-1:-1
steps:
- name: Install the build dependencies
run: |
dnf -q install -y gcc make pkgconf-pkg-config git python3 rpm-build \
- clang llvm cryptsetup openssl openssl-devel libcurl-devel tpm2-tss-devel \
+ cryptsetup openssl openssl-devel libcurl-devel tpm2-tss-devel \
elfutils-libelf-devel zlib-ng-compat-devel luajit-devel jq
- name: Check out repository
@@ -270,6 +270,9 @@ jobs:
with:
fetch-depth: 0
+ - name: Install clang 23
+ run: sh .github/scripts/install-clang.sh
+
- name: Download the target rpm package
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
diff --git a/.github/workflows/kernel-obs.yml b/.github/workflows/kernel-obs.yml
index 9ec8700e..0c636b63 100644
--- a/.github/workflows/kernel-obs.yml
+++ b/.github/workflows/kernel-obs.yml
@@ -164,6 +164,7 @@ jobs:
/bin/sh /host/.github/scripts/kernel-obs-apt-diagnostics.sh
exit 1
fi
+ sh /host/.github/scripts/install-clang.sh
keys_dir=/host/.ci/kernel-obs-keys
version=\$(cat /host/build/kernel-obs-version)
diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml
index 42216882..ee026303 100644
--- a/.github/workflows/sanitizers.yml
+++ b/.github/workflows/sanitizers.yml
@@ -56,11 +56,8 @@ jobs:
apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
- clang \
cryptsetup-bin \
e2fsprogs \
- libclang-rt-21-dev \
- llvm \
curl \
git \
pkg-config \
@@ -71,6 +68,7 @@ jobs:
libtpms-dev \
libtss2-dev \
zlib1g-dev
+ sh .github/scripts/install-clang.sh libclang-rt-23-dev
git config --global --add safe.directory /host
@@ -131,7 +129,7 @@ jobs:
mem: 8G
cmd: |
cd /host
- .github/scripts/vm-toolchain.sh libclang-rt-21-dev
+ .github/scripts/vm-toolchain.sh libclang-rt-23-dev
. build/vm-toolchain.env
make -C testing fuzz \
FUZZ_SECONDS=${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && 600 || 60 }} \
diff --git a/AGENTS.md b/AGENTS.md
index 290475c6..d6d71e69 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -312,7 +312,9 @@ one usually still compiles and passes tests.
grows the TCB; the agentless design exists to keep it minimal.
- **Bleeding-edge kernel and toolchain only.** The signed-loader ABI
described in `Documentation/operate/plan/system-requirements.rst` and
- current clang/LLVM are hard prerequisites. Development trees can
+ current clang/LLVM, release 23, are hard prerequisites. Every CI job
+ installs it with `.github/scripts/install-clang.sh`; verify compiler
+ behavior with it, not an older host clang. Development trees can
expose that ABI before the corresponding release number changes; use a
verified commit, not just `uname`, to identify the tested kernel. No
legacy-kernel fallback paths; a missing kernel feature fails the build
diff --git a/Documentation/contribute/code/developer-guide.rst b/Documentation/contribute/code/developer-guide.rst
index f66e1a87..aa05a9a4 100644
--- a/Documentation/contribute/code/developer-guide.rst
+++ b/Documentation/contribute/code/developer-guide.rst
@@ -19,10 +19,10 @@ Before you begin
- A Linux host on x86-64, arm64 or riscv64. The test VM runs on x86-64
and arm64 hosts only.
-- A C compiler, GNU make, ``pkg-config``, ``python3`` and a current
- ``clang`` and ``llvm`` with the BPF target. CI installs clang 20 on
- its Ubuntu runners because clang 18 lacks the BPF address-space casts
- that arena upatches need.
+- A C compiler, GNU make, ``pkg-config``, ``python3``, and ``clang`` and
+ ``llvm`` 23 with the BPF target, the release CI builds and tests with.
+ :src:`.github/scripts/install-clang.sh` installs them on Debian, Ubuntu
+ and Fedora.
- The development files that :src:`Makefile.config` probes for with
``pkg-config``:
@@ -451,8 +451,15 @@ the commit at ``HEAD`` alone without them.
shirudo-build`` and ``make -C testing test-helpers``. It
refuses to start with uncommitted changes and checks out each
commit in the working tree.
+ * - ``install-clang.sh [<package>...]``
+ - Installs clang and LLVM 23, from the distribution, Debian unstable
+ or apt.llvm.org, and points ``clang``, ``llvm-strip``,
+ ``llvm-objcopy`` and ``llvm-symbolizer`` in ``/usr/bin`` at them.
+ Every CI job that compiles runs it. It installs packages as root,
+ so run it only in a throwaway container or VM.
* - ``build-debian.sh <btf>``
- - Installs Debian testing's compiler and libraries, builds the
+ - Installs Debian testing's compiler and libraries and clang 23
+ from unstable, builds the
binary and the helper with the BTF given, and runs the unit tests
and ``check-operator-linkage.sh``. The ``Build`` workflow runs it
in a ``debian:testing`` container on arm64 and riscv64. It
diff --git a/Documentation/contribute/testing/testing.rst b/Documentation/contribute/testing/testing.rst
index 033c04d5..51c8a179 100644
--- a/Documentation/contribute/testing/testing.rst
+++ b/Documentation/contribute/testing/testing.rst
@@ -231,7 +231,7 @@ Run the fuzz targets
--------------------
The fuzz targets cover the parsers of input from outside the host. They
-need clang with its libFuzzer runtime, ``libclang-rt-21-dev`` on the CI
+need clang with its libFuzzer runtime, ``libclang-rt-23-dev`` on the CI
runner.
1. Build and run every target on its seed corpus for 60 seconds each:
diff --git a/Documentation/operate/plan/system-requirements.rst b/Documentation/operate/plan/system-requirements.rst
index 5fe450de..0803624d 100644
--- a/Documentation/operate/plan/system-requirements.rst
+++ b/Documentation/operate/plan/system-requirements.rst
@@ -411,9 +411,10 @@ keyrings. Any Linux kernel on which the tools below run serves.
``tss2-tctildr``, ``libelf``, ``zlib``, LuaJIT
- Linked by the ``shirudo`` binary, which is the same program on
both roles.
- * - ``clang`` and LLVM with the BPF target, installed as
+ * - ``clang`` and LLVM 23 with the BPF target, ``clang`` installed as
``/usr/bin/clang``
- ``shirudo build`` runs that path and does not search ``PATH``.
+ It compiles for BPF instruction set v4.
* - The target kernel's ``vmlinux.h``
- The one kernel-derived input of a build. ``shirudo build`` takes
``--vmlinux``, else ``./vmlinux.h``, else
@@ -431,8 +432,9 @@ keyrings. Any Linux kernel on which the tools below run serves.
they dispatch a command.
The operator package depends on ``clang``, ``llvm`` and the
-``veritysetup`` package. The operator and target packages conflict, so
-one host cannot install both.
+``veritysetup`` package. Where the distribution's ``clang`` is older than
+23, install clang 23 and point ``/usr/bin/clang`` at it. The operator and
+target packages conflict, so one host cannot install both.
Build host for the target binary
--------------------------------
@@ -464,7 +466,7 @@ target-deps`` first.
static PIE support (``libc6-dev`` on Debian, ``glibc-static`` on
Fedora)
- The static PIE link. They come from the compiler's sysroot.
- * - ``clang`` with the BPF target
+ * - ``clang`` 23 with the BPF target
- The BPF objects embedded in the binary.
* - BTF of a kernel with the signed-loader ABI
- The embedded BPF objects read ``prog->aux->sig`` and do not