samples/bpf: Change _kern suffix to .bpf with syscall tracing program
authorDaniel T. Lee <danieltimlee@gmail.com>
Sat, 24 Dec 2022 07:15:24 +0000 (16:15 +0900)
committerAndrii Nakryiko <andrii@kernel.org>
Thu, 29 Dec 2022 22:22:34 +0000 (14:22 -0800)
commitd4fffba4d04b8d605ff07f1ed987399f6af0ad5b
tree0405767945159b3efca7c39d81853d0dea6f7a5c
parent8a4dd0bcbdfd5bdaa5d1a5b390f44a45b60e8aa9
samples/bpf: Change _kern suffix to .bpf with syscall tracing program

Currently old compile rule (CLANG-bpf) doesn't contains VMLINUX_H define
flag which is essential for the bpf program that includes "vmlinux.h".
Also old compile rule doesn't directly specify the compile target as bpf,
instead it uses bunch of extra options with clang followed by long chain
of commands. (e.g. clang | opt | llvm-dis | llc)

In Makefile, there is already new compile rule which is more simple and
neat. And it also has -D__VMLINUX_H__ option. By just changing the _kern
suffix to .bpf will inherit the benefit of the new CLANG-BPF compile
target.

Also, this commit adds dummy gnu/stub.h to the samples/bpf directory.
As commit 1c2dd16add7e ("selftests/bpf: get rid of -D__x86_64__") noted,
compiling with 'clang -target bpf' will raise an error with stubs.h
unless workaround (-D__x86_64) is used. This commit solves this problem
by adding dummy stub.h to make /usr/include/features.h to follow the
expected path as the same way selftests/bpf dealt with.

Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20221224071527.2292-4-danieltimlee@gmail.com
17 files changed:
samples/bpf/Makefile
samples/bpf/gnu/stubs.h [new file with mode: 0644]
samples/bpf/map_perf_test.bpf.c [new file with mode: 0644]
samples/bpf/map_perf_test_kern.c [deleted file]
samples/bpf/map_perf_test_user.c
samples/bpf/test_current_task_under_cgroup.bpf.c [new file with mode: 0644]
samples/bpf/test_current_task_under_cgroup_kern.c [deleted file]
samples/bpf/test_current_task_under_cgroup_user.c
samples/bpf/test_probe_write_user.bpf.c [new file with mode: 0644]
samples/bpf/test_probe_write_user_kern.c [deleted file]
samples/bpf/test_probe_write_user_user.c
samples/bpf/trace_output.bpf.c [new file with mode: 0644]
samples/bpf/trace_output_kern.c [deleted file]
samples/bpf/trace_output_user.c
samples/bpf/tracex2.bpf.c [new file with mode: 0644]
samples/bpf/tracex2_kern.c [deleted file]
samples/bpf/tracex2_user.c