diff options
| author | Blake Jones <blakejones@google.com> | 2025-06-12 12:49:35 -0700 |
|---|---|---|
| committer | Namhyung Kim <namhyung@kernel.org> | 2025-06-20 14:48:14 -0700 |
| commit | 1d0654b7fdc5431b85035f6e76b4bc57679575d8 (patch) | |
| tree | 20e52c0cbc88f33780a68a94bc454f2c55808e1c /tools/build | |
| parent | 13b38e6b8059de096ebddb5d770c2419943949b7 (diff) | |
perf build: detect support for libbpf's emit_strings option
This creates a config option that detects libbpf's ability to display
character arrays as strings, which was just added to the BPF tree
(https://git.kernel.org/bpf/bpf-next/c/87c9c79a02b4).
To test this change, I built perf (from later in this patch set) with:
- static libbpf (default, using source from kernel tree)
- dynamic libbpf (LIBBPF_DYNAMIC=1 LIBBPF_INCLUDE=/usr/local/include)
For both the static and dynamic versions, I used headers with and without
the ".emit_strings" option.
I verified that of the four resulting binaries, the two with
".emit_strings" would successfully record BPF_METADATA events, and the two
without wouldn't. All four binaries would successfully display
BPF_METADATA events, because the relevant bit of libbpf code is only used
during "perf record".
Signed-off-by: Blake Jones <blakejones@google.com>
Link: https://lore.kernel.org/r/20250612194939.162730-2-blakejones@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'tools/build')
| -rw-r--r-- | tools/build/Makefile.feature | 1 | ||||
| -rw-r--r-- | tools/build/feature/Makefile | 4 | ||||
| -rw-r--r-- | tools/build/feature/test-libbpf-strings.c | 10 |
3 files changed, 15 insertions, 0 deletions
diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature index 3a1fddd38db0..2e5f4c8b6547 100644 --- a/tools/build/Makefile.feature +++ b/tools/build/Makefile.feature @@ -126,6 +126,7 @@ FEATURE_TESTS_EXTRA := \ llvm \ clang \ libbpf \ + libbpf-strings \ libpfm4 \ libdebuginfod \ clang-bpf-co-re \ diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index 4aa166d3eab6..0c4e541ed56e 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -59,6 +59,7 @@ FILES= \ test-lzma.bin \ test-bpf.bin \ test-libbpf.bin \ + test-libbpf-strings.bin \ test-get_cpuid.bin \ test-sdt.bin \ test-cxx.bin \ @@ -339,6 +340,9 @@ $(OUTPUT)test-bpf.bin: $(OUTPUT)test-libbpf.bin: $(BUILD) -lbpf +$(OUTPUT)test-libbpf-strings.bin: + $(BUILD) + $(OUTPUT)test-sdt.bin: $(BUILD) diff --git a/tools/build/feature/test-libbpf-strings.c b/tools/build/feature/test-libbpf-strings.c new file mode 100644 index 000000000000..83e6c45f5c85 --- /dev/null +++ b/tools/build/feature/test-libbpf-strings.c @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <bpf/btf.h> + +int main(void) +{ + struct btf_dump_type_data_opts opts; + + opts.emit_strings = 0; + return opts.emit_strings; +} |
