From 7ccbaf5fab2d195d3b02fa8155ef09c79fc24807 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Fri, 7 Aug 2026 11:23:09 -0500 Subject: [PATCH 1/4] testsuite: Match kernel compiler for external modules Check if kernel was built with clang and then pass LLVM=1. Otherwise kbuild will try to use several flags that are not compatible. Signed-off-by: Lucas De Marchi --- testsuite/module-playground/Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/testsuite/module-playground/Makefile b/testsuite/module-playground/Makefile index 61072c7ac..2786659f2 100644 --- a/testsuite/module-playground/Makefile +++ b/testsuite/module-playground/Makefile @@ -19,6 +19,11 @@ else ifeq ($(KDIR),any) KDIR := $(shell find $(MODULE_DIRECTORY) -maxdepth 1 -mindepth 1 -type d | sort -V | tail -n1)/build endif +KERNEL_MAKE_ARGS := M=$$PWD +ifeq ($(origin LLVM), undefined) + KERNEL_MAKE_ARGS += $(shell grep -qs "^CONFIG_CC_IS_CLANG=y" "$(KDIR)/include/config/auto.conf" && printf 'LLVM=1') +endif + ARCH_SPECIFIC_MODULES := mod-simple-x86_64.ko mod-simple-i386.ko mod-simple-sparc64.ko default: modules @@ -28,9 +33,9 @@ mod-simple-%.ko: mod-simple-%.c Makefile.arch $(MAKE) KDIR=$(KDIR_$(arch)) ARCH=$(arch) CROSS_COMPILE=$(CROSS_COMPILE_$(arch)) -f Makefile.arch modules: - $(MAKE) -C $(KDIR) M=$$PWD modules + $(MAKE) -C $(KDIR) $(KERNEL_MAKE_ARGS) modules arch-modules: $(ARCH_SPECIFIC_MODULES) clean: - $(MAKE) -C $(KDIR) M=$$PWD clean + $(MAKE) -C $(KDIR) $(KERNEL_MAKE_ARGS) clean From ada8348c1e437cf31413c7c23ff695a2de9db4fa Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Fri, 7 Aug 2026 11:23:10 -0500 Subject: [PATCH 2/4] testsuite: Workaround BTF failures When trying to run the testsuite in CachyOS that has a kernel built with clang, the following errors show up after linking the modules: FAILED: btf permute: Invalid argument FAILED to sort BTF: Invalid argument This may happen when kernel is built with CONFIG_DEBUG_INFO_BTF_MODULES=y and there's a tool mismatch (e.g. the pahole version), a bug in pahole itself or the build system. Workaround that by simply disabling btf generation from kernel's scripts/gen-btf.sh: BTF sections are not needed at all for our testsuite. Signed-off-by: Lucas De Marchi --- testsuite/module-playground/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/testsuite/module-playground/Makefile b/testsuite/module-playground/Makefile index 2786659f2..0ef0d88df 100644 --- a/testsuite/module-playground/Makefile +++ b/testsuite/module-playground/Makefile @@ -22,6 +22,7 @@ endif KERNEL_MAKE_ARGS := M=$$PWD ifeq ($(origin LLVM), undefined) KERNEL_MAKE_ARGS += $(shell grep -qs "^CONFIG_CC_IS_CLANG=y" "$(KDIR)/include/config/auto.conf" && printf 'LLVM=1') + KERNEL_MAKE_ARGS += CONFIG_DEBUG_INFO_BTF_MODULES= endif ARCH_SPECIFIC_MODULES := mod-simple-x86_64.ko mod-simple-i386.ko mod-simple-sparc64.ko From 905572db95497d152e49b7446a21319c3259962f Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Fri, 7 Aug 2026 11:23:11 -0500 Subject: [PATCH 3/4] ci: Fix typo s/ldd/lld/ Signed-off-by: Lucas De Marchi --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0a93a1984..72ff279d6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -63,7 +63,7 @@ jobs: - container: 'archlinux:multilib-devel' only_bits: '64' only_compiler: 'clang' - custom: 'ldd-as-linker' + custom: 'lld-as-linker' linker: 'lld' # Variants with moduledir From 1df172245fb1930760dc7932b96ae1f09adbc9fe Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Fri, 7 Aug 2026 11:23:11 -0500 Subject: [PATCH 4/4] ci: Plumb cachyos support This should allow us testing with a kernel built with clang. Signed-off-by: Lucas De Marchi --- .github/actions/setup-os/setup-cachyos.sh | 23 +++++++++++++++++++++++ .github/workflows/main.yml | 7 +++++++ 2 files changed, 30 insertions(+) create mode 100755 .github/actions/setup-os/setup-cachyos.sh diff --git a/.github/actions/setup-os/setup-cachyos.sh b/.github/actions/setup-os/setup-cachyos.sh new file mode 100755 index 000000000..2b9e3c5b0 --- /dev/null +++ b/.github/actions/setup-os/setup-cachyos.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# SPDX-FileCopyrightText: 2024 Emil Velikov +# SPDX-FileCopyrightText: 2024 Lucas De Marchi +# +# SPDX-License-Identifier: LGPL-2.1-or-later + +# Semi-regularly the packager key may have (temporarily) expired. Somewhat +# robust solution is to wipe the local keyring and regenerate/reinstall it +# prior to any other packages on the system. +rm -rf /etc/pacman.d/gnupg +pacman-key --init +pacman-key --populate +pacman --noconfirm -Sy archlinux-keyring + +pacman --noconfirm -Su \ + clang \ + git \ + gtk-doc \ + linux-cachyos-headers \ + lld \ + mbedtls \ + meson \ + scdoc diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 72ff279d6..61b79654d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -66,6 +66,13 @@ jobs: custom: 'lld-as-linker' linker: 'lld' + # Variant with kernel built with clang + - container: 'cachyos/cachyos:latest' + only_bits: '64' + only_compiler: 'clang' + custom: 'clang-kernel' + linker: 'lld' + # Variants with moduledir - container: 'archlinux:multilib-devel' meson_setup: '-Dmoduledir=/usr/lib/modules'