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