From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZTsc9-0007J5-EZ for mharc-grub-devel@gnu.org; Mon, 24 Aug 2015 10:20:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59608) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTo2m-0001u4-M0 for grub-devel@gnu.org; Mon, 24 Aug 2015 05:27:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZTo2h-0007WB-OS for grub-devel@gnu.org; Mon, 24 Aug 2015 05:27:56 -0400 Received: from mail-la0-x235.google.com ([2a00:1450:4010:c03::235]:36111) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTo2h-0007Va-GL for grub-devel@gnu.org; Mon, 24 Aug 2015 05:27:51 -0400 Received: by labia3 with SMTP id ia3so9025999lab.3 for ; Mon, 24 Aug 2015 02:27:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type; bh=Tci1nPF9zDhp5N6cPY9lbbyxGBeHuWTuDe3Vv3wleeY=; b=MyQbDSewEv9qU/FF5W58dyuuWwxMOqzm6RIZ57bw2iDePUy/OxG0q+tdzf0iamTQ1u rNiIgg5XsYmJ4rZJ+go7i0eN4zSY7bnt3wLUUw3Eejw9trYMQgBNe08DjaM/biH3oWHx n324RdetAiB4s1xZ6IhSlzM62mhnmz7KB98a8jfJubiPDCles6kclx4lwe90HuVImdmu R3rX0uM/zylsoFU80aydpra3gfcRMO+IQCiDbVNP4L+kDO55TuUOchAuUW4a22SbaOn9 hXjkuKypEXjSLv5jNMLDV7Wx8Y6fg0N+/+hoBIVd7r5ETYPX3eaA0qUhndoLn9dJNA5y Izsw== X-Received: by 10.112.199.133 with SMTP id jk5mr19812516lbc.32.1440408470586; Mon, 24 Aug 2015 02:27:50 -0700 (PDT) Received: from [192.168.1.43] (ppp91-76-5-127.pppoe.mtu-net.ru. [91.76.5.127]) by smtp.gmail.com with ESMTPSA id x10sm721793lal.0.2015.08.24.02.27.48 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Aug 2015 02:27:49 -0700 (PDT) Message-ID: <55DAE394.6030306@gmail.com> Date: Mon, 24 Aug 2015 12:27:48 +0300 From: Andrei Borzenkov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: Mark H Weaver Subject: Re: [PATCH] Ensure that MIPS target code is compiled for the O32 ABI. 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> In-Reply-To: <55DAD1F9.7080302@gmail.com> Content-Type: multipart/mixed; boundary="------------050201030805050101010909" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::235 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: Mon, 24 Aug 2015 09:27:57 -0000 This is a multi-part message in MIME format. --------------050201030805050101010909 Content-Type: text/plain; charset=windows-1251; format=flowed Content-Transfer-Encoding: 8bit 24.08.2015 11:12, Andrei Borzenkov пишет: > 24.08.2015 10:57, Mark H Weaver пишет: >> Andrei Borzenkov writes: >>> Could you paste "clang -v" output for both cases? I believe I >>> understand what's going on. >> >> Okay, I've included it below. It might be relevant to mention that the >> MIPS port of GNU Guix is not a 'multilib' system: it includes support >> only for the N32 ABI. However, our gcc is still capable of generating >> freestanding code for the O32 ABI, as demonstrated by the fact that I've >> been successfully building and using GRUB on it. >> >> Thanks, >> Mark >> >> --8<---------------cut here---------------start------------->8--- >> mhw@librenote:~$ clang -v -mabi=32 mips.S >> clang version 3.6.0 (tags/RELEASE_360/final) >> Target: mips64el-unknown-linux-gnu > > Yes, as expected. clang treats mips and mips64 as two different targets > so o32 is invalid for mips64. > > Could you test attached patch for both gcc and clang? Use > > configure TARGET_CC=clang Sorry, was broken, fixed version attached. --------------050201030805050101010909 Content-Type: text/x-patch; name="mips-o32.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="mips-o32.patch" From: Andrei Borzenkov 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 -mabi=32". Reported-By: Mark H Weaver Also-By: Mark H Weaver --- configure.ac | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/configure.ac b/configure.ac index c864311..2e73b3f 100644 --- a/configure.ac +++ b/configure.ac @@ -597,6 +597,35 @@ int main (void); TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_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 mips -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:"); +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 -- tg: (ba218c1..) u/mips-o32 (depends on: master) --------------050201030805050101010909--