# SPDX-License-Identifier: GPL-2.0-only ifeq ($(src-perf),)src-perf := $(srctree)/tools/perfendif ifeq ($(obj-perf),)obj-perf := $(OUTPUT)endif ifneq ($(obj-perf),)obj-perf := $(abspath $(obj-perf))/endif $(shell printf "" > $(OUTPUT).config-detected)detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected)detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected) CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS) include $(srctree)/tools/scripts/Makefile.arch $(call detected_var,SRCARCH) NO_PERF_REGS := 1 ifneq ($(NO_SYSCALL_TABLE),1) NO_SYSCALL_TABLE := 1 ifeq ($(SRCARCH),x86) ifeq (${IS_64_BIT}, 1) NO_SYSCALL_TABLE := 0 endif else ifeq ($(SRCARCH),$(filter $(SRCARCH),powerpc arm64 s390)) NO_SYSCALL_TABLE := 0 endif endif ifneq ($(NO_SYSCALL_TABLE),1) CFLAGS += -DHAVE_SYSCALL_TABLE_SUPPORT endifendif # Additional ARCH settings for ppcifeq ($(SRCARCH),powerpc) NO_PERF_REGS := 0 CFLAGS += -I$(OUTPUT)arch/powerpc/include/generated LIBUNWIND_LIBS := -lunwind -lunwind-ppc64endif # Additional ARCH settings for x86ifeq ($(SRCARCH),x86) $(call detected,CONFIG_X86) ifeq (${IS_64_BIT}, 1) CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT -I$(OUTPUT)arch/x86/include/generated ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma $(call detected,CONFIG_X86_64) else LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind endif NO_PERF_REGS := 0endif ifeq ($(SRCARCH),arm) NO_PERF_REGS := 0 LIBUNWIND_LIBS = -lunwind -lunwind-armendif ifeq ($(SRCARCH),arm64) NO_PERF_REGS := 0 CFLAGS += -I$(OUTPUT)arch/arm64/include/generated LIBUNWIND_LIBS = -lunwind -lunwind-aarch64endif ifeq ($(SRCARCH),riscv) NO_PERF_REGS := 0endif ifeq ($(SRCARCH),csky) NO_PERF_REGS := 0endif ifeq ($(ARCH),s390) NO_PERF_REGS := 0 CFLAGS += -fPIC -I$(OUTPUT)arch/s390/include/generatedendif ifeq ($(NO_PERF_REGS),0) $(call detected,CONFIG_PERF_REGS)endif # So far there's only x86 and arm libdw unwind support merged in perf.# Disable it on all other architectures in case libdw unwind# support is detected in system. Add supported architectures# to the check.ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc s390 csky riscv)) NO_LIBDW_DWARF_UNWIND := 1endif ifeq ($(LIBUNWIND_LIBS),) NO_LIBUNWIND := 1endif## For linking with debug library, run like:## make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/# libunwind_arch_set_flags = $(eval $(libunwind_arch_set_flags_code))define libunwind_arch_set_flags_code FEATURE_CHECK_CFLAGS-libunwind-$(1) = -I$(LIBUNWIND_DIR)/include FEATURE_CHECK_LDFLAGS-libunwind-$(1) = -L$(LIBUNWIND_DIR)/libendef ifdef LIBUNWIND_DIR LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib LIBUNWIND_ARCHS = x86 x86_64 arm aarch64 debug-frame-arm debug-frame-aarch64 $(foreach libunwind_arch,$(LIBUNWIND_ARCHS),$(call libunwind_arch_set_flags,$(libunwind_arch)))endif # Set per-feature check compilation flagsFEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS) FEATURE_CHECK_LDFLAGS-libunwind-arm = -lunwind -lunwind-armFEATURE_CHECK_LDFLAGS-libunwind-aarch64 = -lunwind -lunwind-aarch64FEATURE_CHECK_LDFLAGS-libunwind-x86 = -lunwind -llzma -lunwind-x86FEATURE_CHECK_LDFLAGS-libunwind-x86_64 = -lunwind -llzma -lunwind-x86_64 FEATURE_CHECK_LDFLAGS-libcrypto = -lcrypto ifdef CSINCLUDES LIBOPENCSD_CFLAGS := -I$(CSINCLUDES)endifOPENCSDLIBS := -lopencsd_c_api -lopencsdifdef CSLIBS LIBOPENCSD_LDFLAGS := -L$(CSLIBS)endifFEATURE_CHECK_CFLAGS-libopencsd := $(LIBOPENCSD_CFLAGS)FEATURE_CHECK_LDFLAGS-libopencsd := $(LIBOPENCSD_LDFLAGS) $(OPENCSDLIBS) ifeq ($(NO_PERF_REGS),0) CFLAGS += -DHAVE_PERF_REGS_SUPPORTendif # for linking with debug library, run like:# make DEBUG=1 LIBDW_DIR=/opt/libdw/ifdef LIBDW_DIR LIBDW_CFLAGS := -I$(LIBDW_DIR)/include LIBDW_LDFLAGS := -L$(LIBDW_DIR)/libendifDWARFLIBS := -ldwifeq ($(findstring -static,${LDFLAGS}),-static) DWARFLIBS += -lelf -lebl -ldl -lz -llzma -lbz2endifFEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) $(DWARFLIBS) # for linking with debug library, run like:# make DEBUG=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/ifdef LIBBABELTRACE_DIR LIBBABELTRACE_CFLAGS := -I$(LIBBABELTRACE_DIR)/include LIBBABELTRACE_LDFLAGS := -L$(LIBBABELTRACE_DIR)/libendifFEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS)FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf ifdef LIBZSTD_DIR LIBZSTD_CFLAGS := -I$(LIBZSTD_DIR)/lib LIBZSTD_LDFLAGS := -L$(LIBZSTD_DIR)/libendifFEATURE_CHECK_CFLAGS-libzstd := $(LIBZSTD_CFLAGS)FEATURE_CHECK_LDFLAGS-libzstd := $(LIBZSTD_LDFLAGS) FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi# include ARCH specific config-include $(src-perf)/arch/$(SRCARCH)/Makefile ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSETendif include $(srctree)/tools/scripts/utilities.mak ifeq ($(call get-executable,$(FLEX)),) dummy := $(error Error: $(FLEX) is missing on this system, please install it)endif ifeq ($(call get-executable,$(BISON)),) dummy := $(error Error: $(BISON) is missing on this system, please install it)endif # Treat warnings as errors unless directed not toifneq ($(WERROR),0) CORE_CFLAGS += -Werror CXXFLAGS += -Werrorendif ifndef DEBUG DEBUG := 0endif ifeq ($(DEBUG),0)ifeq ($(CC_NO_CLANG), 0) CORE_CFLAGS += -O3else CORE_CFLAGS += -O6endifendif ifdef PARSER_DEBUG PARSER_DEBUG_BISON := -t PARSER_DEBUG_FLEX := -d CFLAGS += -DPARSER_DEBUG $(call detected_var,PARSER_DEBUG_BISON) $(call detected_var,PARSER_DEBUG_FLEX)endif # Try different combinations to accommodate systems that only have# python[2][-config] in weird combinations but always preferring# python2 and python2-config as per pep-0394. If we catch a# python[-config] in version 3, the version check will kill it.PYTHON2 := $(if $(call get-executable,python2),python2,python)override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2))PYTHON2_CONFIG := \ $(if $(call get-executable,$(PYTHON)-config),$(PYTHON)-config,python-config)override PYTHON_CONFIG := \ $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON2_CONFIG)) grep-libs = $(filter -l%,$(1))strip-libs = $(filter-out -l%,$(1)) PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG)) # Python 3.8 changed the output of `python-config --ldflags` to not include the# '-lpythonX.Y' flag unless '--embed' is also passed. The feature check for# libpython fails if that flag is not included in LDFLAGSifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null; echo $$?), 0) PYTHON_CONFIG_LDFLAGS := --ldflags --embedelse PYTHON_CONFIG_LDFLAGS := --ldflagsendif ifdef PYTHON_CONFIG PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null) PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null) FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)endif FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS)FEATURE_CHECK_LDFLAGS-libpython-version := $(PYTHON_EMBED_LDOPTS) FEATURE_CHECK_LDFLAGS-libaio = -lrt FEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes -ldl CORE_CFLAGS += -fno-omit-frame-pointerCORE_CFLAGS += -ggdb3CORE_CFLAGS += -funwind-tablesCORE_CFLAGS += -WallCORE_CFLAGS += -WextraCORE_CFLAGS += -std=gnu99 CXXFLAGS += -std=gnu++11 -fno-exceptions -fno-rttiCXXFLAGS += -WallCXXFLAGS += -fno-omit-frame-pointerCXXFLAGS += -ggdb3CXXFLAGS += -funwind-tablesCXXFLAGS += -Wno-strict-aliasing # Enforce a non-executable stack, as we may regress (again) in the future by# adding assembler files missing the .GNU-stack linker note.LDFLAGS += -Wl,-z,noexecstack EXTLIBS = -lpthread -lrt -lm -ldl ifneq ($(TCMALLOC),) CFLAGS += -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free EXTLIBS += -ltcmallocendif ifeq ($(FEATURES_DUMP),)include $(srctree)/tools/build/Makefile.featureelseinclude $(FEATURES_DUMP)endif ifeq ($(feature-stackprotector-all), 1) CORE_CFLAGS += -fstack-protector-allendif ifeq ($(DEBUG),0) ifeq ($(feature-fortify-source), 1) CORE_CFLAGS += -D_FORTIFY_SOURCE=2 endifendif INC_FLAGS += -I$(srctree)/tools/lib/perf/includeINC_FLAGS += -I$(src-perf)/util/includeINC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/includeINC_FLAGS += -I$(srctree)/tools/include/INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapiINC_FLAGS += -I$(srctree)/tools/include/uapiINC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/ # $(obj-perf) for generated common-cmds.h# $(obj-perf)/util for generated bison/flex headersifneq ($(OUTPUT),)INC_FLAGS += -I$(obj-perf)/utilINC_FLAGS += -I$(obj-perf)endif INC_FLAGS += -I$(src-perf)/utilINC_FLAGS += -I$(src-perf)INC_FLAGS += -I$(srctree)/tools/lib/ CORE_CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE CFLAGS += $(CORE_CFLAGS) $(INC_FLAGS)CXXFLAGS += $(INC_FLAGS) LIBPERF_CFLAGS := $(CORE_CFLAGS) $(EXTRA_CFLAGS) ifeq ($(feature-sync-compare-and-swap), 1) CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORTendif ifeq ($(feature-pthread-attr-setaffinity-np), 1) CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NPendif ifeq ($(feature-pthread-barrier), 1) CFLAGS += -DHAVE_PTHREAD_BARRIERendif ifndef NO_BIONIC $(call feature_check,bionic) ifeq ($(feature-bionic), 1) BIONIC := 1 CFLAGS += -DLACKS_SIGQUEUE_PROTOTYPE CFLAGS += -DLACKS_OPEN_MEMSTREAM_PROTOTYPE EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) endifendif ifeq ($(feature-eventfd), 1) CFLAGS += -DHAVE_EVENTFD_SUPPORTendif ifeq ($(feature-get_current_dir_name), 1) CFLAGS += -DHAVE_GET_CURRENT_DIR_NAMEendif ifeq ($(feature-gettid), 1) CFLAGS += -DHAVE_GETTIDendif ifeq ($(feature-file-handle), 1) CFLAGS += -DHAVE_FILE_HANDLEendif ifdef NO_LIBELF NO_DWARF := 1 NO_DEMANGLE := 1 NO_LIBUNWIND := 1 NO_LIBDW_DWARF_UNWIND := 1 NO_LIBBPF := 1 NO_JVMTI := 1else ifeq ($(feature-libelf), 0) ifeq ($(feature-glibc), 1) LIBC_SUPPORT := 1 endif ifeq ($(BIONIC),1) LIBC_SUPPORT := 1 endif ifeq ($(LIBC_SUPPORT),1) msg := $(warning No libelf found. Disables 'probe' tool, jvmti and BPF support in 'perf record'. Please install libelf-dev, libelf-devel or elfutils-libelf-devel); NO_LIBELF := 1 NO_DWARF := 1 NO_DEMANGLE := 1 NO_LIBUNWIND := 1 NO_LIBDW_DWARF_UNWIND := 1 NO_LIBBPF := 1 NO_JVMTI := 1 else ifneq ($(filter s% -fsanitize=address%,$(EXTRA_CFLAGS),),) ifneq ($(shell ldconfig -p | grep libasan >/dev/null 2>&1; echo $$?), 0) msg := $(error No libasan found, please install libasan); endif endif ifneq ($(filter s% -fsanitize=undefined%,$(EXTRA_CFLAGS),),) ifneq ($(shell ldconfig -p | grep libubsan >/dev/null 2>&1; echo $$?), 0) msg := $(error No libubsan found, please install libubsan); endif endif ifneq ($(filter s% -static%,$(LDFLAGS),),) msg := $(error No static glibc found, please install glibc-static); else msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]); endif endif else ifndef NO_LIBDW_DWARF_UNWIND ifneq ($(feature-libdw-dwarf-unwind),1) NO_LIBDW_DWARF_UNWIND := 1 msg := $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR); endif endif ifneq ($(feature-dwarf), 1) ifndef NO_DWARF msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev); NO_DWARF := 1 endif else ifneq ($(feature-dwarf_getlocations), 1) msg := $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157); else CFLAGS += -DHAVE_DWARF_GETLOCATIONS_SUPPORT endif # dwarf_getlocations endif # Dwarf support endif # libelf supportendif # NO_LIBELF ifeq ($(feature-glibc), 1) CFLAGS += -DHAVE_GLIBC_SUPPORTendif ifeq ($(feature-libaio), 1) ifndef NO_AIO CFLAGS += -DHAVE_AIO_SUPPORT endifendif ifdef NO_DWARF NO_LIBDW_DWARF_UNWIND := 1endif ifeq ($(feature-sched_getcpu), 1) CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORTendif ifeq ($(feature-setns), 1) CFLAGS += -DHAVE_SETNS_SUPPORT $(call detected,CONFIG_SETNS)endif ifdef CORESIGHT $(call feature_check,libopencsd) ifeq ($(feature-libopencsd), 1) CFLAGS += -DHAVE_CSTRACE_SUPPORT $(LIBOPENCSD_CFLAGS) ifeq ($(feature-reallocarray), 0) CFLAGS += -DCOMPAT_NEED_REALLOCARRAY endif LDFLAGS += $(LIBOPENCSD_LDFLAGS) EXTLIBS += $(OPENCSDLIBS) $(call detected,CONFIG_LIBOPENCSD) ifdef CSTRACE_RAW CFLAGS += -DCS_DEBUG_RAW ifeq (${CSTRACE_RAW}, packed) CFLAGS += -DCS_RAW_PACKED endif endif endifendif ifndef NO_LIBELF CFLAGS += -DHAVE_LIBELF_SUPPORT EXTLIBS += -lelf $(call detected,CONFIG_LIBELF) ifeq ($(feature-libelf-mmap), 1) CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT endif ifeq ($(feature-libelf-getphdrnum), 1) CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT endif ifeq ($(feature-libelf-gelf_getnote), 1) CFLAGS += -DHAVE_GELF_GETNOTE_SUPPORT else msg := $(warning gelf_getnote() not found on libelf, SDT support disabled); endif ifeq ($(feature-libelf-getshdrstrndx), 1)Lines 1–500 of 1193. Load more
# SPDX-License-Identifier: GPL-2.0-only ifeq ($(src-perf),) src-perf := $(srctree)/tools/perf endif ifeq ($(obj-perf),) obj-perf := $(OUTPUT) endif ifneq ($(obj-perf),) obj-perf := $(abspath $(obj-perf))/ endif $(shell printf "" > $(OUTPUT).config-detected) detected = $(shell echo "$(1)=y" >> $(OUTPUT).config-detected) detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected) CFLAGS := $(EXTRA_CFLAGS) $(EXTRA_WARNINGS) include $(srctree)/tools/scripts/Makefile.arch $(call detected_var,SRCARCH) NO_PERF_REGS := 1 ifneq ($(NO_SYSCALL_TABLE),1) NO_SYSCALL_TABLE := 1 ifeq ($(SRCARCH),x86) ifeq (${IS_64_BIT}, 1) NO_SYSCALL_TABLE := 0 endif else ifeq ($(SRCARCH),$(filter $(SRCARCH),powerpc arm64 s390)) NO_SYSCALL_TABLE := 0 endif endif ifneq ($(NO_SYSCALL_TABLE),1) CFLAGS += -DHAVE_SYSCALL_TABLE_SUPPORT endif endif # Additional ARCH settings for ppc ifeq ($(SRCARCH),powerpc) NO_PERF_REGS := 0 CFLAGS += -I$(OUTPUT)arch/powerpc/include/generated LIBUNWIND_LIBS := -lunwind -lunwind-ppc64 endif # Additional ARCH settings for x86 ifeq ($(SRCARCH),x86) $(call detected,CONFIG_X86) ifeq (${IS_64_BIT}, 1) CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT -I$(OUTPUT)arch/x86/include/generated ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma $(call detected,CONFIG_X86_64) else LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind endif NO_PERF_REGS := 0 endif ifeq ($(SRCARCH),arm) NO_PERF_REGS := 0 LIBUNWIND_LIBS = -lunwind -lunwind-arm endif ifeq ($(SRCARCH),arm64) NO_PERF_REGS := 0 CFLAGS += -I$(OUTPUT)arch/arm64/include/generated LIBUNWIND_LIBS = -lunwind -lunwind-aarch64 endif ifeq ($(SRCARCH),riscv) NO_PERF_REGS := 0 endif ifeq ($(SRCARCH),csky) NO_PERF_REGS := 0 endif ifeq ($(ARCH),s390) NO_PERF_REGS := 0 CFLAGS += -fPIC -I$(OUTPUT)arch/s390/include/generated endif ifeq ($(NO_PERF_REGS),0) $(call detected,CONFIG_PERF_REGS) endif # So far there's only x86 and arm libdw unwind support merged in perf. # Disable it on all other architectures in case libdw unwind # support is detected in system. Add supported architectures # to the check. ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc s390 csky riscv)) NO_LIBDW_DWARF_UNWIND := 1 endif ifeq ($(LIBUNWIND_LIBS),) NO_LIBUNWIND := 1 endif # # For linking with debug library, run like: # # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/ # libunwind_arch_set_flags = $(eval $(libunwind_arch_set_flags_code)) define libunwind_arch_set_flags_code FEATURE_CHECK_CFLAGS-libunwind-$(1) = -I$(LIBUNWIND_DIR)/include FEATURE_CHECK_LDFLAGS-libunwind-$(1) = -L$(LIBUNWIND_DIR)/lib endef ifdef LIBUNWIND_DIR LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib LIBUNWIND_ARCHS = x86 x86_64 arm aarch64 debug-frame-arm debug-frame-aarch64 $(foreach libunwind_arch,$(LIBUNWIND_ARCHS),$(call libunwind_arch_set_flags,$(libunwind_arch))) endif # Set per-feature check compilation flags FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS) FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS) FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS) FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS) FEATURE_CHECK_LDFLAGS-libunwind-arm = -lunwind -lunwind-arm FEATURE_CHECK_LDFLAGS-libunwind-aarch64 = -lunwind -lunwind-aarch64 FEATURE_CHECK_LDFLAGS-libunwind-x86 = -lunwind -llzma -lunwind-x86 FEATURE_CHECK_LDFLAGS-libunwind-x86_64 = -lunwind -llzma -lunwind-x86_64 FEATURE_CHECK_LDFLAGS-libcrypto = -lcrypto ifdef CSINCLUDES LIBOPENCSD_CFLAGS := -I$(CSINCLUDES) endif OPENCSDLIBS := -lopencsd_c_api -lopencsd ifdef CSLIBS LIBOPENCSD_LDFLAGS := -L$(CSLIBS) endif FEATURE_CHECK_CFLAGS-libopencsd := $(LIBOPENCSD_CFLAGS) FEATURE_CHECK_LDFLAGS-libopencsd := $(LIBOPENCSD_LDFLAGS) $(OPENCSDLIBS) ifeq ($(NO_PERF_REGS),0) CFLAGS += -DHAVE_PERF_REGS_SUPPORT endif # for linking with debug library, run like: # make DEBUG=1 LIBDW_DIR=/opt/libdw/ ifdef LIBDW_DIR LIBDW_CFLAGS := -I$(LIBDW_DIR)/include LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib endif DWARFLIBS := -ldw ifeq ($(findstring -static,${LDFLAGS}),-static) DWARFLIBS += -lelf -lebl -ldl -lz -llzma -lbz2 endif FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS) FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) $(DWARFLIBS) # for linking with debug library, run like: # make DEBUG=1 LIBBABELTRACE_DIR=/opt/libbabeltrace/ ifdef LIBBABELTRACE_DIR LIBBABELTRACE_CFLAGS := -I$(LIBBABELTRACE_DIR)/include LIBBABELTRACE_LDFLAGS := -L$(LIBBABELTRACE_DIR)/lib endif FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS) FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) -lbabeltrace-ctf ifdef LIBZSTD_DIR LIBZSTD_CFLAGS := -I$(LIBZSTD_DIR)/lib LIBZSTD_LDFLAGS := -L$(LIBZSTD_DIR)/lib endif FEATURE_CHECK_CFLAGS-libzstd := $(LIBZSTD_CFLAGS) FEATURE_CHECK_LDFLAGS-libzstd := $(LIBZSTD_LDFLAGS) FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi # include ARCH specific config -include $(src-perf)/arch/$(SRCARCH)/Makefile ifdef PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET CFLAGS += -DHAVE_ARCH_REGS_QUERY_REGISTER_OFFSET endif include $(srctree)/tools/scripts/utilities.mak ifeq ($(call get-executable,$(FLEX)),) dummy := $(error Error: $(FLEX) is missing on this system, please install it) endif ifeq ($(call get-executable,$(BISON)),) dummy := $(error Error: $(BISON) is missing on this system, please install it) endif # Treat warnings as errors unless directed not to ifneq ($(WERROR),0) CORE_CFLAGS += -Werror CXXFLAGS += -Werror endif ifndef DEBUG DEBUG := 0 endif ifeq ($(DEBUG),0) ifeq ($(CC_NO_CLANG), 0) CORE_CFLAGS += -O3 else CORE_CFLAGS += -O6 endif endif ifdef PARSER_DEBUG PARSER_DEBUG_BISON := -t PARSER_DEBUG_FLEX := -d CFLAGS += -DPARSER_DEBUG $(call detected_var,PARSER_DEBUG_BISON) $(call detected_var,PARSER_DEBUG_FLEX) endif # Try different combinations to accommodate systems that only have # python[2][-config] in weird combinations but always preferring # python2 and python2-config as per pep-0394. If we catch a # python[-config] in version 3, the version check will kill it. PYTHON2 := $(if $(call get-executable,python2),python2,python) override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2)) PYTHON2_CONFIG := \ $(if $(call get-executable,$(PYTHON)-config),$(PYTHON)-config,python-config) override PYTHON_CONFIG := \ $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON2_CONFIG)) grep-libs = $(filter -l%,$(1)) strip-libs = $(filter-out -l%,$(1)) PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG)) # Python 3.8 changed the output of `python-config --ldflags` to not include the # '-lpythonX.Y' flag unless '--embed' is also passed. The feature check for # libpython fails if that flag is not included in LDFLAGS ifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null; echo $$?), 0) PYTHON_CONFIG_LDFLAGS := --ldflags --embed else PYTHON_CONFIG_LDFLAGS := --ldflags endif ifdef PYTHON_CONFIG PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null) PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null) FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) endif FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS) FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS) FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS) FEATURE_CHECK_LDFLAGS-libpython-version := $(PYTHON_EMBED_LDOPTS) FEATURE_CHECK_LDFLAGS-libaio = -lrt FEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes -ldl CORE_CFLAGS += -fno-omit-frame-pointer CORE_CFLAGS += -ggdb3 CORE_CFLAGS += -funwind-tables CORE_CFLAGS += -Wall CORE_CFLAGS += -Wextra CORE_CFLAGS += -std=gnu99 CXXFLAGS += -std=gnu++11 -fno-exceptions -fno-rtti CXXFLAGS += -Wall CXXFLAGS += -fno-omit-frame-pointer CXXFLAGS += -ggdb3 CXXFLAGS += -funwind-tables CXXFLAGS += -Wno-strict-aliasing # Enforce a non-executable stack, as we may regress (again) in the future by # adding assembler files missing the .GNU-stack linker note. LDFLAGS += -Wl,-z,noexecstack EXTLIBS = -lpthread -lrt -lm -ldl ifneq ($(TCMALLOC),) CFLAGS += -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free EXTLIBS += -ltcmalloc endif ifeq ($(FEATURES_DUMP),) include $(srctree)/tools/build/Makefile.feature else include $(FEATURES_DUMP) endif ifeq ($(feature-stackprotector-all), 1) CORE_CFLAGS += -fstack-protector-all endif ifeq ($(DEBUG),0) ifeq ($(feature-fortify-source), 1) CORE_CFLAGS += -D_FORTIFY_SOURCE=2 endif endif INC_FLAGS += -I$(srctree)/tools/lib/perf/include INC_FLAGS += -I$(src-perf)/util/include INC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include INC_FLAGS += -I$(srctree)/tools/include/ INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi INC_FLAGS += -I$(srctree)/tools/include/uapi INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/ INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/ # $(obj-perf) for generated common-cmds.h # $(obj-perf)/util for generated bison/flex headers ifneq ($(OUTPUT),) INC_FLAGS += -I$(obj-perf)/util INC_FLAGS += -I$(obj-perf) endif INC_FLAGS += -I$(src-perf)/util INC_FLAGS += -I$(src-perf) INC_FLAGS += -I$(srctree)/tools/lib/ CORE_CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE CFLAGS += $(CORE_CFLAGS) $(INC_FLAGS) CXXFLAGS += $(INC_FLAGS) LIBPERF_CFLAGS := $(CORE_CFLAGS) $(EXTRA_CFLAGS) ifeq ($(feature-sync-compare-and-swap), 1) CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT endif ifeq ($(feature-pthread-attr-setaffinity-np), 1) CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP endif ifeq ($(feature-pthread-barrier), 1) CFLAGS += -DHAVE_PTHREAD_BARRIER endif ifndef NO_BIONIC $(call feature_check,bionic) ifeq ($(feature-bionic), 1) BIONIC := 1 CFLAGS += -DLACKS_SIGQUEUE_PROTOTYPE CFLAGS += -DLACKS_OPEN_MEMSTREAM_PROTOTYPE EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) endif endif ifeq ($(feature-eventfd), 1) CFLAGS += -DHAVE_EVENTFD_SUPPORT endif ifeq ($(feature-get_current_dir_name), 1) CFLAGS += -DHAVE_GET_CURRENT_DIR_NAME endif ifeq ($(feature-gettid), 1) CFLAGS += -DHAVE_GETTID endif ifeq ($(feature-file-handle), 1) CFLAGS += -DHAVE_FILE_HANDLE endif ifdef NO_LIBELF NO_DWARF := 1 NO_DEMANGLE := 1 NO_LIBUNWIND := 1 NO_LIBDW_DWARF_UNWIND := 1 NO_LIBBPF := 1 NO_JVMTI := 1 else ifeq ($(feature-libelf), 0) ifeq ($(feature-glibc), 1) LIBC_SUPPORT := 1 endif ifeq ($(BIONIC),1) LIBC_SUPPORT := 1 endif ifeq ($(LIBC_SUPPORT),1) msg := $(warning No libelf found. Disables 'probe' tool, jvmti and BPF support in 'perf record'. Please install libelf-dev, libelf-devel or elfutils-libelf-devel); NO_LIBELF := 1 NO_DWARF := 1 NO_DEMANGLE := 1 NO_LIBUNWIND := 1 NO_LIBDW_DWARF_UNWIND := 1 NO_LIBBPF := 1 NO_JVMTI := 1 else ifneq ($(filter s% -fsanitize=address%,$(EXTRA_CFLAGS),),) ifneq ($(shell ldconfig -p | grep libasan >/dev/null 2>&1; echo $$?), 0) msg := $(error No libasan found, please install libasan); endif endif ifneq ($(filter s% -fsanitize=undefined%,$(EXTRA_CFLAGS),),) ifneq ($(shell ldconfig -p | grep libubsan >/dev/null 2>&1; echo $$?), 0) msg := $(error No libubsan found, please install libubsan); endif endif ifneq ($(filter s% -static%,$(LDFLAGS),),) msg := $(error No static glibc found, please install glibc-static); else msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]); endif endif else ifndef NO_LIBDW_DWARF_UNWIND ifneq ($(feature-libdw-dwarf-unwind),1) NO_LIBDW_DWARF_UNWIND := 1 msg := $(warning No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR); endif endif ifneq ($(feature-dwarf), 1) ifndef NO_DWARF msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev); NO_DWARF := 1 endif else ifneq ($(feature-dwarf_getlocations), 1) msg := $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157); else CFLAGS += -DHAVE_DWARF_GETLOCATIONS_SUPPORT endif # dwarf_getlocations endif # Dwarf support endif # libelf support endif # NO_LIBELF ifeq ($(feature-glibc), 1) CFLAGS += -DHAVE_GLIBC_SUPPORT endif ifeq ($(feature-libaio), 1) ifndef NO_AIO CFLAGS += -DHAVE_AIO_SUPPORT endif endif ifdef NO_DWARF NO_LIBDW_DWARF_UNWIND := 1 endif ifeq ($(feature-sched_getcpu), 1) CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT endif ifeq ($(feature-setns), 1) CFLAGS += -DHAVE_SETNS_SUPPORT $(call detected,CONFIG_SETNS) endif ifdef CORESIGHT $(call feature_check,libopencsd) ifeq ($(feature-libopencsd), 1) CFLAGS += -DHAVE_CSTRACE_SUPPORT $(LIBOPENCSD_CFLAGS) ifeq ($(feature-reallocarray), 0) CFLAGS += -DCOMPAT_NEED_REALLOCARRAY endif LDFLAGS += $(LIBOPENCSD_LDFLAGS) EXTLIBS += $(OPENCSDLIBS) $(call detected,CONFIG_LIBOPENCSD) ifdef CSTRACE_RAW CFLAGS += -DCS_DEBUG_RAW ifeq (${CSTRACE_RAW}, packed) CFLAGS += -DCS_RAW_PACKED endif endif endif endif ifndef NO_LIBELF CFLAGS += -DHAVE_LIBELF_SUPPORT EXTLIBS += -lelf $(call detected,CONFIG_LIBELF) ifeq ($(feature-libelf-mmap), 1) CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT endif ifeq ($(feature-libelf-getphdrnum), 1) CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT endif ifeq ($(feature-libelf-gelf_getnote), 1) CFLAGS += -DHAVE_GELF_GETNOTE_SUPPORT else msg := $(warning gelf_getnote() not found on libelf, SDT support disabled); endif ifeq ($(feature-libelf-getshdrstrndx), 1)