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