File libperf-make-libperf-a-part-of-the-perf-build.patch of Package perf
275
1
From: Jiri Olsa <jolsa@kernel.org>
2
Date: Sun, 21 Jul 2019 13:24:10 +0200
3
Subject: libperf: Make libperf.a part of the perf build
4
Git-commit: 3143504918105156d03e8f927e127f7b9ea260d2
5
Patch-mainline: v5.4-rc1
6
References: jsc#SLE-13661
7
8
Add an empty libperf.a under tools/perf/lib and link it with perf.
9
10
It can also be built separately with:
11
12
$ cd tools/perf/lib && make
13
CC core.o
14
LD libperf-in.o
15
AR libperf.a
16
LINK libperf.so
17
18
Committer testing:
19
20
$ make O=/tmp/build/perf -C tools/perf/lib/
21
make: Entering directory '/home/acme/git/perf/tools/perf/lib'
22
LINK /tmp/build/perf/libperf.so
23
make: Leaving directory '/home/acme/git/perf/tools/perf/lib'
24
$ ls -la /tmp/build/perf/libperf.so
25
-rwxrwxr-x. 1 acme acme 16232 Jul 22 15:30 /tmp/build/perf/libperf.so
26
$ file /tmp/build/perf/libperf.so
27
/tmp/build/perf/libperf.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=7a51d227d871b381ddb686dcf94145c4dd908221, not stripped
28
$ git status tools/perf
29
On branch perf/core
30
nothing to commit, working tree clean
31
$
32
$ ls -lart tools/perf/lib/
33
total 16
34
drwxrwxr-x. 16 acme acme 4096 Jul 22 15:29 ..
35
-rw-rw-r--. 1 acme acme 1633 Jul 22 15:29 Makefile
36
-rw-rw-r--. 1 acme acme 0 Jul 22 15:29 core.c
37
-rw-rw-r--. 1 acme acme 20 Jul 22 15:29 Build
38
drwxrwxr-x. 2 acme acme 4096 Jul 22 15:29 .
39
$
40
41
Committer notes:
42
43
Need to add -I$(srctree)/tools/arch/$(ARCH)/include/uapi
44
-I$(srctree)/tools/include/uapi to tools/perf/lib/Makefile's INCLUDE
45
variable to pick up the latest versions of kernel headers, even in older
46
systems, this is in line with what is in tools/lib/bpf/Makefile.
47
48
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
49
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
50
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
51
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
52
Cc: Andi Kleen <ak@linux.intel.com>
53
Cc: Michael Petlan <mpetlan@redhat.com>
54
Cc: Namhyung Kim <namhyung@kernel.org>
55
Cc: Peter Zijlstra <peterz@infradead.org>
56
Link: http://lkml.kernel.org/r/20190721112506.12306-24-jolsa@kernel.org
57
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
58
Signed-off-by: Tony Jones <tonyj@suse.de>
59
---
60
tools/perf/Makefile.config | 1 +
61
tools/perf/Makefile.perf | 30 ++++++++++---------
62
tools/perf/lib/Build | 1 +
63
tools/perf/lib/Makefile | 74 ++++++++++++++++++++++++++++++++++++++++++++++
64
tools/perf/lib/core.c | 0
65
5 files changed, 92 insertions(+), 14 deletions(-)
66
67
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
68
index 89ac5a1f1550..e4988f49ea79 100644
69
--- a/tools/perf/Makefile.config
70
+++ b/tools/perf/Makefile.config
71
72
endif
73
endif
74
75
+INC_FLAGS += -I$(src-perf)/lib/include
76
INC_FLAGS += -I$(src-perf)/util/include
77
INC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include
78
INC_FLAGS += -I$(srctree)/tools/include/uapi
79
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
80
index 0fffd2bb6cd9..6e7e7d44ffac 100644
81
--- a/tools/perf/Makefile.perf
82
+++ b/tools/perf/Makefile.perf
83
84
TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/
85
BPF_DIR = $(srctree)/tools/lib/bpf/
86
SUBCMD_DIR = $(srctree)/tools/lib/subcmd/
87
+LIBPERF_DIR = $(srctree)/tools/perf/lib/
88
89
# Set FEATURE_TESTS to 'all' so all possible feature checkers are executed.
90
# Without this setting the output feature dump file misses some features, for
91
92
TE_PATH=$(OUTPUT)
93
BPF_PATH=$(OUTPUT)
94
SUBCMD_PATH=$(OUTPUT)
95
+ LIBPERF_PATH=$(OUTPUT)
96
ifneq ($(subdir),)
97
API_PATH=$(OUTPUT)/../lib/api/
98
else
99
100
API_PATH=$(LIB_DIR)
101
BPF_PATH=$(BPF_DIR)
102
SUBCMD_PATH=$(SUBCMD_DIR)
103
+ LIBPERF_PATH=$(LIBPERF_DIR)
104
endif
105
106
LIBTRACEEVENT = $(TE_PATH)libtraceevent.a
107
108
109
LIBSUBCMD = $(SUBCMD_PATH)libsubcmd.a
110
111
+LIBPERF = $(LIBPERF_PATH)libperf.a
112
+
113
# python extension build directories
114
PYTHON_EXTBUILD := $(OUTPUT)python_ext_build/
115
PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/
116
117
118
export PERL_PATH
119
120
-LIBPERF_A=$(OUTPUT)libperf.a
121
-
122
-PERFLIBS = $(LIBAPI) $(LIBTRACEEVENT) $(LIBSUBCMD)
123
+PERFLIBS = $(LIBAPI) $(LIBTRACEEVENT) $(LIBSUBCMD) $(LIBPERF)
124
ifndef NO_LIBBPF
125
PERFLIBS += $(LIBBPF)
126
endif
127
128
129
PMU_EVENTS_IN := $(OUTPUT)pmu-events/pmu-events-in.o
130
131
-LIBPERF_IN := $(OUTPUT)libperf-in.o
132
-
133
export JEVENTS
134
135
build := -f $(srctree)/tools/build/Makefile.build dir=. obj
136
137
$(PMU_EVENTS_IN): $(JEVENTS) FORCE
138
$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=pmu-events obj=pmu-events
139
140
-$(LIBPERF_IN): prepare FORCE
141
- $(Q)$(MAKE) $(build)=libperf
142
-
143
-$(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(PMU_EVENTS_IN) $(LIBPERF_IN) $(LIBTRACEEVENT_DYNAMIC_LIST)
144
+$(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(PMU_EVENTS_IN) $(LIBTRACEEVENT_DYNAMIC_LIST)
145
$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS) \
146
- $(PERF_IN) $(PMU_EVENTS_IN) $(LIBPERF_IN) $(LIBS) -o $@
147
+ $(PERF_IN) $(PMU_EVENTS_IN) $(LIBS) -o $@
148
149
$(GTK_IN): FORCE
150
$(Q)$(MAKE) $(build)=gtk
151
152
153
$(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)
154
155
-$(LIBPERF_A): $(LIBPERF_IN)
156
- $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIBPERF_IN) $(LIB_OBJS)
157
-
158
LIBTRACEEVENT_FLAGS += plugin_dir=$(plugindir_SQ) 'EXTRA_CFLAGS=$(EXTRA_CFLAGS)' 'LDFLAGS=$(LDFLAGS)'
159
160
$(LIBTRACEEVENT): FORCE
161
162
$(call QUIET_CLEAN, libbpf)
163
$(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) clean >/dev/null
164
165
+$(LIBPERF): FORCE
166
+ $(Q)$(MAKE) -C $(LIBPERF_DIR) O=$(OUTPUT) $(OUTPUT)libperf.a
167
+
168
+$(LIBPERF)-clean:
169
+ $(call QUIET_CLEAN, libperf)
170
+ $(Q)$(MAKE) -C $(LIBPERF_DIR) O=$(OUTPUT) clean >/dev/null
171
+
172
$(LIBSUBCMD): FORCE
173
$(Q)$(MAKE) -C $(SUBCMD_DIR) O=$(OUTPUT) $(OUTPUT)libsubcmd.a
174
175
176
python-clean:
177
$(python-clean)
178
179
-clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean config-clean fixdep-clean python-clean
180
+clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBPERF)-clean config-clean fixdep-clean python-clean
181
$(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(LANG_BINDINGS)
182
$(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
183
$(Q)$(RM) $(OUTPUT).config-detected
184
diff --git a/tools/perf/lib/Build b/tools/perf/lib/Build
185
new file mode 100644
186
index 000000000000..5196958cec01
187
--- /dev/null
188
+++ b/tools/perf/lib/Build
189
190
+libperf-y += core.o
191
diff --git a/tools/perf/lib/Makefile b/tools/perf/lib/Makefile
192
new file mode 100644
193
index 000000000000..33046e7c6a2a
194
--- /dev/null
195
+++ b/tools/perf/lib/Makefile
196
197
+# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
198
+# Most of this file is copied from tools/lib/bpf/Makefile
199
+
200
+MAKEFLAGS += --no-print-directory
201
+
202
+ifeq ($(srctree),)
203
+srctree := $(patsubst %/,%,$(dir $(CURDIR)))
204
+srctree := $(patsubst %/,%,$(dir $(srctree)))
205
+srctree := $(patsubst %/,%,$(dir $(srctree)))
206
+#$(info Determined 'srctree' to be $(srctree))
207
+endif
208
+
209
+include $(srctree)/tools/scripts/Makefile.include
210
+include $(srctree)/tools/scripts/Makefile.arch
211
+
212
+ifeq ("$(origin V)", "command line")
213
+ VERBOSE = $(V)
214
+endif
215
+ifndef VERBOSE
216
+ VERBOSE = 0
217
+endif
218
+
219
+ifeq ($(VERBOSE),1)
220
+ Q =
221
+else
222
+ Q = @
223
+endif
224
+
225
+# Set compile option CFLAGS
226
+ifdef EXTRA_CFLAGS
227
+ CFLAGS := $(EXTRA_CFLAGS)
228
+else
229
+ CFLAGS := -g -Wall
230
+endif
231
+
232
+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
233
+
234
+# Append required CFLAGS
235
+override CFLAGS += $(EXTRA_WARNINGS)
236
+override CFLAGS += -Werror -Wall
237
+override CFLAGS += -fPIC
238
+override CFLAGS += $(INCLUDES)
239
+override CFLAGS += -fvisibility=hidden
240
+
241
+all:
242
+
243
+export srctree OUTPUT CC LD CFLAGS V
244
+include $(srctree)/tools/build/Makefile.include
245
+
246
+LIBPERF_SO := $(OUTPUT)libperf.so
247
+LIBPERF_A := $(OUTPUT)libperf.a
248
+LIBPERF_IN := $(OUTPUT)libperf-in.o
249
+
250
+$(LIBPERF_IN): FORCE
251
+ $(Q)$(MAKE) $(build)=libperf
252
+
253
+$(LIBPERF_A): $(LIBPERF_IN)
254
+ $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIBPERF_IN)
255
+
256
+$(LIBPERF_SO): $(LIBPERF_IN)
257
+ $(QUIET_LINK)$(CC) --shared -Wl,-soname,libperf.so $^ -o $@
258
+
259
+libs: $(LIBPERF_A) $(LIBPERF_SO)
260
+
261
+all: fixdep
262
+ $(Q)$(MAKE) libs
263
+
264
+clean:
265
+ $(call QUIET_CLEAN, libperf) $(RM) $(LIBPERF_A) \
266
+ *.o *~ *.a *.so .*.d .*.cmd LIBPERF-CFLAGS
267
+
268
+FORCE:
269
+
270
+.PHONY: all install clean FORCE
271
diff --git a/tools/perf/lib/core.c b/tools/perf/lib/core.c
272
new file mode 100644
273
index 000000000000..e69de29bb2d1
274
275