kumquat-buildroot/package/kexec/kexec.mk
Julien Olivain fd6410c6f9 package/kexec: fix link error when BR2_OPTIMIZE_0=y
When BR2_OPTIMIZE_0, -O0 is passed in compiler CFLAGS. This means no
code optimization will be performed.

kexec code uses a trick to detect unaligned accesses at link time
which needs at least dead-code-removal to work. See
put/get_unaligned() macros in kexec/kexec.h. This code was re-enabled
in upstream commit [1].

This commit sets at least -O1 (which include the sufficient
dead-code-removal) when BR2_OPTIMIZE_0=y, to fix those issues.

Fixes:
- http://autobuild.buildroot.org/results/8f8/8f8532f1dfbd71e52c51c00118934af9fa45e7cb
- http://autobuild.buildroot.org/results/528/528fd7baf9b0ad5549d22ec8e0623c5fa1f2d117
- http://autobuild.buildroot.org/results/499/499115439680adfb4b40042468e5bbb65d91ce6c
- ...and many others

[1] https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/commit/?id=0723defb5308ac7fce296f8b596bff4df6803f01

Signed-off-by: Julien Olivain <ju.o@free.fr>
Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
(cherry picked from commit a411588b582ad6a0c8573ec9f59f737473d69bee)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2024-08-07 00:43:52 +02:00

48 lines
1.3 KiB
Makefile

################################################################################
#
# kexec
#
################################################################################
KEXEC_VERSION = 2.0.28
KEXEC_SOURCE = kexec-tools-$(KEXEC_VERSION).tar.xz
KEXEC_SITE = $(BR2_KERNEL_MIRROR)/linux/utils/kernel/kexec
KEXEC_LICENSE = GPL-2.0
KEXEC_LICENSE_FILES = COPYING
KEXEC_CPE_ID_PRODUCT = kexec-tools
KEXEC_CPE_ID_VENDOR = kexec-tools_project
KEXEC_SELINUX_MODULES = kdump
# Makefile expects $STRIP -o to work, so needed for !BR2_STRIP_strip
KEXEC_MAKE_OPTS = STRIP="$(TARGET_CROSS)strip"
# kexec requires at least -O1 optimization level. Its code uses a
# trick to detect unaligned accesses at link time which needs at least
# dead-code-removal to work. See put/get_unaligned() macros in
# kexec/kexec.h
ifeq ($(BR2_OPTIMIZE_0),y)
KEXEC_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -O1"
endif
ifeq ($(BR2_PACKAGE_KEXEC_ZLIB),y)
KEXEC_CONF_OPTS += --with-zlib
KEXEC_DEPENDENCIES += zlib
else
KEXEC_CONF_OPTS += --without-zlib
endif
ifeq ($(BR2_PACKAGE_XZ),y)
KEXEC_CONF_OPTS += --with-lzma
KEXEC_DEPENDENCIES += xz
else
KEXEC_CONF_OPTS += --without-lzma
endif
define KEXEC_REMOVE_LIB_TOOLS
rm -rf $(TARGET_DIR)/usr/lib/kexec-tools
endef
KEXEC_POST_INSTALL_TARGET_HOOKS += KEXEC_REMOVE_LIB_TOOLS
$(eval $(autotools-package))