Bug 56771 - Integer Overflow? Building arm-rtems libgcc2
Summary: Integer Overflow? Building arm-rtems libgcc2
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.7.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-28 20:08 UTC by Joel Sherrill
Modified: 2013-07-10 13:09 UTC (History)
2 users (show)

See Also:
Host: centos-6.4/i686 debian-5.0/sparc64
Target: arm
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-04-03 00:00:00


Attachments
Preprocessed code that fails to build (12.67 KB, application/octet-stream)
2013-03-28 20:10 UTC, Joel Sherrill
Details
Full build log (838.63 KB, application/octet-stream)
2013-03-28 20:12 UTC, Joel Sherrill
Details
xgcc dumps from a cygwin build that also fails. (90.12 KB, application/octet-stream)
2013-04-02 06:23 UTC, Chris Johns
Details
Patch to libcpp/configure.ac for 4.8 and newers (386 bytes, patch)
2013-04-03 14:43 UTC, Joel Sherrill
Details | Diff
Patch for 4.6 and 4.7 (428 bytes, patch)
2013-04-03 15:39 UTC, Joel Sherrill
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joel Sherrill 2013-03-28 20:08:27 UTC
This error occurs on some hosts. We suspect it occurs only on 32-bit hosts. It appears that some magic is occurring where a constant is too large.

Host: CentOS 6.4 32-bit
Host GCC: 4.4.7 20120313 (Red Hat 4.4.7-3)
Target: arm-rtems4.11
Component Versions:

gcc-4.7.2
gmp-5.0.5
mpc-0.8.2
mpfr-3.0.1
newlib-2.0.0

Configure command:

../gcc-4.7.2/configure \
--prefix=/home/joel/rtems-4.11-work/tools \
--bindir=/home/joel/rtems-4.11-work/tools/bin \
--exec_prefix=/home/joel/rtems-4.11-work/tools \
--includedir=/home/joel/rtems-4.11-work/tools/include \
--libdir=/home/joel/rtems-4.11-work/tools/lib \
--libexecdir=/home/joel/rtems-4.11-work/tools/libexec \
--mandir=/home/joel/rtems-4.11-work/tools/share/man \
--infodir=/home/joel/rtems-4.11-work/tools/share/info \
--datadir=/home/joel/rtems-4.11-work/tools/share \
--build=i686-linux-gnu --host=i686-linux-gnu \
--target=arm-rtems4.11 \
--disable-libstdcxx-pch \
--with-gnu-as --with-gnu-ld --verbose \
--with-newlib \
--with-system-zlib \
--disable-nls --without-included-gettext \
--disable-win32-registry \
--enable-version-specific-runtime-libs \
--disable-lto \
--enable-threads \
--disable-plugin \
--enable-newlib-io-c99-formats \
--enable-newlib-iconv \
--enable-obsolete \
--enable-languages="$languages"

Failure output:

