[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#696267: gcc-4.7: libgcc2.c includes limits.h, breaking --without-headers bootstrap



Package: gcc-4.7
Version: 4.7.2-12
Severity: normal
Tags: upstream patch

building cross gcc targetting arm64 fails during the gcc stage1 build 
due to including limits.h even though stage1 is configured with
--without-headers.

This is the offending bit of log:
/home/wookey/linaro/armv8/toolchain/raringnew/arm64-cross-toolchain-base-1.92/gcc/build/./gcc/xgcc -B/home/wookey/linaro/armv8/toolchain/raringnew/arm64-cross-toolchain-base-1.92/gcc/build/./gcc/ -B/usr/aarch64-linux-gnu/bin/ -B/usr/aarch64-linux-gnu/lib/ -isystem /usr/aarch64-linux-gnu/include -isystem /usr/aarch64-linux-gnu/sys-include    -g -O2 -O2  -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -fPIC -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -Dinhibit_libc  -fPIC -I. -I. -I../.././gcc -I../../../src/libgcc -I../../../src/libgcc/. -I../../../src/libgcc/../gcc -I../../../src/libgcc/../include  -DHAVE_CC_TLS  -o _fixunsxfsi.o -MT _fixunsxfsi.o -MD -MP -MF _fixunsxfsi.dep -DL_fixunsxfsi -c ../../../src/libgcc/libgcc2.c 
/home/wookey/linaro/armv8/toolchain/raringnew/arm64-cross-toolchain-base-1.92/gcc/build/./gcc/xgcc -B/home/wookey/linaro/armv8/toolchain/raringnew/arm64-cross-toolchain-base-1.92/gcc/build/./gcc/ -B/usr/aarch64-linux-gnu/bin/ -B/usr/aarch64-linux-gnu/lib/ -isystem /usr/aarch64-linux-gnu/include -isystem /usr/aarch64-linux-gnu/sys-include    -g -O2 -O2  -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -fPIC -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -Dinhibit_libc  -fPIC -I. -I. -I../.././gcc -I../../../src/libgcc -I../../../src/libgcc/. -I../../../src/libgcc/../gcc -I../../../src/libgcc/../include  -DHAVE_CC_TLS  -o _fixsfdi.o -MT _fixsfdi.o -MD -MP -MF _fixsfdi.dep -DL_fixsfdi -c ../../../src/libgcc/libgcc2.c 
In file included from /usr/include/features.h:341:0,
                 from /usr/include/limits.h:26,
                 from /home/wookey/linaro/armv8/toolchain/raringnew/arm64-cross-toolchain-base-1.92/gcc/build/./gcc/include-fixed/limits.h:169,
                 from /home/wookey/linaro/armv8/toolchain/raringnew/arm64-cross-toolchain-base-1.92/gcc/build/./gcc/include-fixed/syslimits.h:7,
                 from /home/wookey/linaro/armv8/toolchain/raringnew/arm64-cross-toolchain-base-1.92/gcc/build/./gcc/include-fixed/limits.h:34,
                 from ../../../src/libgcc/libgcc2.c:1733:
/usr/include/stdc-predef.h:30:26: fatal error: bits/predefs.h: No such file or directory


The headers found are for the BUILD arch not the TARGET arch, and
because bits/* has been moved to the multiarch location this fails
anyway because the toolchain is not looking in multiarch locations at
this point (it shouldn't be looking for headers at all, but if it was
it should include the mulitarch arch-specific path too).

This has accidentally worked in the past (e.g in the quantal toolchain
bootstrap) because libc6-dev-i386 puts predefs.h into
/usr/include/bits/ (or at least leaves it there - this package owns
the driectory - nothing seems to own the files inside - this should
probably be the subject of another bug).

Fortunately we can avoid worrying about exactly whether the right
paths are being searched because in fact the limits.h inclusion itself
has become outdated.

The offending code is in libgcc2.c around 1733:
#if defined(L_fixunsxfsi) && LIBGCC2_HAS_XF_MODE
/* Reenable the normal types, in case limits.h needs them. */
#undef char
#undef short
#undef int
#undef long
#undef unsigned
#undef float
#undef double
#undef MIN
#undef MAX
#include <limits.h>

UWtype
__fixunsxfSI (XFtype a)
{
  if (a >= - (DFtype) Wtype_MIN)
    return (Wtype) (a + Wtype_MIN) - Wtype_MIN;
  return (Wtype) a;
}
#endif

That inclusion of limits.h was there because the function __fixunsxfSI used to use LONG_MIN from that headers file, but this was changed a while back (http://repo.or.cz/w/official-gcc.git/blobdiff/49f0f270673c4512c11f72a038b84c321ae5534a..7429c938827aa98bf3b02c4ac89510f4d28ef0b1:/gcc/libgcc2.c)
to use Wtype_MIN instead, which is defined in the local libgcc2.h header.

so in fact the limits.h inclusion is no longer needed.



-- System Information:
Debian Release: 6.0.6
  APT prefers stable
  APT policy: (990, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.32.33-kvm-i386-20111128-dirty (SMP w/1 CPU core)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
--- gcc-4.7-4.7.2/debian/patches/libgcc2-128bit-remove-limits-header.diff	1970-01-01 01:00:00.000000000 +0100
+++ arm64-cross-toolchain-base-1.92/gcc/debian/patches/libgcc2-128bit-remove-limits-header.diff	2012-12-18 16:31:55.000000000 +0000
@@ -0,0 +1,61 @@
+Index: gcc/src/libgcc/libgcc2.c
+===================================================================
+--- gcc.orig/src/libgcc/libgcc2.c	2011-11-02 15:26:35.000000000 +0000
++++ gcc/src/libgcc/libgcc2.c	2012-12-18 16:26:50.000000000 +0000
+@@ -1676,18 +1676,6 @@
+ #endif
+ 
+ #if defined(L_fixunsxfsi) && LIBGCC2_HAS_XF_MODE
+-/* Reenable the normal types, in case limits.h needs them.  */
+-#undef char
+-#undef short
+-#undef int
+-#undef long
+-#undef unsigned
+-#undef float
+-#undef double
+-#undef MIN
+-#undef MAX
+-#include <limits.h>
+-
+ UWtype
+ __fixunsxfSI (XFtype a)
+ {
+@@ -1698,18 +1686,6 @@
+ #endif
+ 
+ #if defined(L_fixunsdfsi) && LIBGCC2_HAS_DF_MODE
+-/* Reenable the normal types, in case limits.h needs them.  */
+-#undef char
+-#undef short
+-#undef int
+-#undef long
+-#undef unsigned
+-#undef float
+-#undef double
+-#undef MIN
+-#undef MAX
+-#include <limits.h>
+-
+ UWtype
+ __fixunsdfSI (DFtype a)
+ {
+@@ -1720,18 +1696,6 @@
+ #endif
+ 
+ #if defined(L_fixunssfsi) && LIBGCC2_HAS_SF_MODE
+-/* Reenable the normal types, in case limits.h needs them.  */
+-#undef char
+-#undef short
+-#undef int
+-#undef long
+-#undef unsigned
+-#undef float
+-#undef double
+-#undef MIN
+-#undef MAX
+-#include <limits.h>
+-
+ UWtype
+ __fixunssfSI (SFtype a)
+ {
--- gcc-4.7-4.7.2/debian/rules.patch	2012-12-12 10:30:37.000000000 +0000
+++ arm64-cross-toolchain-base-1.92/gcc/debian/rules.patch	2012-12-18 17:39:14.000000000 +0000
@@ -86,6 +85,9 @@
 	pr54411 \
 	hurd-pthread \
 	pr54974 \
+	libgo-testsuite \
+	cross-build-fixes \
+	libgcc2-128bit-remove-limits-header \
 
 #	$(if $(filter yes, $(DEB_CROSS)),,gcc-print-file-name) \
 #	libstdc++-nothumb-check \

Reply to: