[Bug c/51187] gcc 4.6.2 miscompiles genrecog.c when building gcc 4.5.3 with --target=avr on Debian/sparc

2011-11-17 Thread jurij at wooyd dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51187

--- Comment #1 from Jurij Smakov  2011-11-17 09:01:06 
UTC ---
Created attachment 25843
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25843
Preprocessed genrecog.c code


[Bug c/51187] gcc 4.6.2 miscompiles genrecog.c when building gcc 4.5.3 with --target=avr on Debian/sparc

2011-11-17 Thread mikpe at it dot uu.se
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51187

Mikael Pettersson  changed:

   What|Removed |Added

 CC||mikpe at it dot uu.se

--- Comment #2 from Mikael Pettersson  2011-11-17 
09:18:12 UTC ---
Have you seen this issue on other hosts than sparc32, such as x86-64 or
sparc64?

Have you checked if other versions of the host gcc work, such as gcc-4.6.1,
gcc-4.5.3, or gcc-4.4.6?


[Bug c/51187] gcc 4.6.2 miscompiles genrecog.c when building gcc 4.5.3 with --target=avr on Debian/sparc

2011-11-17 Thread plugwash at p10link dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51187

Peter Green  changed:

   What|Removed |Added

 CC||plugwash at p10link dot net

--- Comment #3 from Peter Green  2011-11-17 
11:47:35 UTC ---
>Have you seen this issue on other hosts than sparc32, such as x86-64 or
>sparc64?
gcc-avr fails around the same place on a number of architectures. I do not know
enough about gcc to say if they are all results of the same issue or not (note:
architecture names are debian architectures).

sparc:
gcc  -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wwrite-strings
-Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute
-pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings
-Wold-style-definition -Wc++-compat   -DHAVE_CONFIG_H -DGENERATOR_FILE  -o
build/genrecog \
build/genrecog.o build/rtl.o build/read-rtl.o build/ggc-none.o
build/vec.o build/min-insn-modes.o build/gensupport.o build/print-rtl.o
build/errors.o ../build-sparc-linux-gnu/libiberty/libiberty.a
build/genrecog ../../src/gcc/config/avr/avr.md \
  insn-conditions.md > tmp-recog.c
/bin/bash: line 1: 22778 Bus error   build/genrecog
../../src/gcc/config/avr/avr.md insn-conditions.md > tmp-recog.c
make[3]: *** [s-recog] Error 138

sparc64:
gcc  -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wwrite-strings
-Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute
-pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings
-Wold-style-definition -Wc++-compat   -DHAVE_CONFIG_H -DGENERATOR_FILE  -o
build/genmddeps \
build/genmddeps.o build/rtl.o build/read-rtl.o build/ggc-none.o
build/vec.o build/min-insn-modes.o build/gensupport.o build/print-rtl.o
build/errors.o ../build-sparc64-linux-gnu/libiberty/libiberty.a
build/genmddeps ../../src/gcc/config/avr/avr.md > tmp-mddeps
/bin/bash: line 1: 24043 Segmentation fault  build/genmddeps
../../src/gcc/config/avr/avr.md > tmp-mddeps
make[3]: *** [s-mddeps] Error 139

mips/mipsel:
gcc  -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wwrite-strings
-Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute
-pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings
-Wold-style-definition -Wc++-compat   -DHAVE_CONFIG_H -DGENERATOR_FILE  -o
build/genmddeps \
build/genmddeps.o build/rtl.o build/read-rtl.o build/ggc-none.o
build/vec.o build/min-insn-modes.o build/gensupport.o build/print-rtl.o
build/errors.o ../build-mips-linux-gnu/libiberty/libiberty.a
build/genmddeps ../../src/gcc/config/avr/avr.md > tmp-mddeps
../../src/gcc/config/avr/avr.md:78: missing name or number
../../src/gcc/config/avr/avr.md:78: following context is `"predicates.md")'
make[3]: *** [s-mddeps] Error 1

sh4:
gcc  -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wwrite-strings
-Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute
-pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings
-Wold-style-definition -Wc++-compat   -DHAVE_CONFIG_H -DGENERATOR_FILE  -o
build/gengenrtl \
build/gengenrtl.o build/errors.o
../build-sh4-linux-gnu/libiberty/libiberty.a
build/gengenrtl -h > tmp-genrtl.h
/bin/sh: line 1: 29938 Segmentation fault  build/gengenrtl -h >
tmp-genrtl.h
make[3]: *** [s-genrtl-h] Error 139

amd64, armel, hurd-i386, i386, ia64, kfreebsd-i386, kfreebsd-amd64, powerpc,
s390, armhf and s390x all built gcc-avr successfully. 

alpha, avr32, hppa, m68k and powerpcspe have not tried to build gcc-avr due to
unavailable binutils-avr.

>Have you checked if other versions of the host gcc work, such as gcc-4.6.1,
>gcc-4.5.3, or gcc-4.4.6?
I'm not aware of anyone trying this.


[Bug c/51187] gcc 4.6.2 miscompiles genrecog.c when building gcc 4.5.3 with --target=avr on Debian/sparc

2011-11-17 Thread ebotcazou at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51187

Eric Botcazou  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2011-11-18
 CC||ebotcazou at gcc dot
   ||gnu.org
 Ever Confirmed|0   |1

--- Comment #4 from Eric Botcazou  2011-11-18 
06:31:42 UTC ---
> We discovered this bug in gcc 4.6.2 in Debian due to build failure of gcc-avr
> package on sparc (tracked in Debian as http://bugs.debian.org/648016), which
> uses gcc 4.5 source to build an AVR cross-compiler. I was not able to come up
> with a nice self-contained test-case, but here are the steps to reproduce the
> failure.

I can reproduce.  However...

> ./configure -v --enable-languages=c,c++ --prefix=/usr/lib
> --infodir=/usr/share/info --mandir=/usr/share/man --bindir=/usr/bin
> --libexecdir=/usr/lib --libdir=/usr/lib --enable-shared --with-system-zlib
> --enable-long-long --enable-nls --without-included-gettext --disable-checking
> --disable-libssp --build=sparc-linux-gnu --host=sparc-linux-gnu --target=avr

...you should never configure the compiler with --disable-checking, even in a
cross configuration.  This will save a few percents in compilation times but
disables critical internal checking; you risk silently generating wrong code.

As a matter of fact, remove this switch is a workaround for the problem.

> My analysis indicates that failure happens due to a miscompilation of
> genrecog.c by gcc 4.6.2. Here's the debugging information I posted to the
> Debian bug already (note that this was done using gcc-avr Debian source
> package, so running genrecog in pristine 4.5.3 produces slightly different
> output, but I believe that it still crashes due to same reason):

Thanks for the thorough analysis.