kselftests-bpf: isolate target userspace compiler flags

Passing target flags through EXTRA_CFLAGS leaks them into kernel
module builds on Linux 6.6 and 6.12, causing ARM hard-float ABI
mismatches in generated module objects. Linux 6.18 also forwards
these flags to host tools, where the host compiler rejects them.

Reuse SAN_CFLAGS, normally used for sanitizer options, to pass
target flags to both userspace selftests and their target libbpf
builds on Linux 6.6, 6.12 and 6.18. Host tools and kernel modules
do not consume this variable. USERCFLAGS would only cover the
selftests, leaving their libbpf builds without the target flags.

This covers the targets built by this package; CROSS_BPFTOOL
does not consume SAN_CFLAGS.

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
Link: https://github.com/openwrt/openwrt/pull/25345
Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
Tianling Shen authored and Robert Marko committed 2026-09-29 09:29:09 +02:00
1 parent a5bc79c39b
commit 8694449c7a
1 file changed
+3 -1
+3 -1
View File
@@ -42,10 +42,12 @@ MOD_TARGETS:= \
MAKE_PATH:=tools/testing/selftests/bpf
# Use SAN_CFLAGS to cover target libbpf as well as userspace selftests,
# without passing target flags to host tools or kernel modules.
MAKE_VARS:= \
ARCH="$(LINUX_KARCH)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
EXTRA_CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
SAN_CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
LDLIBS="$(TARGET_LDFLAGS)" \
TOOLCHAIN_INCLUDE="$(TOOLCHAIN_INC_DIRS)" \
KBUILD_OUTPUT="$(LINUX_DIR)"