From: Vladimir Serbinenko <phcoder@gmail.com>
To: grub-devel@gnu.org
Cc: Vladimir Serbinenko <phcoder@gmail.com>
Subject: [PATCH] configure: Add -mno-relax on riscv*
Date: Thu, 27 Mar 2025 19:32:23 +0300 [thread overview]
Message-ID: <20250327163232.299424-1-phcoder@gmail.com> (raw)
Without this option compiler sometimes emits R_RISCV_ALIGN relocs.
Unlike other relocs this one requires the linker to do NOP deletions
and we can't ignore them. Just instruct compiler not to emit them
Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
---
configure.ac | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/configure.ac b/configure.ac
index 34f4f9415..2818a73a6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -913,6 +913,31 @@ if test "x$target_cpu" = xloongarch64; then
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -Wa,-mla-global-with-abs"
fi
+if test "x$target_cpu" = xriscv64 || test "x$target_cpu" = xriscv32; then
+ AC_CACHE_CHECK([for no-relax options], grub_cv_target_cc_mno_relax, [
+ grub_cv_target_cc_mno_relax=no
+ for cand in "-mno-relax" "-Wa,-mno-relax"; do
+ if test x"$grub_cv_target_cc_mno_relax" != xno ; then
+ break
+ fi
+ CFLAGS="$TARGET_CFLAGS $cand -Werror"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+ asm (".globl start; start:");
+ void __main (void);
+ void __main (void) {}
+ int main (void);
+ ]], [[]])], [grub_cv_target_cc_mno_relax="$cand"], [])
+ done
+ ])
+
+ CFLAGS="$TARGET_CFLAGS"
+
+ if test x"$grub_cv_target_cc_mno_relax" != xno ; then
+ TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mno_relax"
+ TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_mno_relax"
+ fi
+fi
+
# GRUB doesn't use float or doubles at all. Yet some toolchains may decide
# that floats are a good fit to run instead of what's written in the code.
# Given that floating point unit is disabled (if present to begin with)
--
2.49.0
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
next reply other threads:[~2025-03-27 16:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-27 16:32 Vladimir Serbinenko [this message]
2025-04-10 14:50 ` [PATCH] configure: Add -mno-relax on riscv* Daniel Kiper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250327163232.299424-1-phcoder@gmail.com \
--to=phcoder@gmail.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.