[PATCH] selftests/bpf: workarounds for GCC BPF build

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 when  to avoid errors on bool
    types declarations in vmlinux.h
  * Pass -nostdinc for tests that trigger int64_t declaration
    collision due to a difference between gcc and clang stdint.h
  * Pass -Wno-error for tests that trigger uninitialized variable
    warning pm BPF_RAW_INSNS

[1] https://lore.kernel.org/bpf/EYcXjcKDCJY7Yb0GGtAAb7nLKPEvrgWdvWpuNzXm2qi6rYMZDixKv5KwfVVMBq17V55xyC-A1wIjrqG3aw-Imqudo9q9X7D7nLU2gWgbN0w=@pm.me/

Signed-off-by: Ihor Solodrai <ihor.solodrai@xxxxx>
---
 tools/testing/selftests/bpf/Makefile | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 9e870e519c30..2e1fe53efa83 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -103,6 +103,15 @@ progs/btf_dump_test_case_packing.c-bpf_gcc-CFLAGS := -Wno-error
 progs/btf_dump_test_case_padding.c-bpf_gcc-CFLAGS := -Wno-error
 progs/btf_dump_test_case_syntax.c-bpf_gcc-CFLAGS := -Wno-error
 
+# Uninitialized variable warning on BPF_RAW_INSN
+progs/verifier_bpf_fastcall.c-CFLAGS := -Wno-error
+progs/verifier_search_pruning.c-CFLAGS := -Wno-error
+
+# int64_t declaration collision
+progs/test_cls_redirect.c-CFLAGS := -nostdinc
+progs/test_cls_redirect_dynptr.c-CFLAGS := -nostdinc
+progs/test_cls_redirect_subprogs.c-CFLAGS := -nostdinc
+
 # The following tests do type-punning, via the __imm_insn macro, from
 # `struct bpf_insn' to long and then uses the value.  This triggers an
 # "is used uninitialized" warning in GCC due to strict-aliasing
@@ -507,7 +516,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







[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux