xref: /linux/tools/perf/util/Build (revision e62fae9d9e85d38cdda1ee08a424e1b5b8246620)
1include $(srctree)/tools/scripts/Makefile.include
2include $(srctree)/tools/scripts/utilities.mak
3
4perf-util-y += arm64-frame-pointer-unwind-support.o
5perf-util-y += addr2line.o
6perf-util-y += addr_location.o
7perf-util-y += annotate.o
8perf-util-y += blake2s.o
9perf-util-y += block-info.o
10perf-util-y += block-range.o
11perf-util-y += build-id.o
12perf-util-y += cacheline.o
13perf-util-y += capstone.o
14perf-util-y += config.o
15perf-util-y += copyfile.o
16perf-util-y += ctype.o
17perf-util-y += db-export.o
18perf-util-y += disasm.o
19perf-util-y += env.o
20perf-util-y += event.o
21perf-util-y += evlist.o
22perf-util-y += sideband_evlist.o
23perf-util-y += evsel.o
24perf-util-y += evsel_fprintf.o
25perf-util-y += perf_event_attr_fprintf.o
26perf-util-y += evswitch.o
27perf-util-y += find_bit.o
28perf-util-y += levenshtein.o
29perf-util-$(CONFIG_LIBBFD) += libbfd.o
30perf-util-y += llvm.o
31perf-util-y += mmap.o
32perf-util-y += memswap.o
33perf-util-y += parse-events.o
34perf-util-y += print-events.o
35perf-util-y += tracepoint.o
36perf-util-y += perf_regs.o
37perf-util-y += perf-regs-arch/
38perf-util-y += path.o
39perf-util-y += print_binary.o
40perf-util-y += print_insn.o
41perf-util-y += rlimit.o
42perf-util-y += argv_split.o
43perf-util-y += rbtree.o
44perf-util-y += libstring.o
45perf-util-y += bitmap.o
46perf-util-y += hweight.o
47perf-util-y += smt.o
48perf-util-y += strbuf.o
49perf-util-y += string.o
50perf-util-y += strlist.o
51perf-util-y += strfilter.o
52perf-util-y += top.o
53perf-util-y += usage.o
54perf-util-y += dso.o
55perf-util-y += dsos.o
56perf-util-y += symbol.o
57perf-util-y += symbol_fprintf.o
58perf-util-y += map_symbol.o
59perf-util-y += color.o
60perf-util-y += color_config.o
61perf-util-y += metricgroup.o
62perf-util-y += header.o
63perf-util-y += callchain.o
64perf-util-y += values.o
65perf-util-y += debug.o
66perf-util-y += fncache.o
67perf-util-y += machine.o
68perf-util-y += map.o
69perf-util-y += maps.o
70perf-util-y += pstack.o
71perf-util-y += session.o
72perf-util-y += tool.o
73perf-util-y += sample.o
74perf-util-y += sample-raw.o
75perf-util-y += s390-sample-raw.o
76perf-util-y += amd-sample-raw.o
77perf-util-$(CONFIG_TRACE) += syscalltbl.o
78perf-util-y += ordered-events.o
79perf-util-y += namespaces.o
80perf-util-y += comm.o
81perf-util-y += thread.o
82perf-util-y += threads.o
83perf-util-y += thread_map.o
84perf-util-y += parse-events-flex.o
85perf-util-y += parse-events-bison.o
86perf-util-y += pmu.o
87perf-util-y += pmus.o
88perf-util-y += pmu-flex.o
89perf-util-y += pmu-bison.o
90perf-util-y += drm_pmu.o
91perf-util-y += hwmon_pmu.o
92perf-util-y += tool_pmu.o
93perf-util-y += tp_pmu.o
94perf-util-y += svghelper.o
95perf-util-y += trace-event-info.o
96perf-util-y += trace-event-scripting.o
97perf-util-$(CONFIG_LIBTRACEEVENT) += trace-event.o
98perf-util-$(CONFIG_LIBTRACEEVENT) += trace-event-parse.o
99perf-util-$(CONFIG_LIBTRACEEVENT) += trace-event-read.o
100perf-util-y += sort.o
101perf-util-y += hist.o
102perf-util-y += util.o
103perf-util-y += cpumap.o
104perf-util-y += affinity.o
105perf-util-y += cputopo.o
106perf-util-y += cgroup.o
107perf-util-y += target.o
108perf-util-y += rblist.o
109perf-util-y += intlist.o
110perf-util-y += vdso.o
111perf-util-y += counts.o
112perf-util-y += stat.o
113perf-util-y += stat-shadow.o
114perf-util-y += stat-display.o
115perf-util-y += perf_api_probe.o
116perf-util-y += record.o
117perf-util-y += srcline.o
118perf-util-y += srccode.o
119perf-util-y += synthetic-events.o
120perf-util-y += data.o
121perf-util-y += tsc.o
122perf-util-y += cloexec.o
123perf-util-y += call-path.o
124perf-util-y += rwsem.o
125perf-util-y += thread-stack.o
126perf-util-y += spark.o
127perf-util-y += topdown.o
128perf-util-y += iostat.o
129perf-util-y += stream.o
130perf-util-y += kvm-stat.o
131perf-util-y += lock-contention.o
132perf-util-y += auxtrace.o
133perf-util-y += intel-pt-decoder/
134perf-util-y += intel-pt.o
135perf-util-y += intel-bts.o
136perf-util-y += arm-spe.o
137perf-util-y += arm-spe-decoder/
138perf-util-y += hisi-ptt.o
139perf-util-y += hisi-ptt-decoder/
140perf-util-y += s390-cpumsf.o
141perf-util-y += powerpc-vpadtl.o
142
143ifdef CONFIG_LIBOPENCSD
144perf-util-y += cs-etm.o
145perf-util-y += cs-etm-decoder/
146endif
147perf-util-y += cs-etm-base.o
148
149perf-util-y += parse-branch-options.o
150perf-util-y += dump-insn.o
151perf-util-y += parse-regs-options.o
152perf-util-y += parse-sublevel-options.o
153perf-util-y += term.o
154perf-util-y += help-unknown-cmd.o
155perf-util-y += dlfilter.o
156perf-util-y += mem-events.o
157perf-util-y += mem-info.o
158perf-util-y += vsprintf.o
159perf-util-y += units.o
160perf-util-y += time-utils.o
161perf-util-y += expr-flex.o
162perf-util-y += expr-bison.o
163perf-util-y += expr.o
164perf-util-y += branch.o
165perf-util-y += mem2node.o
166perf-util-y += clockid.o
167perf-util-y += list_sort.o
168perf-util-y += mutex.o
169perf-util-y += sharded_mutex.o
170perf-util-y += intel-tpebs.o
171
172perf-util-$(CONFIG_LIBBPF) += bpf_map.o
173perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_counter.o
174perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_counter_cgroup.o
175perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_ftrace.o
176perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_off_cpu.o
177perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf-filter.o
178perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf-filter-flex.o
179perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf-filter-bison.o
180perf-util-$(CONFIG_PERF_BPF_SKEL) += btf.o
181
182ifeq ($(CONFIG_TRACE),y)
183  perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf-trace-summary.o
184  perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_trace_augment.o
185endif
186
187ifeq ($(CONFIG_LIBTRACEEVENT),y)
188  perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_lock_contention.o
189endif
190
191ifeq ($(CONFIG_LIBTRACEEVENT),y)
192  perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_kwork.o
193  perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_kwork_top.o
194endif
195
196perf-util-$(CONFIG_LIBELF) += symbol-elf.o
197perf-util-$(CONFIG_LIBELF) += probe-file.o
198perf-util-$(CONFIG_LIBELF) += probe-event.o
199
200ifdef CONFIG_LIBBPF_DYNAMIC
201  hashmap := 1
202endif
203ifndef CONFIG_LIBBPF
204  hashmap := 1
205endif
206
207ifdef hashmap
208perf-util-y += hashmap.o
209endif
210
211ifndef CONFIG_LIBELF
212perf-util-y += symbol-minimal.o
213endif
214
215ifndef CONFIG_SETNS
216perf-util-y += setns.o
217endif
218
219perf-util-$(CONFIG_LIBDW) += probe-finder.o
220perf-util-$(CONFIG_LIBDW) += dwarf-aux.o
221perf-util-$(CONFIG_LIBDW) += dwarf-regs.o
222perf-util-$(CONFIG_LIBDW) += dwarf-regs-csky.o
223perf-util-$(CONFIG_LIBDW) += dwarf-regs-powerpc.o
224perf-util-$(CONFIG_LIBDW) += dwarf-regs-x86.o
225perf-util-$(CONFIG_LIBDW) += debuginfo.o
226perf-util-$(CONFIG_LIBDW) += annotate-data.o
227perf-util-$(CONFIG_LIBDW) += libdw.o
228
229perf-util-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
230perf-util-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw-arch/
231perf-util-$(CONFIG_LOCAL_LIBUNWIND)    += unwind-libunwind-local.o
232perf-util-$(CONFIG_LIBUNWIND)          += unwind-libunwind.o
233perf-util-$(CONFIG_LIBUNWIND_X86)      += libunwind/x86_32.o
234perf-util-$(CONFIG_LIBUNWIND_AARCH64)  += libunwind/arm64.o
235
236ifeq ($(CONFIG_LIBTRACEEVENT),y)
237  perf-util-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o
238endif
239
240perf-util-y += data-convert-json.o
241
242perf-util-y += scripting-engines/
243
244perf-util-$(CONFIG_ZLIB) += zlib.o
245perf-util-$(CONFIG_LZMA) += lzma.o
246perf-util-$(CONFIG_ZSTD) += zstd.o
247
248perf-util-y += cap.o
249
250perf-util-$(CONFIG_CXX_DEMANGLE) += demangle-cxx.o
251perf-util-y += demangle-ocaml.o
252perf-util-y += demangle-java.o
253perf-util-y += demangle-rust-v0.o
254perf-util-$(CONFIG_LIBLLVM) += llvm-c-helpers.o
255
256CFLAGS_demangle-rust-v0.o += -Wno-shadow -Wno-declaration-after-statement \
257    -Wno-switch-default -Wno-switch-enum -Wno-missing-field-initializers
258
259ifdef CONFIG_JITDUMP
260perf-util-$(CONFIG_LIBELF) += jitdump.o
261perf-util-$(CONFIG_LIBELF) += genelf.o
262perf-util-$(CONFIG_LIBDW) += genelf_debug.o
263endif
264
265perf-util-y += perf-hooks.o
266
267perf-util-$(CONFIG_LIBBPF) += bpf-event.o
268perf-util-$(CONFIG_LIBBPF) += bpf-utils.o
269
270perf-util-$(CONFIG_LIBPFM4) += pfm.o
271
272CFLAGS_config.o   += -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
273
274# avoid compiler warnings in 32-bit mode
275CFLAGS_genelf_debug.o  += -Wno-packed
276
277$(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-flex.h: util/parse-events.l $(OUTPUT)util/parse-events-bison.c
278	$(call rule_mkdir)
279	$(Q)$(call echo-cmd,flex)$(FLEX) -o $(OUTPUT)util/parse-events-flex.c \
280		--header-file=$(OUTPUT)util/parse-events-flex.h $(PARSER_DEBUG_FLEX) $<
281
282$(OUTPUT)util/parse-events-bison.c $(OUTPUT)util/parse-events-bison.h: util/parse-events.y
283	$(call rule_mkdir)
284	$(Q)$(call echo-cmd,bison)$(BISON) -v $< -d $(PARSER_DEBUG_BISON) $(BISON_FILE_PREFIX_MAP) $(BISON_FALLBACK_FLAGS) \
285		-o $(OUTPUT)util/parse-events-bison.c -p parse_events_
286
287$(OUTPUT)util/expr-flex.c $(OUTPUT)util/expr-flex.h: util/expr.l $(OUTPUT)util/expr-bison.c
288	$(call rule_mkdir)
289	$(Q)$(call echo-cmd,flex)$(FLEX) -o $(OUTPUT)util/expr-flex.c \
290		--header-file=$(OUTPUT)util/expr-flex.h $(PARSER_DEBUG_FLEX) $<
291
292$(OUTPUT)util/expr-bison.c $(OUTPUT)util/expr-bison.h: util/expr.y
293	$(call rule_mkdir)
294	$(Q)$(call echo-cmd,bison)$(BISON) -v $< -d $(PARSER_DEBUG_BISON) $(BISON_FILE_PREFIX_MAP) \
295		-o $(OUTPUT)util/expr-bison.c -p expr_
296
297$(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-flex.h: util/pmu.l $(OUTPUT)util/pmu-bison.c
298	$(call rule_mkdir)
299	$(Q)$(call echo-cmd,flex)$(FLEX) -o $(OUTPUT)util/pmu-flex.c \
300		--header-file=$(OUTPUT)util/pmu-flex.h $(PARSER_DEBUG_FLEX) $<
301
302$(OUTPUT)util/pmu-bison.c $(OUTPUT)util/pmu-bison.h: util/pmu.y
303	$(call rule_mkdir)
304	$(Q)$(call echo-cmd,bison)$(BISON) -v $< -d $(PARSER_DEBUG_BISON) $(BISON_FILE_PREFIX_MAP) \
305		-o $(OUTPUT)util/pmu-bison.c -p perf_pmu_
306
307$(OUTPUT)util/bpf-filter-flex.c $(OUTPUT)util/bpf-filter-flex.h: util/bpf-filter.l $(OUTPUT)util/bpf-filter-bison.c util/bpf-filter.h util/bpf_skel/sample-filter.h
308	$(call rule_mkdir)
309	$(Q)$(call echo-cmd,flex)$(FLEX) -o $(OUTPUT)util/bpf-filter-flex.c \
310		--header-file=$(OUTPUT)util/bpf-filter-flex.h $(PARSER_DEBUG_FLEX) $<
311
312$(OUTPUT)util/bpf-filter-bison.c $(OUTPUT)util/bpf-filter-bison.h: util/bpf-filter.y util/bpf-filter.h util/bpf_skel/sample-filter.h
313	$(call rule_mkdir)
314	$(Q)$(call echo-cmd,bison)$(BISON) -v $< -d $(PARSER_DEBUG_BISON) $(BISON_FILE_PREFIX_MAP) \
315		-o $(OUTPUT)util/bpf-filter-bison.c -p perf_bpf_filter_
316
317FLEX_VERSION := $(shell $(FLEX) --version | cut -d' ' -f2)
318
319FLEX_GE_260 := $(call version-ge3,$(FLEX_VERSION),2.6.0)
320ifeq ($(FLEX_GE_260),1)
321  flex_flags := -Wno-redundant-decls -Wno-switch-default -Wno-unused-function -Wno-misleading-indentation
322
323  # Some newer clang and gcc version complain about this
324  # util/parse-events-bison.c:1317:9: error: variable 'parse_events_nerrs' set but not used [-Werror,-Wunused-but-set-variable]
325  #  int yynerrs = 0;
326
327  flex_flags += -Wno-unused-but-set-variable
328
329  FLEX_LT_262 := $(call version-lt3,$(FLEX_VERSION),2.6.2)
330  ifeq ($(FLEX_LT_262),1)
331    flex_flags += -Wno-sign-compare
332  endif
333else
334  flex_flags := -w
335endif
336
337# Some newer clang and gcc version complain about this
338# util/parse-events-bison.c:1317:9: error: variable 'parse_events_nerrs' set but not used [-Werror,-Wunused-but-set-variable]
339#  int yynerrs = 0;
340
341bison_flags := -DYYENABLE_NLS=0 -Wno-unused-but-set-variable
342
343# Old clangs don't grok -Wno-unused-but-set-variable, remove it
344ifeq ($(CC_NO_CLANG), 0)
345  CLANG_VERSION := $(shell $(CLANG) --version | head -1 | sed 's/.*clang version \([[:digit:]]\+.[[:digit:]]\+.[[:digit:]]\+\).*/\1/g')
346  ifeq ($(call version-lt3,$(CLANG_VERSION),13.0.0),1)
347    bison_flags := $(subst -Wno-unused-but-set-variable,,$(bison_flags))
348    flex_flags := $(subst -Wno-unused-but-set-variable,,$(flex_flags))
349  endif
350endif
351
352BISON_GE_382 := $(shell expr $(shell $(BISON) --version | grep bison | sed -e 's/.\+ \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \>\= 382)
353ifeq ($(BISON_GE_382),1)
354  bison_flags += -Wno-switch-enum
355else
356  bison_flags += -w
357endif
358
359BISON_LT_381 := $(shell expr $(shell $(BISON) --version | grep bison | sed -e 's/.\+ \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \< 381)
360ifeq ($(BISON_LT_381),1)
361  bison_flags += -DYYNOMEM=YYABORT
362endif
363
364CFLAGS_parse-events-flex.o  += $(flex_flags) -Wno-unused-label
365CFLAGS_pmu-flex.o           += $(flex_flags)
366CFLAGS_expr-flex.o          += $(flex_flags)
367CFLAGS_bpf-filter-flex.o    += $(flex_flags)
368
369CFLAGS_parse-events-bison.o += $(bison_flags)
370CFLAGS_pmu-bison.o          += -DYYLTYPE_IS_TRIVIAL=0 $(bison_flags)
371CFLAGS_expr-bison.o         += -DYYLTYPE_IS_TRIVIAL=0 $(bison_flags)
372CFLAGS_bpf-filter-bison.o   += -DYYLTYPE_IS_TRIVIAL=0 $(bison_flags)
373
374$(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-bison.c
375$(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c
376$(OUTPUT)util/expr.o: $(OUTPUT)util/expr-flex.c $(OUTPUT)util/expr-bison.c
377$(OUTPUT)util/bpf-filter.o: $(OUTPUT)util/bpf-filter-flex.c $(OUTPUT)util/bpf-filter-bison.c
378
379CFLAGS_bitmap.o        += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
380CFLAGS_find_bit.o      += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
381CFLAGS_rbtree.o        += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
382CFLAGS_libstring.o     += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
383CFLAGS_hweight.o       += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
384CFLAGS_header.o        += -include $(OUTPUT)PERF-VERSION-FILE
385CFLAGS_arm-spe.o       += -I$(srctree)/tools/arch/arm64/include/ -I$(OUTPUT)arch/arm64/include/generated/
386
387$(OUTPUT)util/argv_split.o: ../lib/argv_split.c FORCE
388	$(call rule_mkdir)
389	$(call if_changed_dep,cc_o_c)
390
391$(OUTPUT)util/bitmap.o: ../lib/bitmap.c FORCE
392	$(call rule_mkdir)
393	$(call if_changed_dep,cc_o_c)
394
395$(OUTPUT)util/ctype.o: ../lib/ctype.c FORCE
396	$(call rule_mkdir)
397	$(call if_changed_dep,cc_o_c)
398
399$(OUTPUT)util/find_bit.o: ../lib/find_bit.c FORCE
400	$(call rule_mkdir)
401	$(call if_changed_dep,cc_o_c)
402
403$(OUTPUT)util/rbtree.o: ../lib/rbtree.c FORCE
404	$(call rule_mkdir)
405	$(call if_changed_dep,cc_o_c)
406
407$(OUTPUT)util/libstring.o: ../lib/string.c FORCE
408	$(call rule_mkdir)
409	$(call if_changed_dep,cc_o_c)
410
411$(OUTPUT)util/hweight.o: ../lib/hweight.c FORCE
412	$(call rule_mkdir)
413	$(call if_changed_dep,cc_o_c)
414
415$(OUTPUT)util/vsprintf.o: ../lib/vsprintf.c FORCE
416	$(call rule_mkdir)
417	$(call if_changed_dep,cc_o_c)
418
419$(OUTPUT)util/list_sort.o: ../lib/list_sort.c FORCE
420	$(call rule_mkdir)
421	$(call if_changed_dep,cc_o_c)
422
423PY_TESTS := setup.py
424ifdef MYPY
425  MYPY_TEST_LOGS := $(PY_TESTS:%=%.mypy_log)
426else
427  MYPY_TEST_LOGS :=
428endif
429
430$(OUTPUT)%.mypy_log: %
431	$(call rule_mkdir)
432	$(Q)$(call echo-cmd,test)mypy "$<" > $@ || (cat $@ && rm $@ && false)
433
434perf-util-y += $(MYPY_TEST_LOGS)
435
436ifdef PYLINT
437  PYLINT_TEST_LOGS := $(PY_TESTS:%=%.pylint_log)
438else
439  PYLINT_TEST_LOGS :=
440endif
441
442$(OUTPUT)%.pylint_log: %
443	$(call rule_mkdir)
444	$(Q)$(call echo-cmd,test)pylint "$<" > $@ || (cat $@ && rm $@ && false)
445
446perf-util-y += $(PYLINT_TEST_LOGS)
447