Various compilation errors happen when BPF programs in selftests/bpf are built with GCC BPF. For more details see the discussion at [1]. The changes only affect test_progs-bpf_gcc, which is built only if BPF_GCC is set: * Pass -std=gnu17 to gcc in order to avoid errors on bool types declarations in vmlinux.h * Pass -fno-strict-aliasing for tests that trigger uninitialized variable warning on BPF_RAW_INSNS [2] [1] https://lore.kernel.org/bpf/EYcXjcKDCJY7Yb0GGtAAb7nLKPEvrgWdvWpuNzXm2qi6rYMZDixKv5KwfVVMBq17V55xyC-A1wIjrqG3aw-Imqudo9q9X7D7nLU2gWgbN0w=@pm.me/ [2] https://lore.kernel.org/bpf/87pll3c8bt.fsf@xxxxxxxxxx/ CC: Jose E. Marchesi <jose.marchesi@xxxxxxxxxx> Signed-off-by: Ihor Solodrai <ihor.solodrai@xxxxx> --- v1: https://lore.kernel.org/bpf/20250104001751.1869849-1-ihor.solodrai@xxxxx/ tools/testing/selftests/bpf/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index eb4d21651aa7..b043791fe6db 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -69,6 +69,10 @@ progs/timer_crash.c-CFLAGS := -fno-strict-aliasing progs/test_global_func9.c-CFLAGS := -fno-strict-aliasing progs/verifier_nocsr.c-CFLAGS := -fno-strict-aliasing +# Uninitialized variable warning on BPF_RAW_INSN +progs/verifier_bpf_fastcall.c-CFLAGS := -fno-strict-aliasing +progs/verifier_search_pruning.c-CFLAGS := -fno-strict-aliasing + # Some utility functions use LLVM libraries jit_disasm_helpers.c-CFLAGS = $(LLVM_CFLAGS) @@ -507,7 +511,7 @@ endef # Build BPF object using GCC define GCC_BPF_BUILD_RULE $(call msg,GCC-BPF,$4,$2) - $(Q)$(BPF_GCC) $3 -DBPF_NO_PRESERVE_ACCESS_INDEX -Wno-attributes -O2 -c $1 -o $2 + $(Q)$(BPF_GCC) $3 -DBPF_NO_PRESERVE_ACCESS_INDEX -Wno-attributes -O2 -std=gnu17 -c $1 -o $2 endef SKEL_BLACKLIST := btf__% test_pinning_invalid.c test_sk_assign.c -- 2.47.1