libperf: Make libperf.a part of the perf build
Add an empty libperf.a under tools/perf/lib and link it with perf. It can also be built separately with: $ cd tools/perf/lib && make CC core.o LD libperf-in.o AR libperf.a LINK libperf.so Committer testing: $ make O=/tmp/build/perf -C tools/perf/lib/ make: Entering directory '/home/acme/git/perf/tools/perf/lib' LINK /tmp/build/perf/libperf.so make: Leaving directory '/home/acme/git/perf/tools/perf/lib' $ ls -la /tmp/build/perf/libperf.so -rwxrwxr-x. 1 acme acme 16232 Jul 22 15:30 /tmp/build/perf/libperf.so $ file /tmp/build/perf/libperf.so /tmp/build/perf/libperf.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=7a51d227d871b381ddb686dcf94145c4dd908221, not stripped $ git status tools/perf On branch perf/core nothing to commit, working tree clean $ $ ls -lart tools/perf/lib/ total 16 drwxrwxr-x. 16 acme acme 4096 Jul 22 15:29 .. -rw-rw-r--. 1 acme acme 1633 Jul 22 15:29 Makefile -rw-rw-r--. 1 acme acme 0 Jul 22 15:29 core.c -rw-rw-r--. 1 acme acme 20 Jul 22 15:29 Build drwxrwxr-x. 2 acme acme 4096 Jul 22 15:29 . $ Committer notes: Need to add -I$(srctree)/tools/arch/$(ARCH)/include/uapi -I$(srctree)/tools/include/uapi to tools/perf/lib/Makefile's INCLUDE variable to pick up the latest versions of kernel headers, even in older systems, this is in line with what is in tools/lib/bpf/Makefile. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexey Budankov <alexey.budankov@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Michael Petlan <mpetlan@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20190721112506.12306-24-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Родитель
e74676deba
Коммит
3143504918
|
@ -277,6 +277,7 @@ ifeq ($(DEBUG),0)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
INC_FLAGS += -I$(src-perf)/lib/include
|
||||||
INC_FLAGS += -I$(src-perf)/util/include
|
INC_FLAGS += -I$(src-perf)/util/include
|
||||||
INC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include
|
INC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include
|
||||||
INC_FLAGS += -I$(srctree)/tools/include/uapi
|
INC_FLAGS += -I$(srctree)/tools/include/uapi
|
||||||
|
|
|
@ -224,6 +224,7 @@ LIB_DIR = $(srctree)/tools/lib/api/
|
||||||
TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/
|
TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/
|
||||||
BPF_DIR = $(srctree)/tools/lib/bpf/
|
BPF_DIR = $(srctree)/tools/lib/bpf/
|
||||||
SUBCMD_DIR = $(srctree)/tools/lib/subcmd/
|
SUBCMD_DIR = $(srctree)/tools/lib/subcmd/
|
||||||
|
LIBPERF_DIR = $(srctree)/tools/perf/lib/
|
||||||
|
|
||||||
# Set FEATURE_TESTS to 'all' so all possible feature checkers are executed.
|
# Set FEATURE_TESTS to 'all' so all possible feature checkers are executed.
|
||||||
# Without this setting the output feature dump file misses some features, for
|
# Without this setting the output feature dump file misses some features, for
|
||||||
|
@ -272,6 +273,7 @@ ifneq ($(OUTPUT),)
|
||||||
TE_PATH=$(OUTPUT)
|
TE_PATH=$(OUTPUT)
|
||||||
BPF_PATH=$(OUTPUT)
|
BPF_PATH=$(OUTPUT)
|
||||||
SUBCMD_PATH=$(OUTPUT)
|
SUBCMD_PATH=$(OUTPUT)
|
||||||
|
LIBPERF_PATH=$(OUTPUT)
|
||||||
ifneq ($(subdir),)
|
ifneq ($(subdir),)
|
||||||
API_PATH=$(OUTPUT)/../lib/api/
|
API_PATH=$(OUTPUT)/../lib/api/
|
||||||
else
|
else
|
||||||
|
@ -282,6 +284,7 @@ else
|
||||||
API_PATH=$(LIB_DIR)
|
API_PATH=$(LIB_DIR)
|
||||||
BPF_PATH=$(BPF_DIR)
|
BPF_PATH=$(BPF_DIR)
|
||||||
SUBCMD_PATH=$(SUBCMD_DIR)
|
SUBCMD_PATH=$(SUBCMD_DIR)
|
||||||
|
LIBPERF_PATH=$(LIBPERF_DIR)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LIBTRACEEVENT = $(TE_PATH)libtraceevent.a
|
LIBTRACEEVENT = $(TE_PATH)libtraceevent.a
|
||||||
|
@ -303,6 +306,8 @@ LIBBPF = $(BPF_PATH)libbpf.a
|
||||||
|
|
||||||
LIBSUBCMD = $(SUBCMD_PATH)libsubcmd.a
|
LIBSUBCMD = $(SUBCMD_PATH)libsubcmd.a
|
||||||
|
|
||||||
|
LIBPERF = $(LIBPERF_PATH)libperf.a
|
||||||
|
|
||||||
# python extension build directories
|
# python extension build directories
|
||||||
PYTHON_EXTBUILD := $(OUTPUT)python_ext_build/
|
PYTHON_EXTBUILD := $(OUTPUT)python_ext_build/
|
||||||
PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/
|
PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/
|
||||||
|
@ -348,9 +353,7 @@ endif
|
||||||
|
|
||||||
export PERL_PATH
|
export PERL_PATH
|
||||||
|
|
||||||
LIBPERF_A=$(OUTPUT)libperf.a
|
PERFLIBS = $(LIBAPI) $(LIBTRACEEVENT) $(LIBSUBCMD) $(LIBPERF)
|
||||||
|
|
||||||
PERFLIBS = $(LIBAPI) $(LIBTRACEEVENT) $(LIBSUBCMD)
|
|
||||||
ifndef NO_LIBBPF
|
ifndef NO_LIBBPF
|
||||||
PERFLIBS += $(LIBBPF)
|
PERFLIBS += $(LIBBPF)
|
||||||
endif
|
endif
|
||||||
|
@ -583,8 +586,6 @@ JEVENTS_IN := $(OUTPUT)pmu-events/jevents-in.o
|
||||||
|
|
||||||
PMU_EVENTS_IN := $(OUTPUT)pmu-events/pmu-events-in.o
|
PMU_EVENTS_IN := $(OUTPUT)pmu-events/pmu-events-in.o
|
||||||
|
|
||||||
LIBPERF_IN := $(OUTPUT)libperf-in.o
|
|
||||||
|
|
||||||
export JEVENTS
|
export JEVENTS
|
||||||
|
|
||||||
build := -f $(srctree)/tools/build/Makefile.build dir=. obj
|
build := -f $(srctree)/tools/build/Makefile.build dir=. obj
|
||||||
|
@ -601,12 +602,9 @@ $(JEVENTS): $(JEVENTS_IN)
|
||||||
$(PMU_EVENTS_IN): $(JEVENTS) FORCE
|
$(PMU_EVENTS_IN): $(JEVENTS) FORCE
|
||||||
$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=pmu-events obj=pmu-events
|
$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=pmu-events obj=pmu-events
|
||||||
|
|
||||||
$(LIBPERF_IN): prepare FORCE
|
$(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(PMU_EVENTS_IN) $(LIBTRACEEVENT_DYNAMIC_LIST)
|
||||||
$(Q)$(MAKE) $(build)=libperf
|
|
||||||
|
|
||||||
$(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(PMU_EVENTS_IN) $(LIBPERF_IN) $(LIBTRACEEVENT_DYNAMIC_LIST)
|
|
||||||
$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS) \
|
$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS) \
|
||||||
$(PERF_IN) $(PMU_EVENTS_IN) $(LIBPERF_IN) $(LIBS) -o $@
|
$(PERF_IN) $(PMU_EVENTS_IN) $(LIBS) -o $@
|
||||||
|
|
||||||
$(GTK_IN): FORCE
|
$(GTK_IN): FORCE
|
||||||
$(Q)$(MAKE) $(build)=gtk
|
$(Q)$(MAKE) $(build)=gtk
|
||||||
|
@ -727,9 +725,6 @@ endif
|
||||||
|
|
||||||
$(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)
|
$(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)
|
||||||
|
|
||||||
$(LIBPERF_A): $(LIBPERF_IN)
|
|
||||||
$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIBPERF_IN) $(LIB_OBJS)
|
|
||||||
|
|
||||||
LIBTRACEEVENT_FLAGS += plugin_dir=$(plugindir_SQ) 'EXTRA_CFLAGS=$(EXTRA_CFLAGS)' 'LDFLAGS=$(LDFLAGS)'
|
LIBTRACEEVENT_FLAGS += plugin_dir=$(plugindir_SQ) 'EXTRA_CFLAGS=$(EXTRA_CFLAGS)' 'LDFLAGS=$(LDFLAGS)'
|
||||||
|
|
||||||
$(LIBTRACEEVENT): FORCE
|
$(LIBTRACEEVENT): FORCE
|
||||||
|
@ -762,6 +757,13 @@ $(LIBBPF)-clean:
|
||||||
$(call QUIET_CLEAN, libbpf)
|
$(call QUIET_CLEAN, libbpf)
|
||||||
$(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) clean >/dev/null
|
$(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) clean >/dev/null
|
||||||
|
|
||||||
|
$(LIBPERF): FORCE
|
||||||
|
$(Q)$(MAKE) -C $(LIBPERF_DIR) O=$(OUTPUT) $(OUTPUT)libperf.a
|
||||||
|
|
||||||
|
$(LIBPERF)-clean:
|
||||||
|
$(call QUIET_CLEAN, libperf)
|
||||||
|
$(Q)$(MAKE) -C $(LIBPERF_DIR) O=$(OUTPUT) clean >/dev/null
|
||||||
|
|
||||||
$(LIBSUBCMD): FORCE
|
$(LIBSUBCMD): FORCE
|
||||||
$(Q)$(MAKE) -C $(SUBCMD_DIR) O=$(OUTPUT) $(OUTPUT)libsubcmd.a
|
$(Q)$(MAKE) -C $(SUBCMD_DIR) O=$(OUTPUT) $(OUTPUT)libsubcmd.a
|
||||||
|
|
||||||
|
@ -948,7 +950,7 @@ config-clean:
|
||||||
python-clean:
|
python-clean:
|
||||||
$(python-clean)
|
$(python-clean)
|
||||||
|
|
||||||
clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean config-clean fixdep-clean python-clean
|
clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBPERF)-clean config-clean fixdep-clean python-clean
|
||||||
$(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(LANG_BINDINGS)
|
$(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(LANG_BINDINGS)
|
||||||
$(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
|
$(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
|
||||||
$(Q)$(RM) $(OUTPUT).config-detected
|
$(Q)$(RM) $(OUTPUT).config-detected
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
libperf-y += core.o
|
|
@ -0,0 +1,74 @@
|
||||||
|
# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
|
||||||
|
# Most of this file is copied from tools/lib/bpf/Makefile
|
||||||
|
|
||||||
|
MAKEFLAGS += --no-print-directory
|
||||||
|
|
||||||
|
ifeq ($(srctree),)
|
||||||
|
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
|
||||||
|
srctree := $(patsubst %/,%,$(dir $(srctree)))
|
||||||
|
srctree := $(patsubst %/,%,$(dir $(srctree)))
|
||||||
|
#$(info Determined 'srctree' to be $(srctree))
|
||||||
|
endif
|
||||||
|
|
||||||
|
include $(srctree)/tools/scripts/Makefile.include
|
||||||
|
include $(srctree)/tools/scripts/Makefile.arch
|
||||||
|
|
||||||
|
ifeq ("$(origin V)", "command line")
|
||||||
|
VERBOSE = $(V)
|
||||||
|
endif
|
||||||
|
ifndef VERBOSE
|
||||||
|
VERBOSE = 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(VERBOSE),1)
|
||||||
|
Q =
|
||||||
|
else
|
||||||
|
Q = @
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Set compile option CFLAGS
|
||||||
|
ifdef EXTRA_CFLAGS
|
||||||
|
CFLAGS := $(EXTRA_CFLAGS)
|
||||||
|
else
|
||||||
|
CFLAGS := -g -Wall
|
||||||
|
endif
|
||||||
|
|
||||||
|
INCLUDES = -I$(srctree)/tools/perf/lib/include -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(ARCH)/include/ -I$(srctree)/tools/arch/$(ARCH)/include/uapi -I$(srctree)/tools/include/uapi
|
||||||
|
|
||||||
|
# Append required CFLAGS
|
||||||
|
override CFLAGS += $(EXTRA_WARNINGS)
|
||||||
|
override CFLAGS += -Werror -Wall
|
||||||
|
override CFLAGS += -fPIC
|
||||||
|
override CFLAGS += $(INCLUDES)
|
||||||
|
override CFLAGS += -fvisibility=hidden
|
||||||
|
|
||||||
|
all:
|
||||||
|
|
||||||
|
export srctree OUTPUT CC LD CFLAGS V
|
||||||
|
include $(srctree)/tools/build/Makefile.include
|
||||||
|
|
||||||
|
LIBPERF_SO := $(OUTPUT)libperf.so
|
||||||
|
LIBPERF_A := $(OUTPUT)libperf.a
|
||||||
|
LIBPERF_IN := $(OUTPUT)libperf-in.o
|
||||||
|
|
||||||
|
$(LIBPERF_IN): FORCE
|
||||||
|
$(Q)$(MAKE) $(build)=libperf
|
||||||
|
|
||||||
|
$(LIBPERF_A): $(LIBPERF_IN)
|
||||||
|
$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIBPERF_IN)
|
||||||
|
|
||||||
|
$(LIBPERF_SO): $(LIBPERF_IN)
|
||||||
|
$(QUIET_LINK)$(CC) --shared -Wl,-soname,libperf.so $^ -o $@
|
||||||
|
|
||||||
|
libs: $(LIBPERF_A) $(LIBPERF_SO)
|
||||||
|
|
||||||
|
all: fixdep
|
||||||
|
$(Q)$(MAKE) libs
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(call QUIET_CLEAN, libperf) $(RM) $(LIBPERF_A) \
|
||||||
|
*.o *~ *.a *.so .*.d .*.cmd LIBPERF-CFLAGS
|
||||||
|
|
||||||
|
FORCE:
|
||||||
|
|
||||||
|
.PHONY: all install clean FORCE
|
Загрузка…
Ссылка в новой задаче