baa55a4e26
gcc-12 is starting to trickle down to some distros, like Archlinux. gcc-12 has new warnings, and detects more cases of issues, like new UAF cases, which is causing build issues in code that was previously building fine, as reported in #14826: In file included from sigchain.c:3: In function 'xrealloc', inlined from 'sigchain_push.isra' at sigchain.c:26:2: subcmd-util.h:56:23: error: pointer may be used after 'realloc' [-Werror=use-after-free] 56 | ret = realloc(ptr, size); | ^~~~~~~~~~~~~~~~~~ subcmd-util.h:52:21: note: call to 'realloc' here 52 | void *ret = realloc(ptr, size); | ^~~~~~~~~~~~~~~~~~ subcmd-util.h:58:31: error: pointer may be used after 'realloc' [-Werror=use-after-free] 58 | ret = realloc(ptr, 1); | ^~~~~~~~~~~~~~~ subcmd-util.h:52:21: note: call to 'realloc' here 52 | void *ret = realloc(ptr, size); | ^~~~~~~~~~~~~~~~~~ In that case, the kernel has already fixed their code, which is part of 5.17: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=52a9dab6d892763b2a8334a568bd4e2c1a6fde66 However, we can't easily carry that patch, because we don't know whether the kernel the user uses already has the fix or not. Instead, we can just tell the kernel to disable use of -Werror when building host tools. As a consequence, we can drop it from the perf-specific setting. Fixes: #14826 Reported-by: Anders Pitman <buildroot@apitman.com> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
173 lines
4.8 KiB
Makefile
173 lines
4.8 KiB
Makefile
################################################################################
|
|
#
|
|
# perf
|
|
#
|
|
################################################################################
|
|
|
|
LINUX_TOOLS += perf
|
|
|
|
PERF_DEPENDENCIES = host-flex host-bison
|
|
|
|
ifeq ($(NORMALIZED_ARCH),x86_64)
|
|
PERF_ARCH=x86
|
|
else
|
|
PERF_ARCH=$(NORMALIZED_ARCH)
|
|
endif
|
|
|
|
PERF_MAKE_FLAGS = \
|
|
$(LINUX_MAKE_FLAGS) \
|
|
JOBS=$(PARALLEL_JOBS) \
|
|
ARCH=$(PERF_ARCH) \
|
|
DESTDIR=$(TARGET_DIR) \
|
|
prefix=/usr \
|
|
NO_GTK2=1 \
|
|
NO_LIBPERL=1 \
|
|
NO_LIBPYTHON=1 \
|
|
NO_LIBBIONIC=1
|
|
|
|
# We need to pass an argument to ld for setting the emulation when
|
|
# building for MIPS architecture, otherwise the default one will always
|
|
# be used and the compilation for most variants will fail.
|
|
ifeq ($(BR2_mips),y)
|
|
PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32btsmip"
|
|
else ifeq ($(BR2_mipsel),y)
|
|
PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32ltsmip"
|
|
else ifeq ($(BR2_mips64),y)
|
|
ifeq ($(BR2_MIPS_NABI32),y)
|
|
PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32btsmipn32"
|
|
else
|
|
PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf64btsmip"
|
|
endif
|
|
else ifeq ($(BR2_mips64el),y)
|
|
ifeq ($(BR2_MIPS_NABI32),y)
|
|
PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32ltsmipn32"
|
|
else
|
|
PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf64ltsmip"
|
|
endif
|
|
endif
|
|
|
|
# The call to backtrace() function fails for ARC, because for some
|
|
# reason the unwinder from libgcc returns early. Thus the usage of
|
|
# backtrace() should be disabled in perf explicitly: at build time
|
|
# backtrace() appears to be available, but it fails at runtime: the
|
|
# backtrace will contain only several functions from the top of stack,
|
|
# instead of the complete backtrace.
|
|
ifeq ($(BR2_arc),y)
|
|
PERF_MAKE_FLAGS += NO_BACKTRACE=1
|
|
endif
|
|
|
|
ifeq ($(BR2_PACKAGE_LINUX_TOOLS_PERF_TUI),y)
|
|
PERF_DEPENDENCIES += slang
|
|
else
|
|
PERF_MAKE_FLAGS += NO_NEWT=1 NO_SLANG=1
|
|
endif
|
|
|
|
ifeq ($(BR2_PACKAGE_AUDIT),y)
|
|
PERF_DEPENDENCIES += audit
|
|
else
|
|
PERF_MAKE_FLAGS += NO_LIBAUDIT=1
|
|
endif
|
|
|
|
ifeq ($(BR2_PACKAGE_ZSTD),y)
|
|
PERF_DEPENDENCIES += zstd
|
|
endif
|
|
|
|
ifeq ($(BR2_PACKAGE_LIBUNWIND),y)
|
|
PERF_DEPENDENCIES += libunwind
|
|
else
|
|
PERF_MAKE_FLAGS += NO_LIBUNWIND=1
|
|
endif
|
|
|
|
ifeq ($(BR2_PACKAGE_NUMACTL),y)
|
|
PERF_DEPENDENCIES += numactl
|
|
else
|
|
PERF_MAKE_FLAGS += NO_LIBNUMA=1
|
|
endif
|
|
|
|
ifeq ($(BR2_PACKAGE_ELFUTILS),y)
|
|
PERF_DEPENDENCIES += elfutils
|
|
else
|
|
PERF_MAKE_FLAGS += NO_LIBELF=1 NO_DWARF=1
|
|
endif
|
|
|
|
ifeq ($(BR2_PACKAGE_BINUTILS),y)
|
|
PERF_DEPENDENCIES += binutils
|
|
else
|
|
PERF_MAKE_FLAGS += NO_DEMANGLE=1
|
|
endif
|
|
|
|
ifeq ($(BR2_PACKAGE_OPENSSL),y)
|
|
PERF_DEPENDENCIES += openssl
|
|
else
|
|
PERF_MAKE_FLAGS += NO_LIBCRYPTO=1
|
|
endif
|
|
|
|
ifeq ($(BR2_PACKAGE_ZLIB),y)
|
|
PERF_DEPENDENCIES += zlib
|
|
else
|
|
PERF_MAKE_FLAGS += NO_ZLIB=1
|
|
endif
|
|
|
|
# lzma is provided by xz
|
|
ifeq ($(BR2_PACKAGE_XZ),y)
|
|
PERF_DEPENDENCIES += xz
|
|
else
|
|
PERF_MAKE_FLAGS += NO_LZMA=1
|
|
endif
|
|
|
|
# We really do not want to build the perf documentation, because it
|
|
# has stringent requirement on the documentation generation tools,
|
|
# like xmlto and asciidoc), which may be lagging behind on some
|
|
# distributions.
|
|
# We name it 'GNUmakefile' so that GNU make will use it instead of
|
|
# the existing 'Makefile'.
|
|
define PERF_DISABLE_DOCUMENTATION
|
|
if [ -f $(LINUX_DIR)/tools/perf/Documentation/Makefile ]; then \
|
|
printf "%%:\n\t@:\n" >$(LINUX_DIR)/tools/perf/Documentation/GNUmakefile; \
|
|
fi
|
|
endef
|
|
LINUX_POST_PATCH_HOOKS += PERF_DISABLE_DOCUMENTATION
|
|
|
|
# O must be redefined here to overwrite the one used by Buildroot for
|
|
# out of tree build. We build perf in $(LINUX_DIR)/tools/perf/ and not just
|
|
# $(LINUX_DIR) so that it isn't built in the root directory of the kernel
|
|
# sources.
|
|
define PERF_BUILD_CMDS
|
|
$(Q)if test ! -f $(LINUX_DIR)/tools/perf/Makefile ; then \
|
|
echo "Your kernel version is too old and does not have the perf tool." ; \
|
|
echo "At least kernel 2.6.31 must be used." ; \
|
|
exit 1 ; \
|
|
fi
|
|
$(Q)if test "$(BR2_PACKAGE_ELFUTILS)" = "" ; then \
|
|
if ! grep -q NO_LIBELF $(LINUX_DIR)/tools/perf/Makefile* ; then \
|
|
if ! test -r $(LINUX_DIR)/tools/perf/config/Makefile ; then \
|
|
echo "The perf tool in your kernel cannot be built without libelf." ; \
|
|
echo "Either upgrade your kernel to >= 3.7, or enable the elfutils package." ; \
|
|
exit 1 ; \
|
|
fi \
|
|
fi \
|
|
fi
|
|
$(Q)if test "$(BR2_PACKAGE_LINUX_TOOLS_PERF_TUI)" = "y" ; then \
|
|
if ! grep -q NO_SLANG $(LINUX_DIR)/tools/perf/Makefile* ; then \
|
|
echo "The perf tool in your kernel cannot be build with the TUI." ; \
|
|
echo "Either upgrade your kernel to >= 3.10, or disable the TUI." ; \
|
|
exit 1 ; \
|
|
fi \
|
|
fi
|
|
$(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \
|
|
-C $(LINUX_DIR)/tools/perf O=$(LINUX_DIR)/tools/perf/
|
|
endef
|
|
|
|
# After installation, we remove the Perl and Python scripts from the
|
|
# target.
|
|
define PERF_INSTALL_TARGET_CMDS
|
|
$(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \
|
|
-C $(LINUX_DIR)/tools/perf O=$(LINUX_DIR)/tools/perf/ install
|
|
$(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/scripts/
|
|
$(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/tests/
|
|
endef
|
|
|
|
define PERF_LINUX_CONFIG_FIXUPS
|
|
$(call KCONFIG_ENABLE_OPT,CONFIG_PERF_EVENTS)
|
|
endef
|