Re: [PATCH] Use medany instead of large model for RISCV
"Vladimir 'phcoder' Serbinenko" <[email protected]> Sat, 21 Mar 2026 00:54:54 +0300
| Newsgroups | org.gnu.grub-devel |
|---|---|
| Message-ID | <CAEaD8JOp0bpRxG9ShrdzvKZ-YVfMx7N981mgXrTcwLqdG5aNoQ@mail.gmail.com> |
--===============2624652107805599364== Content-Type: multipart/alternative; boundary="000000000000cfaa20064d7bbc0b" --000000000000cfaa20064d7bbc0b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable We prefer to use large model. Did you try my patch with using ET_DYN? https://lists.libreplanet.org/archive/html/grub-devel/2025-04/msg00093.html Regards Vladimir 'phcoder' Serbinenko Le ven. 20 mars 2026, 21:48, Jason Montleon via Grub-devel < [email protected]> a =C3=A9crit : > > > > > On Friday, March 20th, 2026 at 10:44 AM, Trevor Gamblin < > [email protected]> wrote: > > > From: Jason Montleon <[email protected]> > > > > Upstream-Status: Submitted [https://savannah.gnu.org/bugs/?65909] > > > > Signed-off-by: Jason Montleon <[email protected]> > > Signed-off-by: Trevor Gamblin <[email protected]> > > --- > > We have recently added this to the openembedded-core layer to help with > RISC-V > > builds on certain platforms (e.g. the VisionFive 2). I have left the > patch as it > > is there, including the link to the original bug submission and the > author's > > attribution. Jason, if you would like to change the attribution or > anything > > about the patch, let me know and I can re-submit. > > Hi Trevor, > Fedora is still using this patch and it is working for us. > > https://src.fedoraproject.org/rpms/grub2/blob/rawhide/f/0283-Use-medany-i= nstead-of-large-model-for-RISCV.patch > > I did want to share that we revisited building with large model and > managed to get it to build. This resulted in a smaller binary with far > fewer relocations. > That work is at > http://fedora.riscv.rocks:3000/rpms/grub2/commits/branch/main-riscv64-lar= ge-code > > I am not sure if one approach would be preferred over the other. > > > configure.ac | 6 ++++-- > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/configure.ac b/configure.ac > > index d19fb625d..2a070c577 100644 > > --- a/configure.ac > > +++ b/configure.ac > > @@ -1675,7 +1675,7 @@ fi] > > > > CFLAGS=3D"$TARGET_CFLAGS" > > > > -if test "$target_cpu" =3D x86_64 || test "$target_cpu" =3D sparc64 || = test > "$target_cpu" =3D riscv64 ; then > > +if test "$target_cpu" =3D x86_64 || test "$target_cpu" =3D sparc64 ; t= hen > > # Use large model to support 4G memory > > AC_CACHE_CHECK([whether option -mcmodel=3Dlarge works], > grub_cv_cc_mcmodel, [ > > CFLAGS=3D"$TARGET_CFLAGS -mcmodel=3Dlarge" > > @@ -1685,9 +1685,11 @@ if test "$target_cpu" =3D x86_64 || test > "$target_cpu" =3D sparc64 || test "$target_ > > ]) > > if test "x$grub_cv_cc_mcmodel" =3D xyes; then > > TARGET_CFLAGS=3D"$TARGET_CFLAGS -mcmodel=3Dlarge" > > - elif test "$target_cpu" =3D sparc64 || test "$target_cpu" =3D riscv6= 4; > then > > + elif test "$target_cpu" =3D sparc64; then > > TARGET_CFLAGS=3D"$TARGET_CFLAGS -mcmodel=3Dmedany" > > fi > > +elif test "$target_cpu" =3D riscv64 ; then > > + TARGET_CFLAGS=3D"$TARGET_CFLAGS -mcmodel=3Dmedany" > > fi > > > > # Stack smashing protector. > > -- > > 2.53.0 > > > > > > _______________________________________________ > Grub-devel mailing list > [email protected] > https://lists.gnu.org/mailman/listinfo/grub-devel > --000000000000cfaa20064d7bbc0b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"auto"><div>We prefer to use large model. Did you try my patch w= ith using ET_DYN? <a href=3D"https://lists.libreplanet.org/archive/html/gru= b-devel/2025-04/msg00093.html">https://lists.libreplanet.org/archive/html/g= rub-devel/2025-04/msg00093.html</a></div><div><br></div><div data-smartmail= =3D"gmail_signature">Regards<br>Vladimir 'phcoder' Serbinenko<br></= div></div><br><div class=3D"gmail_quote gmail_quote_container"><div dir=3D"= ltr" class=3D"gmail_attr">Le ven. 20 mars 2026, 21:48, Jason Montleon via G= rub-devel <<a href=3D"mailto:[email protected]">[email protected]</a>&= gt; a =C3=A9crit=C2=A0:<br></div><blockquote class=3D"gmail_quote" style=3D= "margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br> <br> <br> <br> On Friday, March 20th, 2026 at 10:44 AM, Trevor Gamblin <<a href=3D"mail= to:[email protected]" target=3D"_blank" rel=3D"noreferrer">tgamblin@bay= libre.com</a>> wrote:<br> <br> > From: Jason Montleon <<a href=3D"mailto:[email protected]" target= =3D"_blank" rel=3D"noreferrer">[email protected]</a>><br> > <br> > Upstream-Status: Submitted [<a href=3D"https://savannah.gnu.org/bugs/?= 65909" rel=3D"noreferrer noreferrer" target=3D"_blank">https://savannah.gnu= .org/bugs/?65909</a>]<br> > <br> > Signed-off-by: Jason Montleon <<a href=3D"mailto:[email protected]= " target=3D"_blank" rel=3D"noreferrer">[email protected]</a>><br> > Signed-off-by: Trevor Gamblin <<a href=3D"mailto:tgamblin@baylibre.= com" target=3D"_blank" rel=3D"noreferrer">[email protected]</a>><br> > ---<br> > We have recently added this to the openembedded-core layer to help wit= h RISC-V<br> > builds on certain platforms (e.g. the VisionFive 2). I have left the p= atch as it<br> > is there, including the link to the original bug submission and the au= thor's<br> > attribution. Jason, if you would like to change the attribution or any= thing<br> > about the patch, let me know and I can re-submit.<br> <br> Hi Trevor,<br> Fedora is still using this patch and it is working for us.<br> <a href=3D"https://src.fedoraproject.org/rpms/grub2/blob/rawhide/f/0283-Use= -medany-instead-of-large-model-for-RISCV.patch" rel=3D"noreferrer noreferre= r" target=3D"_blank">https://src.fedoraproject.org/rpms/grub2/blob/rawhide/= f/0283-Use-medany-instead-of-large-model-for-RISCV.patch</a><br> <br> I did want to share that we revisited building with large model and managed= to get it to build. This resulted in a smaller binary with far fewer reloc= ations. <br> That work is at <a href=3D"http://fedora.riscv.rocks:3000/rpms/grub2/commit= s/branch/main-riscv64-large-code" rel=3D"noreferrer noreferrer" target=3D"_= blank">http://fedora.riscv.rocks:3000/rpms/grub2/commits/branch/main-riscv6= 4-large-code</a><br> <br> I am not sure if one approach would be preferred over the other.<br> <br> >=C2=A0 <a href=3D"http://configure.ac" rel=3D"noreferrer noreferrer" ta= rget=3D"_blank">configure.ac</a> | 6 ++++--<br> >=C2=A0 1 file changed, 4 insertions(+), 2 deletions(-)<br> > <br> > diff --git a/<a href=3D"http://configure.ac" rel=3D"noreferrer norefer= rer" target=3D"_blank">configure.ac</a> b/<a href=3D"http://configure.ac" r= el=3D"noreferrer noreferrer" target=3D"_blank">configure.ac</a><br> > index d19fb625d..2a070c577 100644<br> > --- a/<a href=3D"http://configure.ac" rel=3D"noreferrer noreferrer" ta= rget=3D"_blank">configure.ac</a><br> > +++ b/<a href=3D"http://configure.ac" rel=3D"noreferrer noreferrer" ta= rget=3D"_blank">configure.ac</a><br> > @@ -1675,7 +1675,7 @@ fi]<br> > <br> >=C2=A0 CFLAGS=3D"$TARGET_CFLAGS"<br> > <br> > -if test "$target_cpu" =3D x86_64 || test "$target_cpu&= quot; =3D sparc64 || test "$target_cpu" =3D riscv64 ; then<br> > +if test "$target_cpu" =3D x86_64 || test "$target_cpu&= quot; =3D sparc64 ; then<br> >=C2=A0 =C2=A0 # Use large model to support 4G memory<br> >=C2=A0 =C2=A0 AC_CACHE_CHECK([whether option -mcmodel=3Dlarge works], g= rub_cv_cc_mcmodel, [<br> >=C2=A0 =C2=A0 =C2=A0 CFLAGS=3D"$TARGET_CFLAGS -mcmodel=3Dlarge&quo= t;<br> > @@ -1685,9 +1685,11 @@ if test "$target_cpu" =3D x86_64 || t= est "$target_cpu" =3D sparc64 || test "$target_<br> >=C2=A0 =C2=A0 ])<br> >=C2=A0 =C2=A0 if test "x$grub_cv_cc_mcmodel" =3D xyes; then<b= r> >=C2=A0 =C2=A0 =C2=A0 TARGET_CFLAGS=3D"$TARGET_CFLAGS -mcmodel=3Dla= rge"<br> > -=C2=A0 elif test "$target_cpu" =3D sparc64 || test "$t= arget_cpu" =3D riscv64; then<br> > +=C2=A0 elif test "$target_cpu" =3D sparc64; then<br> >=C2=A0 =C2=A0 =C2=A0 TARGET_CFLAGS=3D"$TARGET_CFLAGS -mcmodel=3Dme= dany"<br> >=C2=A0 =C2=A0 fi<br> > +elif test "$target_cpu" =3D riscv64 ; then<br> > +=C2=A0 =C2=A0 TARGET_CFLAGS=3D"$TARGET_CFLAGS -mcmodel=3Dmedany&= quot;<br> >=C2=A0 fi<br> > <br> >=C2=A0 # Stack smashing protector.<br> > --<br> > 2.53.0<br> > <br> > <br> <br> _______________________________________________<br> Grub-devel mailing list<br> <a href=3D"mailto:[email protected]" target=3D"_blank" rel=3D"noreferrer">= [email protected]</a><br> <a href=3D"https://lists.gnu.org/mailman/listinfo/grub-devel" rel=3D"norefe= rrer noreferrer" target=3D"_blank">https://lists.gnu.org/mailman/listinfo/g= rub-devel</a><br> </blockquote></div> --000000000000cfaa20064d7bbc0b-- --===============2624652107805599364== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KR3J1Yi1kZXZl bCBtYWlsaW5nIGxpc3QKR3J1Yi1kZXZlbEBnbnUub3JnCmh0dHBzOi8vbGlzdHMuZ251Lm9yZy9t YWlsbWFuL2xpc3RpbmZvL2dydWItZGV2ZWwK --===============2624652107805599364==--