From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZTsbG-0005nF-IZ for mharc-grub-devel@gnu.org; Mon, 24 Aug 2015 10:19:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34679) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTms3-0000NB-TQ for grub-devel@gnu.org; Mon, 24 Aug 2015 04:12:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZTmrz-0006lL-SZ for grub-devel@gnu.org; Mon, 24 Aug 2015 04:12:47 -0400 Received: from mail-la0-x22d.google.com ([2a00:1450:4010:c03::22d]:36330) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTmrz-0006lD-JS for grub-devel@gnu.org; Mon, 24 Aug 2015 04:12:43 -0400 Received: by labia3 with SMTP id ia3so7900073lab.3 for ; Mon, 24 Aug 2015 01:12:42 -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=bxIotajxQIuuMzGtXLb0uQduHSa2eB+2mvGPhHgKIeI=; b=hmXGx4tGykmGY7UwAONVQGBnmrVonHs+08eOzWkCta6ccDtkOHdFEYKhiGUUMfKGUp agnmGPSiurzKNH2tDZAPL9arzLhP/rotfkdRBrCeq8uYLjFtoieKdnsesIH202BLnEpz YREYlbHtejvGKYHzPNZd/l5hzKsatajTOp/9P2N90fj0gpOlLAda0nBBIq3IoFptUt7R nBqmOt8pNpWNbPU/nQPMp4RNO3VjpJd7VcunVagcC5QV4ijsYzIgXIpl4dsU09zSGHfY 5k0LAutIm3KcbXtudhTjw9Vli2taCtKROCTd/fY3igqKLfWOZ6wJppD/NrdpIqF5fPAW Peug== X-Received: by 10.152.42.205 with SMTP id q13mr8896195lal.18.1440403962757; Mon, 24 Aug 2015 01:12:42 -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 n4sm4850425laj.44.2015.08.24.01.12.41 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Aug 2015 01:12:42 -0700 (PDT) Message-ID: <55DAD1F9.7080302@gmail.com> Date: Mon, 24 Aug 2015 11:12:41 +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> In-Reply-To: <87si79nmp3.fsf@netris.org> Content-Type: multipart/mixed; boundary="------------000001030108070204000102" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::22d 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 08:12:48 -0000 This is a multi-part message in MIME format. --------------000001030108070204000102 Content-Type: text/plain; charset=windows-1251; format=flowed Content-Transfer-Encoding: 8bit 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 --------------000001030108070204000102 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..d857e47 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" + 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) --------------000001030108070204000102--