/home/joel/rtems-4.11-work/rtems-source-builder/rtems/build/arm-rtems4.11-gcc-4.7.2-newlib-2.0.0-1-4.7.2-1/arm-rtems4.11-gcc-4.7.2-newlib-2.0.0-1-4.7.2/build/./gcc/xgcc -B/home/joel/rtems-4.11-work/rtems-source-builder/rtems/build/arm-rtems4.11-gcc-4.7.2-newlib-2.0.0-1-4.7.2-1/arm-rtems4.11-gcc-4.7.2-newlib-2.0.0-1-4.7.2/build/./gcc/ -nostdinc -B/home/joel/rtems-4.11-work/rtems-source-builder/rtems/build/arm-rtems4.11-gcc-4.7.2-newlib-2.0.0-1-4.7.2-1/arm-rtems4.11-gcc-4.7.2-newlib-2.0.0-1-4.7.2/build/arm-rtems4.11/newlib/ -isystem /home/joel/rtems-4.11-work/rtems-source-builder/rtems/build/arm-rtems4.11-gcc-4.7.2-newlib-2.0.0-1-4.7.2-1/arm-rtems4.11-gcc-4.7.2-newlib-2.0.0-1-4.7.2/build/arm-rtems4.11/newlib/targ-include -isystem /home/joel/rtems-4.11-work/rtems-source-builder/rtems/build/arm-rtems4.11-gcc-4.7.2-newlib-2.0.0-1-4.7.2-1/arm-rtems4.11-gcc-4.7.2-newlib-2.0.0-1-4.7.2/gcc-4.7.2/newlib/libc/include -B/home/joel/rtems-4.11-work/tools/arm-rtems4.11/bin/ -B/home/joel/rtems-4.11-work/tools/arm-rtems4.11/lib/ -isystem /home/joel/rtems-4.11-work/tools/arm-rtems4.11/include -isystem /home/joel/rtems-4.11-work/tools/arm-rtems4.11/sys-include    -g -O2 -mthumb -O2 -I../../../../gcc-4.7.2/libgcc/../newlib/libc/sys/rtems/include -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -fno-inline -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -Dinhibit_libc  -fno-inline -I. -I. -I../../.././gcc -I../../../../gcc-4.7.2/libgcc -I../../../../gcc-4.7.2/libgcc/. -I../../../../gcc-4.7.2/libgcc/../gcc -I../../../../gcc-4.7.2/libgcc/../include  -DHAVE_CC_TLS  -o _muldi3.o -MT _muldi3.o -MD -MP -MF _muldi3.dep -DL_muldi3 -c ../../../../gcc-4.7.2/libgcc/libgcc2.c 
In file included from ../../../../gcc-4.7.2/libgcc/libgcc2.c:30:0:
../../../../gcc-4.7.2/libgcc/../gcc/coretypes.h:188:3: warning: this decimal constant is unsigned only in ISO C90 [enabled by default]
../../../../gcc-4.7.2/libgcc/../gcc/coretypes.h:195:1: warning: enumeration values exceed range of largest integer [enabled by default]
In file included from ../../.././gcc/options.h:6:0,
                 from ../../.././gcc/tm.h:14,
                 from ../../../../gcc-4.7.2/libgcc/libgcc2.c:31:
../../../../gcc-4.7.2/libgcc/../gcc/flag-types.h:139:3: warning: this decimal constant is unsigned only in ISO C90 [enabled by default]
../../../../gcc-4.7.2/libgcc/../gcc/flag-types.h:147:3: warning: this decimal constant is unsigned only in ISO C90 [enabled by default]
../../../../gcc-4.7.2/libgcc/../gcc/flag-types.h:186:1: warning: enumeration values exceed range of largest integer [enabled by default]
../../../../gcc-4.7.2/libgcc/../gcc/flag-types.h:190:3: warning: this decimal constant is unsigned only in ISO C90 [enabled by default]
../../../../gcc-4.7.2/libgcc/../gcc/flag-types.h:193:1: warning: enumeration values exceed range of largest integer [enabled by default]
In file included from ../../.././gcc/options.h:8:0,
                 from ../../.././gcc/tm.h:14,
                 from ../../../../gcc-4.7.2/libgcc/libgcc2.c:31:
../../../../gcc-4.7.2/libgcc/../gcc/config/arm/arm-opts.h:42:3: warning: this decimal constant is unsigned only in ISO C90 [enabled by default]
../../../../gcc-4.7.2/libgcc/../gcc/config/arm/arm-opts.h:45:1: warning: enumeration values exceed range of largest integer [enabled by default]
In file included from ../../.././gcc/tm.h:14:0,
                 from ../../../../gcc-4.7.2/libgcc/libgcc2.c:31:
../../.././gcc/options.h:3626:3: warning: this decimal constant is unsigned only in ISO C90 [enabled by default]
../../.././gcc/options.h:4750:1: warning: enumeration values exceed range of largest integer [enabled by default]
In file included from ../../.././gcc/tm.h:15:0,
                 from ../../../../gcc-4.7.2/libgcc/libgcc2.c:31:
../../.././gcc/insn-constants.h:28:3: warning: this decimal constant is unsigned only in ISO C90 [enabled by default]
../../.././gcc/insn-constants.h:186:1: warning: enumeration values exceed range of largest integer [enabled by default]
../../.././gcc/insn-constants.h:191:3: warning: this decimal constant is unsigned only in ISO C90 [enabled by default]
../../.././gcc/insn-constants.h:213:1: warning: enumeration values exceed range of largest integer [enabled by default]
In file included from ../../.././gcc/tm.h:25:0,
                 from ../../../../gcc-4.7.2/libgcc/libgcc2.c:31:
