From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZdWUc-0007H1-Az for mharc-grub-devel@gnu.org; Sun, 20 Sep 2015 00:44:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39367) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZdWUZ-0007Gr-Ie for grub-devel@gnu.org; Sun, 20 Sep 2015 00:44:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZdWUW-0001I4-Au for grub-devel@gnu.org; Sun, 20 Sep 2015 00:44:47 -0400 Received: from mail-la0-x233.google.com ([2a00:1450:4010:c03::233]:34336) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZdWUV-0001Hy-TU for grub-devel@gnu.org; Sun, 20 Sep 2015 00:44:44 -0400 Received: by lahg1 with SMTP id g1so51165542lah.1 for ; Sat, 19 Sep 2015 21:44:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type; bh=NwOT6D8NNS8Q2AevkybZwgyNmI3Ixz4RApCB1NU3BXo=; b=X8Z7kkGzrcjcOJNAKD/unYV30Hciw4LRBj7n60QZp9IGi+n7Gb1Ju627xLR2ecULYZ ujjQNNZadPXHydUMr3PMtUiZeBcWVqDip4ZB9b3hbdJHN5yURQ1D9AmJveJK7e21UOWm at9LXcVg6O9M2t/YvqF2Z64eohgimQhlvngASQu+PburHmqqUJgjRM4sKFlmIbZZVOCZ CBZkGDHtjzwZSJ/ezC3PCN4OGXGqG67HmAGCdmpr/TuDZO32839QF7YZjMySl8vxL8iX 2ftGA/0xDlPA13z7FmCk8l5q6FT5A1Wwt9WVXAKe4ctdK8oFXG31xccC8dOB42zg5BAq AUBQ== X-Received: by 10.152.5.225 with SMTP id v1mr5714533lav.0.1442724282805; Sat, 19 Sep 2015 21:44:42 -0700 (PDT) Received: from [192.168.1.41] (ppp91-76-142-206.pppoe.mtu-net.ru. [91.76.142.206]) by smtp.gmail.com with ESMTPSA id i3sm2536009laa.28.2015.09.19.21.44.41 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Sep 2015 21:44:41 -0700 (PDT) Subject: Re: [PATCH] Ensure that MIPS target code is compiled for the O32 ABI. To: Mark H Weaver References: <1440009323-8667-1-git-send-email-mhw@netris.org> <55D6A36D.205@gmail.com> <876147ryhy.fsf@netris.org> <55DAC58C.1030105@gmail.com> <87si79nmp3.fsf@netris.org> <55DAD1F9.7080302@gmail.com> <55DAE394.6030306@gmail.com> <87mvxfp6y8.fsf@netris.org> <55F2EDF4.4040207@gmail.com> <87a8srjb1h.fsf@netris.org> <55F583DD.2020805@gmail.com> <87pp1lx559.fsf@netris.org> From: Andrei Borzenkov Message-ID: <55FE39BA.5030001@gmail.com> Date: Sun, 20 Sep 2015 07:44:42 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <87pp1lx559.fsf@netris.org> Content-Type: multipart/mixed; boundary="------------060108060306070508020205" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::233 Cc: The development of GNU GRUB X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Sep 2015 04:44:48 -0000 This is a multi-part message in MIME format. --------------060108060306070508020205 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sorry for delay. 14.09.2015 02:37, Mark H Weaver пишет: > > The little-endian-option test fails with GCC 5.2.0. The relevant errors > from config.log are: > > gcc: error: unrecognized command line option '-target' > gcc: error: unrecognized command line option '-mlittle-endian' > Oh, well ... let's try once more. --------------060108060306070508020205 Content-Type: text/x-patch; name="0001-configure-try-to-find-options-to-force-endian-on-MIP.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-configure-try-to-find-options-to-force-endian-on-MIP.pa"; filename*1="tch" >From 4a3d2cfc3a1f8d0325b3964b836b5fe584784bb8 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 20 Sep 2015 07:42:12 +0300 Subject: [PATCH 1/2] configure: try to find options to force endian on MIPS --- configure.ac | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index c864311..baf8525 100644 --- a/configure.ac +++ b/configure.ac @@ -562,12 +562,12 @@ AC_COMPILE_IFELSE( ]])], [grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])]) -if test x$target_cpu = xpowerpc; then +if test x$target_cpu = xpowerpc -o x$target_cpu = xmips; then AC_CACHE_CHECK([for options to get big-endian compilation], grub_cv_target_cc_big_endian, [ grub_cv_target_cc_big_endian=no - for cand in "-target powerpc -Wl,-EB" "-target powerpc" \ - "-target powerpc-linux-gnu -Wl,-EB" "-target powerpc-linux-gnu" \ - "-mbig-endian"; do + for cand in "-target $target_cpu -Wl,-EB" "-target $target_cpu" \ + "-target $target_cpu-linux-gnu -Wl,-EB" "-target $target_cpu-linux-gnu" \ + "-EB" "-mbig-endian"; do if test x"$grub_cv_target_cc_big_endian" != xno ; then break fi @@ -577,6 +577,8 @@ if test x$target_cpu = xpowerpc; then #error still little endian #endif asm (".globl start; start:"); +asm (".globl _start; _start:"); +asm (".globl __start; __start:"); void __main (void); void __main (void) {} int main (void); @@ -595,6 +597,41 @@ int main (void); TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags" TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags" TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian" +elif test x$target_cpu = xmipsel; then + AC_CACHE_CHECK([for options to get little-endian compilation], grub_cv_target_cc_little_endian, [ + grub_cv_target_cc_little_endian=no + for cand in "-target $target_cpu -Wl,-EL" "-target $target_cpu" \ + "-target $target_cpu-linux-gnu -Wl,-EL" "-target $target_cpu-linux-gnu" \ + "-EL"; do + if test x"$grub_cv_target_cc_little_endian" != xno ; then + break + fi + CFLAGS="$TARGET_CFLAGS $cand -Werror" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ == __BYTE_ORDER__) +#error still big endian +#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_little_endian="$cand"], []) + done + ]) + + if test x"$grub_cv_target_cc_little_endian" = xno ; then + AC_MSG_ERROR([could not force little-endian]) + fi + + skip_linkflags="$(echo "$grub_cv_target_cc_little_endian"|sed 's@-Wl,-EL@@')" + + TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags" + TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags" + TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags" + TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_little_endian" fi AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [ -- 1.9.1 --------------060108060306070508020205 Content-Type: text/x-patch; name="0002-configure-try-to-force-o32-ABI-on-MIPS.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0002-configure-try-to-force-o32-ABI-on-MIPS.patch" >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 --------------060108060306070508020205--