diff --git a/1089-Use-medany-instead-of-large-model-for-RISCV.patch b/1089-Use-medany-instead-of-large-model-for-RISCV.patch new file mode 100644 index 0000000000000000000000000000000000000000..4bfd46856812cf004b663e465da822607ca80ee1 --- /dev/null +++ b/1089-Use-medany-instead-of-large-model-for-RISCV.patch @@ -0,0 +1,36 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jason Montleon +Date: Fri, 3 May 2024 13:18:37 -0400 +Subject: [PATCH] Use medany instead of large model for RISCV + +Signed-off-by: Jason Montleon +--- + configure.ac | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/configure.ac b/configure.ac +index d223fe3ef6e..6a6688e362a 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1313,7 +1313,7 @@ AC_SUBST(TARGET_LDFLAGS_OLDMAGIC) + + LDFLAGS="$TARGET_LDFLAGS" + +-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" +@@ -1323,9 +1323,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 + + if test "$target_cpu"-"$platform" = x86_64-efi; then diff --git a/grub.macros b/grub.macros index 2d93fd004c3fc091f6d40aec89f87a1eb2463033..3989213478188b95d2b60b72fd826aab1af86d8d 100644 --- a/grub.macros +++ b/grub.macros @@ -15,7 +15,11 @@ %endif # gnulib actively ignores CFLAGS because it's terrible +%ifarch riscv64 +%global cc_equals "CC=%{ccpath} -fPIE -Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration -Wno-error=int-conversion" +%else %global cc_equals "CC=%{ccpath} -fPIE" +%endif %global cflags_sed \\\ sed \\\ diff --git a/grub.patches b/grub.patches index 648c4bb782a142534252e65ff8337d3b64d42286..458eb4e5143abc3e4239228404a0ddc89730cbfb 100644 --- a/grub.patches +++ b/grub.patches @@ -287,3 +287,4 @@ Patch1084: 1084-kern-misc-Add-sanity-check-after-grub_strtoul-call.patch Patch1085: 1085-loader-i386-linux-Cast-left-shift-to-grub_uint32_t.patch Patch1086: 1086-loader-i386-bsd-Use-safe-math-to-avoid-underflow.patch Patch1087: 1087-fix-CVE-2024-56738.patch +Patch1089: 1089-Use-medany-instead-of-large-model-for-RISCV.patch diff --git a/grub2.spec b/grub2.spec index 6a3bcfb9ef3b2b2692a83a9a6714c8e4fbe81ac5..c61c9e2a59cf2fdef753afb326c0624f724bfaed 100644 --- a/grub2.spec +++ b/grub2.spec @@ -1,4 +1,4 @@ -%define anolis_release 16 +%define anolis_release 17 %global _lto_cflags %{nil} %undefine _hardened_build @@ -193,6 +193,10 @@ git add grub-emu-%{tarversion} git commit -m "After making subdirs" %build +%ifarch riscv64 +export CFLAGS="%{optflags} -Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration -Wno-error=int-conversion" +%endif + %if 0%{with_efi_arch} %{expand:%do_primary_efi_build %%{grubefiarch} %%{grubefiname} %%{grubeficdname} %%{_target_platform} %%{efi_target_cflags} %%{efi_host_cflags}} %endif @@ -506,6 +510,9 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg %endif %changelog +* Wed Oct 23 2025 xinhaitao -2.12-17 +- Add support for riscv64 + * Wed Sep 10 2025 Jessica Liu -2.12-16 - Use time register in grub_efi_get_time_ms()