grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Ensure that MIPS target code is compiled for the O32 ABI.


From: Andrei Borzenkov
Subject: Re: [PATCH] Ensure that MIPS target code is compiled for the O32 ABI.
Date: Fri, 11 Sep 2015 18:06:28 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0

25.08.2015 21:18, Mark H Weaver пишет:
Andrei Borzenkov <address@hidden> writes:

24.08.2015 11:12, Andrei Borzenkov пишет:
Could you test attached patch for both gcc and clang? Use

configure TARGET_CC=clang

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=32):

   ld: warning: cannot find entry symbol __start; defaulting to 00000000004000d0


Well, I just reused existing checks in this case; we worry about it later.

Here's the relevant excerpt:

--8<---------------cut here---------------start------------->8---
configure:24700: gcc -o conftest -Os -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -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-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -Wcast-align -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations
-Wformat=2 -mabi=32 -Werror  -Wall -W  -DGRUB_CPU_MIPSEL=1 
-DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE=MIPS_LOONGSON  -nostdlib -static 
conftest.c  >&5
ld: warning: cannot find entry symbol __start; defaulting to 00000000004000d0
configure:24700: $? = 0
configure:24708: result: -mabi=32
--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?


It is using -nostdlib; is it not enough?

  clang: with TARGET_CC=clang, 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/bin/clang -o conftest  
-Os -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -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-braces 
-Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type 
-Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas 
-Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value  
-Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -g 
-Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -Wcast-align  
-Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast 
-Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla 
-Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros 
-Wvolatile-register-var -Wpointer-sign -Wmis
sing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -mabi=32 
-Werror  -Wall -W  -DGRUB_CPU_MIPSEL=1 -DGRUB_MACHINE_MIPS_LOONGSON=1 
-DGRUB_MACHINE=MIPS_LOONGSON  -nostdlib -static conftest.c  >&5
error: unknown target CPU 'mips32r2'
configure:24700: $? = 1
configure: failed program was:
[...]
configure:24700: 
/gnu/store/yjmchvkz0kmz4s1sxc0p89imfik68qzg-clang-3.6.0/bin/clang -o conftest  
-Os -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -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-braces 
-Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type 
-Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas 
-Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value  
-Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -g 
-Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -Wcast-align  
-Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast 
-Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla 
-Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros 
-Wvolatile-register-var -Wpointer-sign -Wmis
sing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -target mips 
-mabi=32 -Werror  -Wall -W  -DGRUB_CPU_MIPSEL=1 -DGRUB_MACHINE_MIPS_LOONGSON=1 
-DGRUB_MACHINE=MIPS_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 selected 
emulation

This is the same problem we had on powerpc. Your binutils are set to use little-endian output by default; we need to explicitly enable either big or little endian in this case as well. Could you try attached patch to verify? Although I guess we need to unify endianness checks for all supported platforms.

ld: failed to merge target specific data of file /tmp/conftest-efc530.o
ld: warning: cannot find entry symbol __start; defaulting to 00000000004000f0
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: $? = 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=32 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.

As far as I can tell, clang can enable full platform (i.e. MIPS) but not platform variant. So if clang can compile for MIPS at all it should be able to produce both versions. The problem is, endianness in clang is property of target; and what makes it even worse, options that are passed to backend toolchains are also target dependent.

>                                            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


Attachment: mips-32.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]