Yes, it appears to me that
the compiler (cc1) and assembler (as) invocations are the same. I've included
the "-v" output of each below for reference. Furthermore, the -save-temps output
.i files are effectively the same (differences due to cross vs. native paths,
but that is it). Nonetheless, the output assembly source still contains
differences!
I'm curious if anybody examined the
output of a cross and native toolchain of the same (recent)
version?
Eric
0:~$ diff -wbup cross.s native.s
--- cross.s 2006-09-19 11:38:54.000000000 -0500
+++ native.s 2006-09-19 11:39:07.000000000 -0500
@@ -17,24 +17,20 @@ main:
.fmask 0x00000000,0
.set noreorder
.cpload $25
- .set nomacro
-
+ .set reorder
addiu $sp,$sp,-32
sw $31,24($sp)
.cprestore 16
- lw $4,%got($LC0)($28)
- lw $25,%call16(printf)($28)
- nop
- jalr $25
- addiu $4,$4,%lo($LC0)
-
- lw $28,16($sp)
+ la $4,$LC0
+ jal printf
lw $31,24($sp)
subu $2,$0,$2
+ .set noreorder
+ .set nomacro
j $31
addiu $sp,$sp,32
-
.set macro
.set reorder
+
.end main
.ident "GCC: (GNU) 3.4.4"
--- cross.s 2006-09-19 11:38:54.000000000 -0500
+++ native.s 2006-09-19 11:39:07.000000000 -0500
@@ -17,24 +17,20 @@ main:
.fmask 0x00000000,0
.set noreorder
.cpload $25
- .set nomacro
-
+ .set reorder
addiu $sp,$sp,-32
sw $31,24($sp)
.cprestore 16
- lw $4,%got($LC0)($28)
- lw $25,%call16(printf)($28)
- nop
- jalr $25
- addiu $4,$4,%lo($LC0)
-
- lw $28,16($sp)
+ la $4,$LC0
+ jal printf
lw $31,24($sp)
subu $2,$0,$2
+ .set noreorder
+ .set nomacro
j $31
addiu $sp,$sp,32
-
.set macro
.set reorder
+
.end main
.ident "GCC: (GNU) 3.4.4"
For good measure, here's the assembly output from the cross
compiler:
0:~$ more cross.s
.file 1 "t.c"
.section .mdebug.abi32
.previous
.abicalls
.section .rodata.str1.4,"aMS",@progbits,1
.align 2
$LC0:
.ascii "Hello, World!\n\000"
.text
.align 2
.globl main
.ent main
.type main, @function
main:
.frame $sp,32,$31 # vars= 0, regs= 1/0, args= 16, gp= 8
.mask 0x80000000,-8
.fmask 0x00000000,0
.set noreorder
.cpload $25
.set nomacro
.file 1 "t.c"
.section .mdebug.abi32
.previous
.abicalls
.section .rodata.str1.4,"aMS",@progbits,1
.align 2
$LC0:
.ascii "Hello, World!\n\000"
.text
.align 2
.globl main
.ent main
.type main, @function
main:
.frame $sp,32,$31 # vars= 0, regs= 1/0, args= 16, gp= 8
.mask 0x80000000,-8
.fmask 0x00000000,0
.set noreorder
.cpload $25
.set nomacro
addiu $sp,$sp,-32
sw $31,24($sp)
.cprestore 16
lw $4,%got($LC0)($28)
lw $25,%call16(printf)($28)
nop
jalr $25
addiu $4,$4,%lo($LC0)
sw $31,24($sp)
.cprestore 16
lw $4,%got($LC0)($28)
lw $25,%call16(printf)($28)
nop
jalr $25
addiu $4,$4,%lo($LC0)
lw $28,16($sp)
lw $31,24($sp)
subu $2,$0,$2
j $31
addiu $sp,$sp,32
lw $31,24($sp)
subu $2,$0,$2
j $31
addiu $sp,$sp,32
.set macro
.set reorder
.end main
.ident "GCC: (GNU) 3.4.4"
.set reorder
.end main
.ident "GCC: (GNU) 3.4.4"
And here is the cross and native screen capture due to -v:
==== cross ====
0:~$ mipsel-unknown-linux-gnu-gcc -v -save-temps -O2 -c
/opt/oe/target/root/t.c -o obj2.o
Reading specs from /opt/crosstool/gcc-3.4.4-glibc-2.3.6/mipsel-unknown-linux-gnu/lib/gcc/mipsel-unknown-linux-gnu/3.4.4/specs
Configured with: /home/edevolder/downloads/crosstool-0.42/build/mipsel-unknown-linux-gnu/gcc-3.4.4-glibc-2.3.6/gcc-3.4.4/configure --target=mipsel-unknown-linux-gnu --host=x86_64-host_unknown-linux-gnu --prefix=/opt/crosstool/gcc-3.4.4-glibc-2.3.6/mipsel-unknown-linux-gnu --with-sysroot=/opt/crosstool/gcc-3.4.4-glibc-2.3.6/mipsel-unknown-linux-gnu/mipsel-unknown-linux-gnu/sys-root --with-local-prefix=/opt/crosstool/gcc-3.4.4-glibc-2.3.6/mipsel-unknown-linux-gnu/mipsel-unknown-linux-gnu/sys-root --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long
Thread model: posix
gcc version 3.4.4
/opt/crosstool/gcc-3.4.4-glibc-2.3.6/mipsel-unknown-linux-gnu/libexec/gcc/mipsel-unknown-linux-gnu/3.4.4/cc1 -E -quiet -v /opt/oe/target/root/t.c -O2 -o t.i
ignoring nonexistent directory "/opt/crosstool/gcc-3.4.4-glibc-2.3.6/mipsel-unknown-linux-gnu/mipsel-unknown-linux-gnu/sys-root/opt/crosstool/gcc-3.4.4-glibc-2.3.6/mipsel-unknown-linux-gnu/mipsel-unknown-linux-gnu/sys-root/include"
ignoring nonexistent directory "/opt/crosstool/gcc-3.4.4-glibc-2.3.6/mipsel-unknown-linux-gnu/lib/gcc/mipsel-unknown-linux-gnu/3.4.4/../../../../mipsel-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/opt/crosstool/gcc-3.4.4-glibc-2.3.6/mipsel-unknown-linux-gnu/lib/gcc/mipsel-unknown-linux-gnu/3.4.4/include
/opt/crosstool/gcc-3.4.4-glibc-2.3.6/mipsel-unknown-linux-gnu/mipsel-unknown-linux-gnu/sys-root/usr/include
End of search list.
/opt/crosstool/gcc-3.4.4-glibc-2.3.6/mipsel-unknown-linux-gnu/libexec/gcc/mipsel-unknown-linux-gnu/3.4.4/cc1 -fpreprocessed t.i -quiet -dumpbase t.c -auxbase-strip obj2.o -O2 -version -o t.s
GNU C version 3.4.4 (mipsel-unknown-linux-gnu)
compiled by GNU C version 3.2.3 20030502 (Red Hat Linux 3.2.3-54).
GGC heuristics: --param ggc-min-expand=97 --param ggc-min-heapsize=126001
/opt/crosstool/gcc-3.4.4-glibc-2.3.6/mipsel-unknown-linux-gnu/lib/gcc/mipsel-unknown-linux-gnu/3.4.4/../../../../mipsel-unknown-linux-gnu/bin/as -EL -O2 -no-mdebug -32 -v -KPIC -o obj2.o t.s
GNU assembler version 2.15 (mipsel-unknown-linux-gnu) using BFD version 2.15
Reading specs from /opt/crosstool/gcc-3.4.4-glibc-2.3.6/mipsel-unknown-linux-gnu/lib/gcc/mipsel-unknown-linux-gnu/3.4.4/specs
Configured with: /home/edevolder/downloads/crosstool-0.42/build/mipsel-unknown-linux-gnu/gcc-3.4.4-glibc-2.3.6/gcc-3.4.4/configure --target=mipsel-unknown-linux-gnu --host=x86_64-host_unknown-linux-gnu --prefix=/opt/crosstool/gcc-3.4.4-glibc-2.3.6/mipsel-unknown-linux-gnu --with-sysroot=/opt/crosstool/gcc-3.4.4-glibc-2.3.6/mipsel-unknown-linux-gnu/mipsel-unknown-linux-gnu/sys-root --with-local-prefix=/opt/crosstool/gcc-3.4.4-glibc-2.3.6/mipsel-unknown-linux-gnu/mipsel-unknown-linux-gnu/sys-root --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long
Thread model: posix
gcc version 3.4.4
/opt/crosstool/gcc-3.4.4-glibc-2.3.6/mipsel-unknown-linux-gnu/libexec/gcc/mipsel-unknown-linux-gnu/3.4.4/cc1 -E -quiet -v /opt/oe/target/root/t.c -O2 -o t.i
ignoring nonexistent directory "/opt/crosstool/gcc-3.4.4-glibc-2.3.6/mipsel-unknown-linux-gnu/mipsel-unknown-linux-gnu/sys-root/opt/crosstool/gcc-3.4.4-glibc-2.3.6/mipsel-unknown-linux-gnu/mipsel-unknown-linux-gnu/sys-root/include"
ignoring nonexistent directory "/opt/crosstool/gcc-3.4.4-glibc-2.3.6/mipsel-unknown-linux-gnu/lib/gcc/mipsel-unknown-linux-gnu/3.4.4/../../../../mipsel-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/opt/crosstool/gcc-3.4.4-glibc-2.3.6/mipsel-unknown-linux-gnu/lib/gcc/mipsel-unknown-linux-gnu/3.4.4/include
/opt/crosstool/gcc-3.4.4-glibc-2.3.6/mipsel-unknown-linux-gnu/mipsel-unknown-linux-gnu/sys-root/usr/include
End of search list.
/opt/crosstool/gcc-3.4.4-glibc-2.3.6/mipsel-unknown-linux-gnu/libexec/gcc/mipsel-unknown-linux-gnu/3.4.4/cc1 -fpreprocessed t.i -quiet -dumpbase t.c -auxbase-strip obj2.o -O2 -version -o t.s
GNU C version 3.4.4 (mipsel-unknown-linux-gnu)
compiled by GNU C version 3.2.3 20030502 (Red Hat Linux 3.2.3-54).
GGC heuristics: --param ggc-min-expand=97 --param ggc-min-heapsize=126001
/opt/crosstool/gcc-3.4.4-glibc-2.3.6/mipsel-unknown-linux-gnu/lib/gcc/mipsel-unknown-linux-gnu/3.4.4/../../../../mipsel-unknown-linux-gnu/bin/as -EL -O2 -no-mdebug -32 -v -KPIC -o obj2.o t.s
GNU assembler version 2.15 (mipsel-unknown-linux-gnu) using BFD version 2.15
=== native ===
root@db1200:~# gcc -v -save-temps -O2 -c t.c -o obj1.o
Reading specs from /usr/lib/gcc/mipsel-unknown-linux-gnu/3.4.4/specs
Configured with: /home/edevolder/downloads/crosstool-0.42/build/mipsel-unknown-linux-gnu/gcc-3.4.4-glibc-2.3.6/gcc-3.4.4/configure --build=x86_64-build_unknown-linux-gnu --target=mipsel-unknown-linux-gnu --host=mipsel-unknown-linux-gnu --prefix=/usr --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long
Thread model: posix
gcc version 3.4.4
/usr/libexec/gcc/mipsel-unknown-linux-gnu/3.4.4/cc1 -E -quiet -v t.c -O2 -o t.iignoring nonexistent directory "/usr/lib/gcc/mipsel-unknown-linux-gnu/3.4.4/../../../../mipsel-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/mipsel-unknown-linux-gnu/3.4.4/include
/usr/include
End of search list.
/usr/libexec/gcc/mipsel-unknown-linux-gnu/3.4.4/cc1 -fpreprocessed t.i -quiet -dumpbase t.c -auxbase-strip obj1.o -O2 -version -o t.s
GNU C version 3.4.4 (mipsel-unknown-linux-gnu)
compiled by GNU C version 3.4.4.
GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=31868
/usr/lib/gcc/mipsel-unknown-linux-gnu/3.4.4/../../../../mipsel-unknown-linux-gnu/bin/as -EL -O2 -no-mdebug -32 -v -KPIC -o obj1.o t.s
GNU assembler version 2.15 (mipsel-unknown-linux-gnu) using BFD version 2.15
Reading specs from /usr/lib/gcc/mipsel-unknown-linux-gnu/3.4.4/specs
Configured with: /home/edevolder/downloads/crosstool-0.42/build/mipsel-unknown-linux-gnu/gcc-3.4.4-glibc-2.3.6/gcc-3.4.4/configure --build=x86_64-build_unknown-linux-gnu --target=mipsel-unknown-linux-gnu --host=mipsel-unknown-linux-gnu --prefix=/usr --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long
Thread model: posix
gcc version 3.4.4
/usr/libexec/gcc/mipsel-unknown-linux-gnu/3.4.4/cc1 -E -quiet -v t.c -O2 -o t.iignoring nonexistent directory "/usr/lib/gcc/mipsel-unknown-linux-gnu/3.4.4/../../../../mipsel-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/mipsel-unknown-linux-gnu/3.4.4/include
/usr/include
End of search list.
/usr/libexec/gcc/mipsel-unknown-linux-gnu/3.4.4/cc1 -fpreprocessed t.i -quiet -dumpbase t.c -auxbase-strip obj1.o -O2 -version -o t.s
GNU C version 3.4.4 (mipsel-unknown-linux-gnu)
compiled by GNU C version 3.4.4.
GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=31868
/usr/lib/gcc/mipsel-unknown-linux-gnu/3.4.4/../../../../mipsel-unknown-linux-gnu/bin/as -EL -O2 -no-mdebug -32 -v -KPIC -o obj1.o t.s
GNU assembler version 2.15 (mipsel-unknown-linux-gnu) using BFD version 2.15
From: Thiemo Seufer [mailto:ths@xxxxxxxxxxxx]
Sent: Tue 9/19/2006 11:05 AM
To: Eric DeVolder
Cc: linux-mips@xxxxxxxxxxxxxx
Subject: Re: Differing results from cross and native compilers
Eric DeVolder wrote:
[snip]
> I would have thought that
for this simple example I'd get identical
> results. For reasons I have
yet to figure out, the cross compiler is
> finding better optimizations
than the native, though both are the
> same gcc version. I checked the
specs files, and the two are identical
> other than the "cross_compile"
setting.
Have you checked (with -v) if the assembler gets the same
optimisations
in both cases, and/or (with -save-temps) where in the compile
things
start to diverge?
Thiemo