1310 lines · 41.1 KB · Text
RawDownload
# 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) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))HOSTCFLAGS := $(filter-out -Wnested-externs,$(EXTRA_WARNINGS)) # This is required because the kernel is built with this and some of the code# borrowed from kernel headers depends on it, e.g. put_unaligned_*().CFLAGS += -fno-strict-aliasing # Set target flag and options when using clang as compiler.ifeq ($(CC_NO_CLANG), 0)  CLANG_TARGET_FLAGS_arm	:= arm-linux-gnueabi  CLANG_TARGET_FLAGS_arm64	:= aarch64-linux-gnu  CLANG_TARGET_FLAGS_loongarch	:= loongarch64-linux-gnu  CLANG_TARGET_FLAGS_m68k	:= m68k-linux-gnu  CLANG_TARGET_FLAGS_mips	:= mipsel-linux-gnu  CLANG_TARGET_FLAGS_powerpc	:= powerpc64le-linux-gnu  CLANG_TARGET_FLAGS_riscv	:= riscv64-linux-gnu  CLANG_TARGET_FLAGS_s390	:= s390x-linux-gnu  CLANG_TARGET_FLAGS_x86	:= x86_64-linux-gnu  CLANG_TARGET_FLAGS_x86_64	:= x86_64-linux-gnu   # Default to host architecture if ARCH is not explicitly given.  ifeq ($(ARCH), $(HOSTARCH))    CLANG_TARGET_FLAGS := $(shell $(CLANG) -print-target-triple)  else    CLANG_TARGET_FLAGS := $(CLANG_TARGET_FLAGS_$(ARCH))  endif   ifeq ($(CROSS_COMPILE),)    ifeq ($(CLANG_TARGET_FLAGS),)      $(error Specify CROSS_COMPILE or add CLANG_TARGET_FLAGS for $(ARCH))    else      CLANG_FLAGS += --target=$(CLANG_TARGET_FLAGS)    endif # CLANG_TARGET_FLAGS  else    CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))  endif # CROSS_COMPILE   CC := $(CLANG) $(CLANG_FLAGS) -fintegrated-as  CXX := $(CXX) $(CLANG_FLAGS) -fintegrated-as   # Enabled Wthread-safety analysis for clang builds.  CFLAGS += -Wthread-safetyendif include $(srctree)/tools/scripts/Makefile.arch $(call detected_var,SRCARCH) CFLAGS += -I$(OUTPUT)arch/$(SRCARCH)/include/generated # Additional ARCH settings for x86ifeq ($(SRCARCH),x86)  $(call detected,CONFIG_X86)  ifeq (${IS_64_BIT}, 1)    CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT    ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S    $(call detected,CONFIG_X86_64)  endifendif ifeq ($(ARCH),s390)  CFLAGS += -fPIC  CXXFLAGS += -fPICendif # Unconditionally set up the libunwind feature build flags as a# feature-dump build doesn't specify LIBUNWIND=1. This means that# dumping the libunwind features will be broken that can impact later# builds that use the feature dump.ifeq ($(SRCARCH),arm)  LIBUNWIND_LIBS = -lunwind -lunwind-armendififeq ($(SRCARCH),arm64)  LIBUNWIND_LIBS = -lunwind -lunwind-aarch64endififeq ($(SRCARCH),loongarch)  LIBUNWIND_LIBS = -lunwind -lunwind-loongarch64endififeq ($(ARCH),mips)  LIBUNWIND_LIBS = -lunwind -lunwind-mipsendififeq ($(SRCARCH),powerpc)  LIBUNWIND_LIBS := -lunwind -lunwind-ppc64endififeq ($(SRCARCH),riscv)  LIBUNWIND_LIBS := -lunwind -lunwind-riscvendififeq ($(SRCARCH),s390)  LIBUNWIND_LIBS := -lunwind -lunwind-s390xendififeq ($(SRCARCH),x86)  ifeq (${IS_64_BIT}, 1)    LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma  else    LIBUNWIND_LIBS = -lunwind-x86 -lunwind -llzma  endifendififneq ($(LIBUNWIND),1)  NO_LIBUNWIND := 1endififeq ($(LIBUNWIND_LIBS),)  NO_LIBUNWIND := 1endif ## For linking with debug library, run like:##   make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/#LIBUNWIND_ARCHS:=aarch64 arm loongarch64 mips ppc32 ppc64 riscv s390x x86 x86_64 # "Local" (no arch specified) feature test 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) # Add directory into the "remote" (build for a a specific arch) feature tests.ifdef LIBUNWIND_DIR  LIBUNWIND_CFLAGS  = -I$(LIBUNWIND_DIR)/include  LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib   define libunwind_arch_set_flags    FEATURE_CHECK_CFLAGS-libunwind-$(1)  = -I$(LIBUNWIND_DIR)/include    FEATURE_CHECK_LDFLAGS-libunwind-$(1) = -L$(LIBUNWIND_DIR)/lib -lunwind -lunwind-$(1)  endef  $(foreach arch,$(LIBUNWIND_ARCHS), \    $(eval $(call libunwind_arch_set_flags,$(arch))) \  )endif ifdef CSINCLUDES  LIBOPENCSD_CFLAGS := -I$(CSINCLUDES)endifOPENCSDLIBS := -lopencsd_c_api -lopencsdifeq ($(findstring -static,${LDFLAGS}),-static)  OPENCSDLIBS += -lstdc++endififdef CSLIBS  LIBOPENCSD_LDFLAGS := -L$(CSLIBS)endifFEATURE_CHECK_CFLAGS-libopencsd := $(LIBOPENCSD_CFLAGS)FEATURE_CHECK_LDFLAGS-libopencsd := $(LIBOPENCSD_LDFLAGS) $(OPENCSDLIBS) # 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 -lz -llzma -lbz2   LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw).0.0  LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION)))  LIBDW_VERSION_2 := $(word 2, $(subst ., ,$(LIBDW_VERSION)))   # Elfutils merged libebl.a into libdw.a starting from version 0.177,  # Link libebl.a only if libdw is older than this version.  ifeq ($(shell test $(LIBDW_VERSION_2) -lt 177; echo $$?),0)    DWARFLIBS += -lebl  endif   # Must put -ldl after -lebl for dependency  DWARFLIBS += -ldlendifFEATURE_CHECK_CFLAGS-libdw := $(LIBDW_CFLAGS)FEATURE_CHECK_LDFLAGS-libdw := $(LIBDW_LDFLAGS) $(DWARFLIBS) ifneq ($(NO_BABELTRACE2),1)  ifeq ($(call get-executable,$(PKG_CONFIG)),)    $(error Error: $(PKG_CONFIG) needed by babeltrace2 is missing on this system, please install it)  endifendif # for linking with debug library, run like:# make DEBUG=1 LIBCAPSTONE_DIR=/opt/capstone/ifdef LIBCAPSTONE_DIR  LIBCAPSTONE_CFLAGS  := -I$(LIBCAPSTONE_DIR)/include  LIBCAPSTONE_LDFLAGS := -L$(LIBCAPSTONE_DIR)/endifFEATURE_CHECK_CFLAGS-libcapstone := $(LIBCAPSTONE_CFLAGS)FEATURE_CHECK_LDFLAGS-libcapstone := $(LIBCAPSTONE_LDFLAGS) -lcapstone 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) # for linking with debug library, run like:# make DEBUG=1 PKG_CONFIG_PATH=/opt/libtraceevent/(lib|lib64)/pkgconfig ifneq ($(NO_LIBTRACEEVENT),1)  ifeq ($(call get-executable,$(PKG_CONFIG)),)    $(error Error: $(PKG_CONFIG) needed by libtraceevent is missing on this system, please install it)  endifendif 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 include $(srctree)/tools/scripts/utilities.mak ifeq ($(call get-executable,$(FLEX)),)  $(error Error: $(FLEX) is missing on this system, please install it)endif ifeq ($(call get-executable,$(BISON)),)  $(error Error: $(BISON) is missing on this system, please install it)endif ifneq ($(OUTPUT),)  ifeq ($(shell expr $(shell $(BISON) --version | grep bison | sed -e 's/.\+ \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \>\= 371), 1)    BISON_FILE_PREFIX_MAP := --file-prefix-map=$(OUTPUT)=  endifendif # Treat warnings as errors unless directed not toifneq ($(WERROR),0)  CORE_CFLAGS += -Werror  CXXFLAGS += -Werror  HOSTCFLAGS += -Werrorendif ifndef DEBUG  DEBUG := 0endif ifeq ($(DEBUG),0)CORE_CFLAGS += -DNDEBUG=1CORE_CFLAGS += -O3else  CORE_CFLAGS += -g  CXXFLAGS += -gendif 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 ifdef LTO  CORE_CFLAGS += -flto  CXXFLAGS += -fltoendif # Try different combinations to accommodate systems that only have# python[2][3]-config in weird combinations in the following order of# priority from lowest to highest:#   * python2-config as per pep-0394.#   * python-config#   * python3-config#   * $(PYTHON)-config (If PYTHON is user supplied but PYTHON_CONFIG isn't)#PYTHON_AUTO := python-configPYTHON_AUTO := $(if $(call get-executable,python2-config),python2-config,$(PYTHON_AUTO))PYTHON_AUTO := $(if $(call get-executable,python-config),python-config,$(PYTHON_AUTO))PYTHON_AUTO := $(if $(call get-executable,python3-config),python3-config,$(PYTHON_AUTO)) # If PYTHON is defined but PYTHON_CONFIG isn't, then take $(PYTHON)-config as if it was the user# supplied value for PYTHON_CONFIG. Because it's "user supplied", error out if it doesn't exist.ifdef PYTHON  ifndef PYTHON_CONFIG    PYTHON_CONFIG_AUTO := $(call get-executable,$(PYTHON)-config)    PYTHON_CONFIG := $(if $(PYTHON_CONFIG_AUTO),$(PYTHON_CONFIG_AUTO),\                          $(call $(error $(PYTHON)-config not found)))  endifendif # Select either auto detected python and python-config or use user supplied values if they are# defined. get-executable-or-default fails with an error if the first argument is supplied but# doesn't exist.override PYTHON_CONFIG := $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON_AUTO))override PYTHON := $(call get-executable-or-default,PYTHON,$(subst -config,,$(PYTHON_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)  # Update the python flags for cross compilation  ifdef CROSS_COMPILE    PYTHON_NATIVE := $(shell echo $(PYTHON_EMBED_LDOPTS) | sed 's/\(-L.*\/\)\(.*-linux-gnu\).*/\2/')    PYTHON_EMBED_LDOPTS := $(subst $(PYTHON_NATIVE),$(shell $(CC) -dumpmachine),$(PYTHON_EMBED_LDOPTS))  endif  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)  ifeq ($(CC_NO_CLANG), 0)    PYTHON_EMBED_CCOPTS := $(filter-out -ffat-lto-objects, $(PYTHON_EMBED_CCOPTS))  endifendif FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS) FEATURE_CHECK_LDFLAGS-libaio = -lrt CORE_CFLAGS += -fno-omit-frame-pointerCORE_CFLAGS += -WallCORE_CFLAGS += -WextraCORE_CFLAGS += -std=gnu11CORE_CFLAGS += -funsigned-char CXXFLAGS += -std=gnu++17 -fno-exceptions -fno-rttiCXXFLAGS += -WallCXXFLAGS += -WextraCXXFLAGS += -fno-omit-frame-pointer HOSTCFLAGS += -WallHOSTCFLAGS += -Wextra # 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),)# We will display at the end of this Makefile.config, using $(call feature_display_entries),# as we may retry some feature detection here.  FEATURE_DISPLAY_DEFERRED := 1include $(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 += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2  endifendif INC_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) 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-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-gettid), 1)  CFLAGS += -DHAVE_GETTIDendif ifeq ($(feature-file-handle), 1)  CFLAGS += -DHAVE_FILE_HANDLEendif ifdef NO_LIBELF  NO_LIBDW := 1  NO_LIBUNWIND := 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)      $(error ERROR: No libelf found. Disables 'probe' tool, jvmti and BPF support. Please install libelf-dev, libelf-devel, elfutils-libelf-devel or build with NO_LIBELF=1.)    else      ifneq ($(filter s% -fsanitize=address%,$(EXTRA_CFLAGS),),)        ifneq ($(shell ldconfig -p | grep libasan >/dev/null 2>&1; echo $$?), 0)          $(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)          $(error No libubsan found, please install libubsan)        endif      endif       ifneq ($(filter s% -static%,$(LDFLAGS),),)        $(error No static glibc found, please install glibc-static)      else        $(error No gnu/libc-version.h found, please install glibc-dev[el])      endif    endif  else    ifneq ($(feature-libdw), 1)      ifndef NO_LIBDW        $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.157, disables dwarf support. Please install new elfutils-devel/libdw-dev)        NO_LIBDW := 1      endif    endif # Dwarf support  endif # libelf supportendif # NO_LIBELF ifeq ($(feature-libaio), 1)  ifndef NO_AIO    CFLAGS += -DHAVE_AIO_SUPPORT  endifendif ifeq ($(feature-scandirat), 1)  # Ignore having scandirat with memory sanitizer that lacks an interceptor.  ifeq ($(filter s% -fsanitize=memory%,$(EXTRA_CFLAGS),),)    CFLAGS += -DHAVE_SCANDIRAT_SUPPORT  endifendif ifeq ($(feature-sched_getcpu), 1)  CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORTendif ifeq ($(feature-setns), 1)  CFLAGS += -DHAVE_SETNS_SUPPORT  $(call detected,CONFIG_SETNS)endif

Lines 1–500 of 1310.