>From b609d424889ffdb3cc9191384296980e02514abb Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 20 Sep 2015 07:42:12 +0300 Subject: [PATCH 2/2] 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 Also-By: Mark H Weaver --- configure.ac | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/configure.ac b/configure.ac index baf8525..d9d4222 100644 --- a/configure.ac +++ b/configure.ac @@ -634,6 +634,37 @@ int main (void); TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_little_endian" fi +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" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#if !defined(_ABIO32) || !defined(_MIPS_SIM) || (_MIPS_SIM != _ABIO32) +#error not o32 ABI +#endif +asm (".globl start; start:"); +asm (".globl _start; _start:"); +asm (".globl __start; __start:"); +void __main (void); +void __main (void) {} +int main (void); +]], [[]])], + [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" +fi + AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [ test_program= case "x$target_cpu-$platform" in -- 1.9.1