From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZUIp2-0000Hy-5b for mharc-grub-devel@gnu.org; Tue, 25 Aug 2015 14:19:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53369) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUIoz-0000Gs-HK for grub-devel@gnu.org; Tue, 25 Aug 2015 14:19:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZUIou-0006Ym-It for grub-devel@gnu.org; Tue, 25 Aug 2015 14:19:45 -0400 Received: from world.peace.net ([50.252.239.5]:57655) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUIou-0006VV-EA for grub-devel@gnu.org; Tue, 25 Aug 2015 14:19:40 -0400 Received: from [10.1.10.32] (helo=yeeloong) by world.peace.net with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1ZUIoa-0000rI-WF; Tue, 25 Aug 2015 14:19:21 -0400 From: Mark H Weaver To: Andrei Borzenkov 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> <55DAE394.6030306@gmail.com> Date: Tue, 25 Aug 2015 14:18:55 -0400 In-Reply-To: <55DAE394.6030306@gmail.com> (Andrei Borzenkov's message of "Mon, 24 Aug 2015 12:27:48 +0300") Message-ID: <87mvxfp6y8.fsf@netris.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 50.252.239.5 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: Tue, 25 Aug 2015 18:19:46 -0000 Andrei Borzenkov writes: > 24.08.2015 11:12, Andrei Borzenkov =D0=BF=D0=B8=D1=88=D0=B5=D1=82: >> Could you test attached patch for both gcc and clang? Use >> >> configure TARGET_CC=3Dclang > > Sorry, was broken, fixed version attached. Your patch works for me with gcc, although config.log shows this warning when building the test program in your new code with the correct flags for gcc (-mabi=3D32): ld: warning: cannot find entry symbol __start; defaulting to 000000000040= 00d0 Here's the relevant excerpt: --8<---------------cut here---------------start------------->8--- configure:24700: gcc -o conftest -Os -Wall -W -Wshadow -Wpointer-arith -Wu= ndef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optim= ization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -= Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmai= n -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wr= eturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -W= unknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-paramete= r -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstri= ct-prototypes -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarati= ons -Wcast-align -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-= pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflo= w -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatil= e-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -= Wmissing-declarations -Wformat=3D2 -mabi=3D32 -Werror -Wall -W -DGRUB_CPU= _MIPSEL=3D1 -DGRUB_MACHINE_MIPS_LOONGSON=3D1 -DGRUB_MACHINE=3DMIPS_LOONGSON= -nostdlib -static conftest.c >&5 ld: warning: cannot find entry symbol __start; defaulting to 00000000004000= d0 configure:24700: $? =3D 0 configure:24708: result: -mabi=3D32 --8<---------------cut here---------------end--------------->8--- I also worry that linking an O32 executable might be fragile on a pure non-multilib N32 system such as GNU Guix, where we lack even the gcc runtime library (libgcc_s) for O32. For now it seems to work, but I wonder if it might be more robust to do the test compilation with -c and -freestanding? clang: with TARGET_CC=3Dclang, it fails for me. Here are the relevant excerpts from config.log: --8<---------------cut here---------------start------------->8--- configure:24700: /gnu/store/yjmchvkz0kmz4s1sxc0p89imfik68qzg-clang-3.6.0/bi= n/clang -o conftest -Os -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-s= ubscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv= -by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -= Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-b= races -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -W= sequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragm= as -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-va= lue -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes= -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -Wcast-al= ign -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast = -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpoi= nter-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-va= r -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-decl= arations -Wformat=3D2 -mabi=3D32 -Werror -Wall -W -DGRUB_CPU_MIPSEL=3D1 -= DGRUB_MACHINE_MIPS_LOONGSON=3D1 -DGRUB_MACHINE=3DMIPS_LOONGSON -nostdlib -= static conftest.c >&5 error: unknown target CPU 'mips32r2' configure:24700: $? =3D 1 configure: failed program was: [...] configure:24700: /gnu/store/yjmchvkz0kmz4s1sxc0p89imfik68qzg-clang-3.6.0/bi= n/clang -o conftest -Os -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-s= ubscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv= -by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -= Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-b= races -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -W= sequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragm= as -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-va= lue -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes= -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -Wcast-al= ign -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast = -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpoi= nter-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-va= r -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-decl= arations -Wformat=3D2 -target mips -mabi=3D32 -Werror -Wall -W -DGRUB_CPU= _MIPSEL=3D1 -DGRUB_MACHINE_MIPS_LOONGSON=3D1 -DGRUB_MACHINE=3DMIPS_LOONGSON= -nostdlib -static conftest.c >&5 ld: /tmp/conftest-efc530.o: compiled for a big endian system and target is = little endian ld: /tmp/conftest-efc530.o: endianness incompatible with that of the select= ed emulation ld: failed to merge target specific data of file /tmp/conftest-efc530.o ld: warning: cannot find entry symbol __start; defaulting to 00000000004000= f0 collect2: error: ld returned 1 exit status clang-3.6: error: linker (via gcc) command failed with exit code 1 (use -v = to see invocation) configure:24700: $? =3D 1 configure: failed program was: [...] --8<---------------cut here---------------end--------------->8--- I guess that "-target mips" is interpreted as requesting big endian. I suspect that simply passing -mabi=3D32 is the right thing to do for clang as well, but that the clang we have built in GNU Guix doesn't include support for targetting the O32 ABI. It's possible that the only way to target O32 from a non-multilib N32 system using clang is to do cross-compilation. Or perhaps we need to explicitly request support for 'mips32r2' when building clang. Mark