[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Ensure that MIPS target code is compiled for the O32 ABI.

From: Mark H Weaver
Subject: Re: [PATCH] Ensure that MIPS target code is compiled for the O32 ABI.
Date: Sat, 12 Sep 2015 23:46:02 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Hi Andrei,

Here's a patch on top of yours that omits the link step from the new
autoconf test.  This eliminates the warnings I encountered before:

diff --git a/ b/
index f3c9b90..cd9fa8d 100644
--- a/
+++ b/
@@ -605,14 +605,10 @@ if test "x$target_cpu" = xmips || test "x$target_cpu" = 
xmipsel ; then
       CFLAGS="$TARGET_CFLAGS $arg -Werror"
 #if !defined(_ABIO32) || !defined(_MIPS_SIM) || (_MIPS_SIM != _ABIO32)
 #error not o32 ABI
-asm (".globl start; start:");
-void __main (void);
-void __main (void) {}
-int main (void);
 ]], [[]])],
                        [grub_cv_target_cc_mips_o32_abi="$arg"], [])
Here's an updated version of your commit, incorporating the above patch:

>From 8adcca69d3d9aacd20010a450aa20083a834392b Mon Sep 17 00:00:00 2001
From: Andrei Borzenkov <address@hidden>
Date: Fri, 11 Sep 2015 11:28:49 -0400
Subject: [PATCH] configure: try to force o32 ABI on MIPS

GRUB expects o32 ABI, in particular used assembly is valid only in this mode.
Some systems (e.g. GNU Guix) default to using newer n64 or n32 ABI. Try to
find suitable options to force o32.

For GCC this is simply -mabi=32. While clang supports this option as well,
o32 ABI is valid for MIPS target and n32/64 ABI are valid for MIPS64 target
only, so use "-target mips/mipsel -mabi=32".

Reported-By: Mark H Weaver <address@hidden>
Also-By: Mark H Weaver <address@hidden>
--- | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/ b/
index c864311..cd9fa8d 100644
--- a/
+++ b/
@@ -597,6 +597,31 @@ int main (void);
   TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian"
+if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
+  AC_CACHE_CHECK([for options to force MIPS o32 ABI], 
grub_cv_target_cc_mips_o32_abi, [
+    grub_cv_target_cc_mips_o32_abi=no
+    for arg in "" "-mabi=32" "-target $target_cpu -mabi=32" ; do
+      if test x"$grub_cv_target_cc_mips_o32_abi" != xno ; then
+        break
+      fi
+      CFLAGS="$TARGET_CFLAGS $arg -Werror"
+#if !defined(_ABIO32) || !defined(_MIPS_SIM) || (_MIPS_SIM != _ABIO32)
+#error not o32 ABI
+]], [[]])],
+                       [grub_cv_target_cc_mips_o32_abi="$arg"], [])
+    done
+  ])
+  if test x"$grub_cv_target_cc_mips_o32_abi" = xno ; then
+    AC_MSG_ERROR([could not force MIPS o32 ABI])
+  fi
+  TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mips_o32_abi"
+  TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_mips_o32_abi"
 AC_CACHE_CHECK([for options to compile assembly], 
[grub_cv_cc_target_asm_compile], [
 case "x$target_cpu-$platform" in

I tested this on MIPS with GCC 5.2.0 and clang 3.6.0.  It works the same
as before, but the warnings are gone.

What do you think?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]