Skip to content

Commit 675b4e2

Browse files
jemarchanakryiko
authored andcommitted
bpf: Temporarily define BPF_NO_PRESEVE_ACCESS_INDEX for GCC
The vmlinux.h file generated by bpftool makes use of compiler pragmas in order to install the CO-RE preserve_access_index in all the struct types derived from the BTF info: #ifndef __VMLINUX_H__ #define __VMLINUX_H__ #ifndef BPF_NO_PRESERVE_ACCESS_INDEX #pragma clang attribute push (__attribute__((preserve_access_index)), apply_t = record #endif [... type definitions generated from kernel BTF ... ] #ifndef BPF_NO_PRESERVE_ACCESS_INDEX #pragma clang attribute pop #endif The `clang attribute push/pop' pragmas are specific to clang/llvm and are not supported by GCC. At the moment the BTF dumping services in libbpf do not support dicriminating between types dumped because they are directly referred and types dumped because they are dependencies. A suitable API is being worked now. See [1] and [2]. In the interim, this patch changes the selftests/bpf Makefile so it passes -DBPF_NO_PRESERVE_ACCESS_INDEX to GCC when it builds the selftests. This workaround is temporary, and may have an impact on the results of the GCC-built tests. [1] https://lore.kernel.org/bpf/[email protected]/T/#u [2] https://lore.kernel.org/bpf/[email protected]/T/#u Tested in bpf-next master. No regressions. Signed-off-by: Jose E. Marchesi <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent eda80aa commit 675b4e2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/testing/selftests/bpf/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ endef
431431
# Build BPF object using GCC
432432
define GCC_BPF_BUILD_RULE
433433
$(call msg,GCC-BPF,$(TRUNNER_BINARY),$2)
434-
$(Q)$(BPF_GCC) $3 -Wno-attributes -O2 -c $1 -o $2
434+
$(Q)$(BPF_GCC) $3 -DBPF_NO_PRESERVE_ACCESS_INDEX -Wno-attributes -O2 -c $1 -o $2
435435
endef
436436

437437
SKEL_BLACKLIST := btf__% test_pinning_invalid.c test_sk_assign.c

0 commit comments

Comments
 (0)