../../../../gcc-4.7.2/libgcc/../gcc/config/arm/arm.h:128:3: warning: this decimal constant is unsigned only in ISO C90 [enabled by default]
../../../../gcc-4.7.2/libgcc/../gcc/config/arm/arm.h:335:3: warning: this decimal constant is unsigned only in ISO C90 [enabled by default]
../../../../gcc-4.7.2/libgcc/../gcc/config/arm/arm.h:1403:7: error: size of array 'call_via' is too large
../../../../gcc-4.7.2/libgcc/../gcc/config/arm/arm.h:1420:20: error: size of array 'thumb_call_via_label' is too large
../../../../gcc-4.7.2/libgcc/../gcc/config/arm/arm.h:1466:7: error: size of array 'aapcs_cprc_failed' is too large
In file included from ../../../../gcc-4.7.2/libgcc/libgcc2.c:58:0:
../../../../gcc-4.7.2/libgcc/libgcc2.h:499:22: error: size of array '__popcount_tab' is too large
../../../../gcc-4.7.2/libgcc/libgcc2.h:505:1: error: size of array '__clz_tab' is too large
In file included from ../../../../gcc-4.7.2/libgcc/libgcc2.h:507:0,
                 from ../../../../gcc-4.7.2/libgcc/libgcc2.c:58:
../../../../gcc-4.7.2/libgcc/longlong.h:63:1: error: size of array '__clz_tab' is too large
../../../../gcc-4.7.2/libgcc/libgcc2.c: In function '__muldi3':
../../../../gcc-4.7.2/libgcc/libgcc2.c:553:22: warning: integer overflow in expression [-Woverflow]
../../../../gcc-4.7.2/libgcc/libgcc2.c:553:3: warning: overflow in implicit constant conversion [-Woverflow]
../../../../gcc-4.7.2/libgcc/libgcc2.c:553:22: warning: integer overflow in expression [-Woverflow]
../../../../gcc-4.7.2/libgcc/libgcc2.c:553:3: warning: right shift count is negative [enabled by default]
../../../../gcc-4.7.2/libgcc/libgcc2.c:553:22: warning: integer overflow in expression [-Woverflow]
../../../../gcc-4.7.2/libgcc/libgcc2.c:553:3: warning: left shift count is negative [enabled by default]
../../../../gcc-4.7.2/libgcc/libgcc2.c:553:22: warning: integer overflow in expression [-Woverflow]
../../../../gcc-4.7.2/libgcc/libgcc2.c:553:3: warning: right shift count is negative [enabled by default]
../../../../gcc-4.7.2/libgcc/libgcc2.c:553:22: warning: integer overflow in expression [-Woverflow]
../../../../gcc-4.7.2/libgcc/libgcc2.c:553:3: warning: right shift count is negative [enabled by default]
../../../../gcc-4.7.2/libgcc/libgcc2.c:553:22: warning: integer overflow in expression [-Woverflow]
../../../../gcc-4.7.2/libgcc/libgcc2.c:553:3: warning: left shift count is negative [enabled by default]
../../../../gcc-4.7.2/libgcc/libgcc2.c:553:22: warning: integer overflow in expression [-Woverflow]
../../../../gcc-4.7.2/libgcc/libgcc2.c:553:3: warning: right shift count is negative [enabled by default]
../../../../gcc-4.7.2/libgcc/libgcc2.c:553:22: warning: integer overflow in expression [-Woverflow]
../../../../gcc-4.7.2/libgcc/libgcc2.c:553:3: warning: left shift count is negative [enabled by default]
../../../../gcc-4.7.2/libgcc/libgcc2.c:553:22: warning: integer overflow in expression [-Woverflow]
../../../../gcc-4.7.2/libgcc/libgcc2.c:553:3: warning: left shift count is negative [enabled by default]
../../../../gcc-4.7.2/libgcc/libgcc2.c:553:22: warning: integer overflow in expression [-Woverflow]
../../../../gcc-4.7.2/libgcc/libgcc2.c:553:3: warning: left shift count is negative [enabled by default]
../../../../gcc-4.7.2/libgcc/libgcc2.c:553:3: warning: this decimal constant is unsigned only in ISO C90 [enabled by default]
make[4]: *** [_muldi3.o] Error 1
make[4]: Leaving directory `/home/joel/rtems-4.11-work/rtems-source-builder/rtems/build/arm-rtems4.11-gcc-4.7.2-newlib-2.0.0-1-4.7.2-1/arm-rtems4.11-gcc-4.7.2-newlib-2.0.0-1-4.7.2/build/arm-rtems4.11/thumb/libgcc'
make[3]: *** [multi-do] Error 1
make[3]: Leaving directory `/home/joel/rtems-4.11-work/rtems-source-builder/rtems/build/arm-rtems4.11-gcc-4.7.2-newlib-2.0.0-1-4.7.2-1/arm-rtems4.11-gcc-4.7.2-newlib-2.0.0-1-4.7.2/build/arm-rtems4.11/libgcc'
make[2]: *** [all-multi] Error 2
make[2]: Leaving directory `/home/joel/rtems-4.11-work/rtems-source-builder/rtems/build/arm-rtems4.11-gcc-4.7.2-newlib-2.0.0-1-4.7.2-1/arm-rtems4.11-gcc-4.7.2-newlib-2.0.0-1-4.7.2/build/arm-rtems4.11/libgcc'
make[1]: *** [all-target-libgcc] Error 2
make[1]: Leaving directory `/home/joel/rtems-4.11-work/rtems-source-builder/rtems/build/arm-rtems4.11-gcc-4.7.2-newlib-2.0.0-1-4.7.2-1/arm-rtems4.11-gcc-4.7.2-newlib-2.0.0-1-4.7.2/build'
Comment 1 Joel Sherrill 2013-03-28 20:10:34 UTC
Created attachment 29747 [details]
Preprocessed code that fails to build

