Skip to content

Commit 6b491a8

Browse files
qmonnetacmel
authored andcommitted
perf build: Install libbpf headers locally when building
API headers from libbpf should not be accessed directly from the library's source directory. Instead, they should be exported with "make install_headers". Let's adjust perf's Makefile to install those headers locally when building libbpf. v2: - Fix $(LIBBPF_OUTPUT) when $(OUTPUT) is null. - Make sure the recipe for $(LIBBPF_OUTPUT) is not under a "ifdef". Signed-off-by: Quentin Monnet <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Andrii Nakryiko <[email protected]> Cc: Daniel Borkmann <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Song Liu <[email protected]> Cc: [email protected] Cc: [email protected] Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent f174940 commit 6b491a8

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

tools/perf/Makefile.perf

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ else # force_fixdep
243243

244244
LIB_DIR = $(srctree)/tools/lib/api/
245245
TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/
246-
BPF_DIR = $(srctree)/tools/lib/bpf/
246+
LIBBPF_DIR = $(srctree)/tools/lib/bpf/
247247
SUBCMD_DIR = $(srctree)/tools/lib/subcmd/
248248
LIBPERF_DIR = $(srctree)/tools/lib/perf/
249249
DOC_DIR = $(srctree)/tools/perf/Documentation/
@@ -295,7 +295,6 @@ strip-libs = $(filter-out -l%,$(1))
295295
ifneq ($(OUTPUT),)
296296
TE_PATH=$(OUTPUT)
297297
PLUGINS_PATH=$(OUTPUT)
298-
BPF_PATH=$(OUTPUT)
299298
SUBCMD_PATH=$(OUTPUT)
300299
LIBPERF_PATH=$(OUTPUT)
301300
ifneq ($(subdir),)
@@ -307,7 +306,6 @@ else
307306
TE_PATH=$(TRACE_EVENT_DIR)
308307
PLUGINS_PATH=$(TRACE_EVENT_DIR)plugins/
309308
API_PATH=$(LIB_DIR)
310-
BPF_PATH=$(BPF_DIR)
311309
SUBCMD_PATH=$(SUBCMD_DIR)
312310
LIBPERF_PATH=$(LIBPERF_DIR)
313311
endif
@@ -326,7 +324,14 @@ LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS = $(if $(findstring -static,$(LDFLAGS)),,$(DY
326324
LIBAPI = $(API_PATH)libapi.a
327325
export LIBAPI
328326

329-
LIBBPF = $(BPF_PATH)libbpf.a
327+
ifneq ($(OUTPUT),)
328+
LIBBPF_OUTPUT = $(abspath $(OUTPUT))/libbpf
329+
else
330+
LIBBPF_OUTPUT = $(CURDIR)/libbpf
331+
endif
332+
LIBBPF_DESTDIR = $(LIBBPF_OUTPUT)
333+
LIBBPF_INCLUDE = $(LIBBPF_DESTDIR)/include
334+
LIBBPF = $(LIBBPF_OUTPUT)/libbpf.a
330335

331336
LIBSUBCMD = $(SUBCMD_PATH)libsubcmd.a
332337

@@ -831,12 +836,14 @@ $(LIBAPI)-clean:
831836
$(call QUIET_CLEAN, libapi)
832837
$(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) clean >/dev/null
833838

834-
$(LIBBPF): FORCE
835-
$(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) $(OUTPUT)libbpf.a FEATURES_DUMP=$(FEATURE_DUMP_EXPORT)
839+
$(LIBBPF): FORCE | $(LIBBPF_OUTPUT)
840+
$(Q)$(MAKE) -C $(LIBBPF_DIR) FEATURES_DUMP=$(FEATURE_DUMP_EXPORT) \
841+
O= OUTPUT=$(LIBBPF_OUTPUT)/ DESTDIR=$(LIBBPF_DESTDIR) prefix= \
842+
$@ install_headers
836843

837844
$(LIBBPF)-clean:
838845
$(call QUIET_CLEAN, libbpf)
839-
$(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) clean >/dev/null
846+
$(Q)$(RM) -r -- $(LIBBPF_OUTPUT)
840847

841848
$(LIBPERF): FORCE
842849
$(Q)$(MAKE) -C $(LIBPERF_DIR) EXTRA_CFLAGS="$(LIBPERF_CFLAGS)" O=$(OUTPUT) $(OUTPUT)libperf.a
@@ -1036,16 +1043,15 @@ SKELETONS := $(SKEL_OUT)/bpf_prog_profiler.skel.h
10361043
SKELETONS += $(SKEL_OUT)/bperf_leader.skel.h $(SKEL_OUT)/bperf_follower.skel.h
10371044
SKELETONS += $(SKEL_OUT)/bperf_cgroup.skel.h
10381045

1046+
$(SKEL_TMP_OUT) $(LIBBPF_OUTPUT):
1047+
$(Q)$(MKDIR) -p $@
1048+
10391049
ifdef BUILD_BPF_SKEL
10401050
BPFTOOL := $(SKEL_TMP_OUT)/bootstrap/bpftool
1041-
LIBBPF_SRC := $(abspath ../lib/bpf)
1042-
BPF_INCLUDE := -I$(SKEL_TMP_OUT)/.. -I$(BPF_PATH) -I$(LIBBPF_SRC)/..
1043-
1044-
$(SKEL_TMP_OUT):
1045-
$(Q)$(MKDIR) -p $@
1051+
BPF_INCLUDE := -I$(SKEL_TMP_OUT)/.. -I$(LIBBPF_INCLUDE)
10461052

10471053
$(BPFTOOL): | $(SKEL_TMP_OUT)
1048-
CFLAGS= $(MAKE) -C ../bpf/bpftool \
1054+
$(Q)CFLAGS= $(MAKE) -C ../bpf/bpftool \
10491055
OUTPUT=$(SKEL_TMP_OUT)/ bootstrap
10501056

10511057
VMLINUX_BTF_PATHS ?= $(if $(O),$(O)/vmlinux) \

0 commit comments

Comments
 (0)