Re: [RFC 1/2] perf: support build BPF skeletons with perf

From: Song Liu
Date: Tue Nov 24 2020 - 18:51:46 EST




> On Nov 22, 2020, at 3:32 PM, Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
>
> On Wed, Nov 18, 2020 at 08:50:45PM -0800, Song Liu wrote:
>
> SNIP
>
>> diff --git a/tools/perf/util/bpf_skel/.gitignore b/tools/perf/util/bpf_skel/.gitignore
>> new file mode 100644
>> index 0000000000000..5263e9e6c5d83
>> --- /dev/null
>> +++ b/tools/perf/util/bpf_skel/.gitignore
>> @@ -0,0 +1,3 @@
>> +# SPDX-License-Identifier: GPL-2.0-only
>> +.tmp
>> +*.skel.h
>> \ No newline at end of file
>> diff --git a/tools/perf/util/bpf_skel/Makefile b/tools/perf/util/bpf_skel/Makefile
>> new file mode 100644
>> index 0000000000000..853bece088f4b
>> --- /dev/null
>> +++ b/tools/perf/util/bpf_skel/Makefile
>> @@ -0,0 +1,71 @@
>> +# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
>> +SKEL_OUTPUT := $(abspath .)
>> +TMP_OUTPUT := $(abspath .tmp)
>> +CLANG ?= clang
>> +LLC ?= llc
>> +LLVM_STRIP ?= llvm-strip
>> +DEFAULT_BPFTOOL := $(TMP_OUTPUT)/sbin/bpftool
>> +BPFTOOL ?= $(DEFAULT_BPFTOOL)
>> +LIBBPF_SRC := $(abspath ../../../lib/bpf)
>> +BPFOBJ := $(TMP_OUTPUT)/libbpf.a
>> +BPF_INCLUDE := $(TMP_OUTPUT)
>> +INCLUDES := -I$(TMP_OUTPUT) -I$(BPF_INCLUDE) -I$(abspath ../../../lib) \
>> + -I$(abspath ../../../include/uapi)
>> +CFLAGS := -g -Wall
>> +
>> +# Try to detect best kernel BTF source
>> +KERNEL_REL := $(shell uname -r)
>> +VMLINUX_BTF_PATHS := /sys/kernel/btf/vmlinux /boot/vmlinux-$(KERNEL_REL)
>> +VMLINUX_BTF_PATH := $(or $(VMLINUX_BTF),$(firstword \
>> + $(wildcard $(VMLINUX_BTF_PATHS))))
>> +ifeq ($(V),1)
>> +Q =
>> +msg =
>> +else
>> +Q = @
>> +msg = @printf ' %-8s %s%s\n' "$(1)" "$(notdir $(2))" "$(if $(3), $(3))";
>> +MAKEFLAGS += --no-print-directory
>> +submake_extras := feature_display=0
>> +endif
>
> some of the above should already be defined in the base Makefile.perf
> we should use that, I think it'd fit better in the Makefile.perf itself

Let me try that. OTOH, I think Makefile.perf is a little too big (1k+ lines)..

Thanks,
Song