From e427f85e29f7027319a5cd1ce1024d80ef4a29ea Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Sat, 8 Aug 2026 15:00:03 +0200 Subject: [PATCH] boot/grub2: fix build issue since 2.14 version bump Since the bump of grub2 to version 2.14, the build fails on some configurations with: /home/autobuild/autobuild/instance-8/output-1/host/bin/grub-mkimage: error: `/home/autobuild/autobuild/instance-8/output-1/build/grub2-2.14/build-i386-pc/grub-core//kernel.img' is miscompiled: its start address is 0x9074 instead of 0x9000: ld.gold bug?. We are not the only ones affected: OpenEmbedded has the issue as well, addressed in commit https://github.com/openembedded/openembedded-core/commit/66aefeca482e2985fef5b936ff611ba8b7f81b85, and this commit points that libreboot and Gentoo have also adopted the same temporary fix: revert two upstream commits. So to fix the issue in Buildroot, we take the same approach. It is temporary, and there is an upstream patch series under discussion to really fix the problem. But as this series has 9 patches still under discussion, we take the simpler approach of reverting two simpler patches for the time being. host-pkgconf is needed as an additional dependency because configure.ac using m4 macros provided by host-pkgconf. Fixes: https://autobuild.buildroot.net/results/89b/89b907278cada3d7ca1fee2d08d66921ffb4d7cc/build-end.log Signed-off-by: Thomas Petazzoni Signed-off-by: Julien Olivain --- ...-Check-linker-for-image-base-support.patch | 75 +++++++++++++++++++ ...-Print-a-more-helpful-error-if-autoc.patch | 36 +++++++++ boot/grub2/grub2.mk | 7 ++ 3 files changed, 118 insertions(+) create mode 100644 boot/grub2/0001-Revert-configure-Check-linker-for-image-base-support.patch create mode 100644 boot/grub2/0002-Revert-configure-Print-a-more-helpful-error-if-autoc.patch diff --git a/boot/grub2/0001-Revert-configure-Check-linker-for-image-base-support.patch b/boot/grub2/0001-Revert-configure-Check-linker-for-image-base-support.patch new file mode 100644 index 0000000000..edfaea2de8 --- /dev/null +++ b/boot/grub2/0001-Revert-configure-Check-linker-for-image-base-support.patch @@ -0,0 +1,75 @@ +From 3a9d2dd2f5fb07b75a74c307d61b9b9fc5d20a62 Mon Sep 17 00:00:00 2001 +From: Yi Zhao +Date: Fri, 27 Feb 2026 11:46:54 +0800 +Subject: [PATCH] Revert "configure: Check linker for --image-base support" + +This reverts commit 1a5417f39a0ccefcdd5440f2a67f84d2d2e26960. + +Signed-off-by: Yi Zhao +Upstream: temporary revert, until upstream fixes the issue, see +discussion at +https://lists.gnu.org/archive/html/grub-devel/2026-02/msg00039.html +Signed-off-by: Thomas Petazzoni +--- + acinclude.m4 | 5 ----- + configure.ac | 14 ++------------ + 2 files changed, 2 insertions(+), 17 deletions(-) + +diff --git a/acinclude.m4 b/acinclude.m4 +index 70c1912f8..fa7840f09 100644 +--- a/acinclude.m4 ++++ b/acinclude.m4 +@@ -79,11 +79,6 @@ AC_DEFUN([grub_PROG_OBJCOPY_ABSOLUTE], + [AC_MSG_CHECKING([whether ${TARGET_OBJCOPY} works for absolute addresses]) + AC_CACHE_VAL(grub_cv_prog_objcopy_absolute, + [cat > conftest.c <<\EOF +-asm ( +- ".globl start, _start, __start\n" +- ".ifdef cmain; .set start = _start = __start = cmain\n.endif\n" +- ".ifdef _cmain; .set start = _start = __start = _cmain\n.endif\n" +-); + void cmain (void); + void + cmain (void) +diff --git a/configure.ac b/configure.ac +index d8ca1b7c1..041cfbab4 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1461,6 +1461,7 @@ elif test x$grub_cv_target_cc_link_format = x-mi386pe || test x$grub_cv_target_c + TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/conf/i386-cygwin-img-ld.sc" + TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}" + TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/conf/i386-cygwin-img-ld.sc" ++ TARGET_IMG_BASE_LDOPT="-Wl,-Ttext" + TARGET_IMG_CFLAGS= + else + TARGET_APPLE_LINKER=0 +@@ -1468,6 +1469,7 @@ else + TARGET_IMG_LDSCRIPT= + TARGET_IMG_LDFLAGS='-Wl,-N' + TARGET_IMG_LDFLAGS_AC='-Wl,-N' ++ TARGET_IMG_BASE_LDOPT="-Wl,-Ttext" + TARGET_IMG_CFLAGS= + fi + +@@ -1798,18 +1800,6 @@ grub_PROG_TARGET_CC + m4_ifndef([AX_CHECK_LINK_FLAG], [m4_fatal([autoconf-archive is missing. You must install it to generate the configure script.])]) + + if test "x$TARGET_APPLE_LINKER" != x1 ; then +-AX_CHECK_LINK_FLAG([-Wl,--image-base,0x400000], +- [TARGET_IMG_BASE_LDOPT="-Wl,--image-base"], +- [TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"], +- [], +- [AC_LANG_SOURCE([ +-asm (".globl start; start:"); +-asm (".globl _start; _start:"); +-asm (".globl __start; __start:"); +-void __main (void); +-void __main (void) {} +-int main (void); +- ])]) + grub_PROG_OBJCOPY_ABSOLUTE + fi + grub_PROG_LD_BUILD_ID_NONE +-- +2.43.0 + diff --git a/boot/grub2/0002-Revert-configure-Print-a-more-helpful-error-if-autoc.patch b/boot/grub2/0002-Revert-configure-Print-a-more-helpful-error-if-autoc.patch new file mode 100644 index 0000000000..8e38bb9d3f --- /dev/null +++ b/boot/grub2/0002-Revert-configure-Print-a-more-helpful-error-if-autoc.patch @@ -0,0 +1,36 @@ +From d0f516385dc73e8dd92b78ce08c1df100434fe67 Mon Sep 17 00:00:00 2001 +From: Yi Zhao +Date: Fri, 27 Feb 2026 13:58:44 +0800 +Subject: [PATCH] Revert "configure: Print a more helpful error if + autoconf-archive is not installed" + +This reverts commit ac042f3f58d33ce9cd5ff61750f06da1a1d7b0eb. + +Signed-off-by: Yi Zhao +Upstream: temporary revert, until upstream fixes the issue, see +discussion at +https://lists.gnu.org/archive/html/grub-devel/2026-02/msg00039.html +Signed-off-by: Thomas Petazzoni +--- + configure.ac | 5 ----- + 1 file changed, 5 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 041cfbab4..209c0fb11 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1794,11 +1794,6 @@ LIBS="" + # Defined in acinclude.m4. + grub_ASM_USCORE + grub_PROG_TARGET_CC +- +-# The error message produced by autoconf if autoconf-archive is not installed is +-# quite misleading and not very helpful. So, try point people in the right direction. +-m4_ifndef([AX_CHECK_LINK_FLAG], [m4_fatal([autoconf-archive is missing. You must install it to generate the configure script.])]) +- + if test "x$TARGET_APPLE_LINKER" != x1 ; then + grub_PROG_OBJCOPY_ABSOLUTE + fi +-- +2.43.0 + diff --git a/boot/grub2/grub2.mk b/boot/grub2/grub2.mk index b3614a7da6..85b3925c1e 100644 --- a/boot/grub2/grub2.mk +++ b/boot/grub2/grub2.mk @@ -15,6 +15,13 @@ HOST_GRUB2_DEPENDENCIES = host-bison host-flex host-gawk \ $(BR2_PYTHON3_HOST_DEPENDENCY) GRUB2_INSTALL_IMAGES = YES +# 0001-Revert-configure-Check-linker-for-image-base-support.patch +# 0002-Revert-configure-Print-a-more-helpful-error-if-autoc.patch +GRUB2_AUTORECONF = YES +GRUB2_DEPENDENCIES += host-pkgconf +HOST_GRUB2_AUTORECONF = YES +HOST_GRUB2_DEPENDENCIES += host-pkgconf + ifeq ($(BR2_TARGET_GRUB2_INSTALL_TOOLS),y) GRUB2_INSTALL_TARGET = YES else