Richard Sandiford via Gcc-patches <gcc-patches@gcc.gnu.org> 于2021年9月1日周三 下午4:55写道: > > apinski--- via Gcc-patches <gcc-patches@gcc.gnu.org> writes: > > From: Andrew Pinski <apin...@marvell.com> > > > > This adds MIPS Linux support to gcc.misc-tests/linkage.exp. Basically > > copying what was done for MIPS IRIX and changing the options to be correct. > > > > OK? > > > > gcc/testsuite/ChangeLog: > > > > PR testsuite/51748 > > * gcc.misc-tests/linkage.exp: Add mips*-linux-* support. > > OK, thanks. Searching for any match for 64 seems surprisingly general, > but it's what other cases do and has obviously stood the test of time. >
syq@XX:~$ gcc -mips64r2 -mabi=64 -c zz.c && file zz.o zz.o: ELF 64-bit LSB relocatable, MIPS, MIPS64 rel2 version 1 (SYSV), not stripped syq@XX:~$ gcc -mips64r2 -mabi=32 -c zz.c && file zz.o zz.o: ELF 32-bit LSB relocatable, MIPS, MIPS64 rel2 version 1 (SYSV), not stripped syq@XX:~$ gcc -mips64r2 -mabi=n32 -c zz.c && file zz.o zz.o: ELF 32-bit LSB relocatable, MIPS, N32 MIPS64 rel2 version 1 (SYSV), not stripped In the first glance, I also thought the code is wrong. While with some check, it does work. > Richard > > > --- > > gcc/testsuite/gcc.misc-tests/linkage.exp | 12 ++++++++++++ > > 1 file changed, 12 insertions(+) > > > > diff --git a/gcc/testsuite/gcc.misc-tests/linkage.exp > > b/gcc/testsuite/gcc.misc-tests/linkage.exp > > index afed2b811c9..2cb109e776e 100644 > > --- a/gcc/testsuite/gcc.misc-tests/linkage.exp > > +++ b/gcc/testsuite/gcc.misc-tests/linkage.exp > > @@ -38,6 +38,18 @@ if { [isnative] && ![is_remote host] } then { > > > > # Need to ensure ABI for native compiler matches gcc > > set native_cflags "" > > + if [istarget "mips*-linux*"] { > > + set file_string [exec file "linkage-x.o"] > > + if [ string match "*64*" $file_string ] { > > + set native_cflags "-mabi=64" > > + } > > + if [ string match "*ELF 32*" $file_string ] { > > + set native_cflags "-mabi=32" > > + } > > + if [ string match "*N32*" $file_string ] { > > + set native_cflags "-mabi=n32" > > + } > > + } > > if [istarget "sparc*-sun-solaris2*"] { > > set file_string [exec file "linkage-x.o"] > > if [ string match "*64*" $file_string ] {