I don't think this code is in error. At least I don't see how. I think something has gone wrong with the arm cross-compiler being used to build it.
Comment 2 Joel Sherrill 2013-03-28 20:12:06 UTC
Created attachment 29748 [details]
Full build log

In case there is something useful in the build log.

Host: CentOS 6.4.

FYI We first saw this back in Oct 2012. But could not reproduce it on another machine. I believe it has now been reproduced on 32-bit CentOS and Ubuntu hosts.
Comment 3 Joel Sherrill 2013-03-29 22:18:26 UTC
Adding another data point. This also fails on gcc63.fsffrance.org which is:

$ ssh joel@gcc63.fsffrance.org
Linux deluxe 2.6.26-2-sparc64-smp #1 SMP Sun Mar 4 22:02:58 UTC 2012 sparc64

$ cat /etc/issue
Debian GNU/Linux 5.0 \n \l
Comment 4 Chris Johns 2013-04-02 06:23:53 UTC
Created attachment 29771 [details]
xgcc dumps from a cygwin build that also fails.

The file contains all the gcc trace and dump output I could figure out. If more is needed I am happy to collect it so please let me know what I need to add.
Comment 5 Chris Johns 2013-04-02 06:28:32 UTC
A cygwin cross-compile also fails as it is a 32bit host. The failure is not specific to Linux.

This means RTEMS users have problems building from source on Windows as cygwin currently us not working and MinGW has issues (gcc-4.7.2 contains path elements great than the Windows max. limit and this effects MinGW utils, eg rm).
Comment 6 Chris Johns 2013-04-02 11:04:29 UTC
It looks to me like libcpp/configure.ac is not setting 'need_64bit_hwint' to 'yes'. It looks like the RTEMS ptch to change arm-rtems*eabi to arm-rtems* needs to have this added.
Comment 7 Joel Sherrill 2013-04-03 14:43:16 UTC
Created attachment 29796 [details]
Patch to libcpp/configure.ac for 4.8 and newers
Comment 8 Joel Sherrill 2013-04-03 15:15:37 UTC
Patch committed to 4.7, 4.8 and SVN head.

Closing.
Comment 9 Sebastian Huber 2013-04-03 15:23:29 UTC
(In reply to comment #8)
> Patch committed to 4.7, 4.8 and SVN head.
> 
> Closing.

Can you please commit this also to the 4.6 branch.
Comment 10 Joel Sherrill 2013-04-03 15:35:32 UTC
Wrong patch applied to 4.7. Need to apply to 4.6  as well.
Comment 11 Joel Sherrill 2013-04-03 15:39:47 UTC
Created attachment 29797 [details]
Patch for 4.6 and 4.7
Comment 12 Joel Sherrill 2013-07-10 13:09:55 UTC
Fixed per email from Sebastian Huber. Closing.