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