]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
grub: add patch to use medany for riscv64
authorTrevor Gamblin <tgamblin@baylibre.com>
Mon, 16 Mar 2026 20:58:03 +0000 (16:58 -0400)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 18 Mar 2026 09:41:18 +0000 (09:41 +0000)
>From the upstream bug report, filed in 2024:

|GRUB 2.12 does not compile correctly using large model on riscv64 using gcc 14.1.1 (gcc-14.1.1-5.fc40.x86_64).
|
|It is my understanding that the large model should not really be used on riscv64 yet and trying to build GRUB 2.12 with it results in an error:
|
|+ ././grub-mkimage -O riscv64-efi -o grubriscv64.efi.orig -d grub-core --sbat ././sbat.csv -m memdisk.squashfs -p /EFI/fedora all_video boot blscfg btrfs cat configfile cryptodisk echo ext2 f2fs fat font gcry_rijndael gcry_rsa gcry_serpent gcry_sha256 gcry_twofish gcry_whirlpool gfxmenu gfxterm gzio halt hfsplus http increment iso9660 jpeg loadenv loopback linux lvm luks luks2 memdisk mdraid09 mdraid1x minicmd net normal part_apple part_msdos part_gpt password_pbkdf2 pgp png reboot regexp search search_fs_uuid search_fs_file search_label serial sleep squash4 syslinuxcfg test tftp version video xfs zstd efi_netfs efifwsetup efinet lsefi lsefimmap connectefi
|././grub-mkimage: error: relocation 0x2b is not implemented yet.
|
|medany builds successfully and boots on the VisionFive2 and on VMs.

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-bsp/grub/files/0263-Use-medany-instead-of-large-model-for-RISCV.patch [new file with mode: 0644]
meta/recipes-bsp/grub/grub2.inc

diff --git a/meta/recipes-bsp/grub/files/0263-Use-medany-instead-of-large-model-for-RISCV.patch b/meta/recipes-bsp/grub/files/0263-Use-medany-instead-of-large-model-for-RISCV.patch
new file mode 100644 (file)
index 0000000..e10a116
--- /dev/null
@@ -0,0 +1,39 @@
+From fcf4b96cfd3a04e1cfa177b08afba4fd80c9978e Mon Sep 17 00:00:00 2001
+From: Jason Montleon <jason@montleon.com>
+Date: Fri, 3 May 2024 13:18:37 -0400
+Subject: [PATCH] Use medany instead of large model for RISCV
+
+Upstream-Status: Submitted [https://savannah.gnu.org/bugs/?65909]
+
+Signed-off-by: Jason Montleon <jason@montleon.com>
+Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
+---
+ configure.ac | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 0d693f8..0289fe1 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1653,7 +1653,7 @@ fi]
+ CFLAGS="$TARGET_CFLAGS"
+-if test "$target_cpu" = x86_64 || test "$target_cpu" = sparc64 || test "$target_cpu" = riscv64 ; then
++if test "$target_cpu" = x86_64 || test "$target_cpu" = sparc64 ; then
+   # Use large model to support 4G memory
+   AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
+     CFLAGS="$TARGET_CFLAGS -mcmodel=large"
+@@ -1663,9 +1663,11 @@ if test "$target_cpu" = x86_64 || test "$target_cpu" = sparc64 || test "$target_
+   ])
+   if test "x$grub_cv_cc_mcmodel" = xyes; then
+     TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
+-  elif test "$target_cpu" = sparc64 || test "$target_cpu" = riscv64; then
++  elif test "$target_cpu" = sparc64; then
+     TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=medany"
+   fi
++elif test "$target_cpu" = riscv64 ; then
++    TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=medany"
+ fi
+ # Stack smashing protector.
index 8c62315e691c2f9de4a9d6b14107e69fa992b44c..7cdeff5edd04764d736007f11f80cf07ef7eb622 100644 (file)
@@ -19,6 +19,7 @@ SRC_URI = "${GNU_MIRROR}/grub/grub-${PV}.tar.gz \
            file://0003-grub.d-10_linux.in-add-oe-s-kernel-name.patch \
            file://0001-Revert-configure-Check-linker-for-image-base-support.patch \
            file://0002-Revert-configure-Print-a-more-helpful-error-if-autoc.patch \
+           file://0263-Use-medany-instead-of-large-model-for-RISCV.patch \
 "
 
 SRC_URI[sha256sum] = "d0415fbb3e739237064e173743a6e5f60c33a81ec02a069cc9152d80efff4967"