Article View: gnu.gcc.bug
Article #526GCC doesn't compile itself correctly on sun4 without -g
From: Dave Cohrs
Date: Mon, 07 Aug 1989 19:55
Date: Mon, 07 Aug 1989 19:55
232 lines
6242 bytes
6242 bytes
I really wish I could give you more detail on this one, but it's tough.
If there's anything I can do to help out on this, let me know. This'll
be a toughy, because it only shows up when you don't use "-g".
Environment:
Sun4/110, SunOS 4.0.1
gcc version 1.35 (no patches; the raw distribution from prep.)
configured with config.gcc for "sun4-os4"
Description:
By default, gcc compiles itself with "-g -O". On a lark, I
decided to take out the "-g", and went through the compilation
steps, including the verification step. I did the following:
% make ; make stage1
% make CC="stage1/gcc -Bstage1/" CFLAGS="-O"
% make stage2
% make CC="stage2/gcc -Bstage2/" CFLAGS="-O"
% foreach file ( *.o )
> cmp $file stage2/$file
> end
The "cmp"'s showed various files that were different, namely:
caller-save.o stage2/caller-save.o differ: char 8, line 2
cccp.o stage2/cccp.o differ: char 7, line 1
cexp.o stage2/cexp.o differ: char 8, line 1
cse.o stage2/cse.o differ: char 7, line 1
explow.o stage2/explow.o differ: char 8, line 1
expmed.o stage2/expmed.o differ: char 8, line 1
expr.o stage2/expr.o differ: char 8, line 1
fold-const.o stage2/fold-const.o differ: char 7, line 1
loop.o stage2/loop.o differ: char 8, line 1
stmt.o stage2/stmt.o differ: char 8, line 1
stor-layout.o stage2/stor-layout.o differ: char 7, line 1
toplev.o stage2/toplev.o differ: char 8, line 1
tree.o stage2/tree.o differ: char 8, line 1
varasm.o stage2/varasm.o differ: char 7, line 1
Which, of course, means their sizes are different, which
means that the stage1 and stage2 compilers are different.
Oh, when I compiled gcc with "-O -g", the stage1 and stage2
output were identical (i.e. the cmp's didn't complain).
Example:
I just happen to have a small example procedure that tickles at
least one bug. Here it is, along with the output of two version
of gcc. The first output is a gcc compiled with "-O -g", the
second, with just "-O".
int
hash(s)
register char *s;
{
register hval = 0;
/* simple shift and add hash... */
while(*s)
hval = (hval<<1)+(*s++);
return (hval%521); /* return hash mod the table size (odd) */
}
**Output of "gcc -B$HOME/src/gcc/ -S -g -c /tmp/foo.c" ($HOME/src/gcc
contains a version of the gcc executables compiled with "-O -g").
gcc_compiled.:
.stabs "/tmp/foo.c",100,0,0,Ltext
Ltext:
.stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0
.stabs "char:t2=r2;0;127;",128,0,0,0
.stabs "long int:t3=r1;-2147483648;2147483647;",128,0,0,0
.stabs "unsigned int:t4=r1;0;-1;",128,0,0,0
.stabs "long unsigned int:t5=r1;0;-1;",128,0,0,0
.stabs "short int:t6=r1;-32768;32767;",128,0,0,0
.stabs "long long int:t7=r1;0;-1;",128,0,0,0
.stabs "short unsigned int:t8=r1;0;65535;",128,0,0,0
.stabs "long long unsigned int:t9=r1;0;-1;",128,0,0,0
.stabs "signed char:t10=r1;-128;127;",128,0,0,0
.stabs "unsigned char:t11=r1;0;255;",128,0,0,0
.stabs "float:t12=r1;4;0;",128,0,0,0
.stabs "double:t13=r1;8;0;",128,0,0,0
.stabs "long double:t14=r1;8;0;",128,0,0,0
.stabs "void:t15=15",128,0,0,0
.text
.align 4
.global _hash
.proc 1
_hash:
.stabn 68,0,5,LM1
LM1:
!#PROLOGUE# 0
save %sp,-112,%sp
!#PROLOGUE# 1
mov %i0,%l0
LBB2:
.stabn 68,0,7,LM2
LM2:
mov 0,%l1
.stabn 68,0,10,LM3
LM3:
L2:
ldsb [%l0],%o0
mov 0,%o1
cmp %o0,%o1
be L3
nop
.stabn 68,0,11,LM4
LM4:
sll %l1,1,%o0
ldsb [%l0],%o1
add %o0,%o1,%l1
add %l0,1,%l0
b L2
nop
L3:
.stabn 68,0,13,LM5
LM5:
mov %l1,%o0
mov 521,%o1
call .rem,0
nop
mov %o0,%o0
mov %o0,%i0
b L1
nop
LBE2:
.stabn 68,0,14,LM6
LM6:
L1:
ret
restore
.stabs "hash:F1",36,0,0,_hash
.stabs "s:P16=*2",64,0,0,16
.stabs "hval:r1",64,0,0,17
.stabn 192,0,0,LBB2
.stabn 224,0,0,LBE2
**Output of "gcc -B$HOME/gcc-1.35/stage2/ -S -g -c /tmp/foo.c" (stage2
contains a version of the gcc executables compiled with "-O", no -g).
gcc_compiled.:
.stabs "/tmp/foo.c",100,0,0,Ltext
Ltext:
.stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0
.stabs "char:t2=r2;0;127;",128,0,0,0
.stabs "long int:t3=r1;-2147483648;2147483647;",128,0,0,0
.stabs "unsigned int:t4=r1;0;-1;",128,0,0,0
.stabs "long unsigned int:t5=r1;0;-1;",128,0,0,0
.stabs "short int:t6=r1;-32768;32767;",128,0,0,0
.stabs "long long int:t7=r1;0;-1;",128,0,0,0
.stabs "short unsigned int:t8=r1;0;65535;",128,0,0,0
.stabs "long long unsigned int:t9=r1;0;-1;",128,0,0,0
.stabs "signed char:t10=r1;-128;127;",128,0,0,0
.stabs "unsigned char:t11=r1;0;255;",128,0,0,0
.stabs "float:t12=r1;4;0;",128,0,0,0
.stabs "double:t13=r1;8;0;",128,0,0,0
.stabs "long double:t14=r1;8;0;",128,0,0,0
.stabs "void:t15=15",128,0,0,0
.text
.align 4
.global _hash
.proc 1
_hash:
.stabn 68,0,5,LM1
LM1:
!#PROLOGUE# 0
save %sp,-112,%sp
!#PROLOGUE# 1
mov %i0,%l0
LBB2:
.stabn 68,0,7,LM2
LM2:
mov 0,%l1
.stabn 68,0,10,LM3
LM3:
L2:
ldsb [%l0],%o0
mov 0,%o1
cmp %o0,%o1
be L3
nop
.stabn 68,0,11,LM4
LM4:
sll %l1,1,%o0
ldsb [%l0],%o1
add %o0,%o1,%l1
add %l0,1,%l0
b L2
nop
L3:
.stabn 68,0,13,LM5
LM5:
call .rem,0
nop
mov %o0,%o0
mov %o0,%i0
b L1
nop
LBE2:
.stabn 68,0,14,LM6
LM6:
L1:
ret
restore
.stabs "hash:F1",36,0,0,_hash
.stabs "s:P16=*2",64,0,0,16
.stabs "hval:r1",64,0,0,17
.stabn 192,0,0,LBB2
.stabn 224,0,0,LBE2
**The difference between these is what the compiler generates for the
final "return" statement:
% diff -c foo.s.withg foo.s.stage2
*** foo.s.withg Mon Aug 7 14:41:28 1989
--- foo.s.stage2 Mon Aug 7 14:42:07 1989
***************
*** 50,57 ****
L3:
.stabn 68,0,13,LM5
LM5:
- mov %l1,%o0
- mov 521,%o1
call .rem,0
nop
mov %o0,%o0
--- 50,55 ----
Dave Cohrs
Technical Details
Message-ID:
<8908071955.AA15933@romano.cs.wisc.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!CS.WISC.EDU!daveShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!CS.WISC.EDU!dave From: dave@CS.WISC.EDU (Dave Cohrs) Newsgroups: gnu.gcc.bug Subject: GCC doesn't compile itself correctly on sun4 without -g Message-ID: <8908071955.AA15933@romano.cs.wisc.edu> Date: 7 Aug 89 19:55:44 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 232