patches/gcc/4.0.1/100-fix-fixincl.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Jan 31 17:49:27 2009 +0000 (2009-01-31)
changeset 1183 268544004e77
permissions -rw-r--r--
On 20090131.1659+0100, Vincent Sanders <vince@kyllikki.org> wrote:
[This]patch is a bit more involved. The patch addresses a gcc
regression in the 4.3 series (specifically this patch is against 4.3.2
which does *not* have a lot of other issues which affect kernel building)

GCC bug tracker has this issue as
#38453 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38453
#32044 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32044

comment 65 of #32044 has the fix being applied to gcc trunk as revision #142719

The attached patch is a backport to gcc 4.3.2 which allows this
version to be used to generate correct output for various ARM kernel
build (and indeed is teh correct answer in general).

/trunk/patches/gcc/4.3.2/360-fix-expensive-optimize.patch | 207 207 0 0 +++++++++++++++++++++
1 file changed, 207 insertions(+)
     1 See http://gcc.gnu.org/PR22541
     2 
     3 From: Dan Kegel
     4 
     5 When building gcc-3.4.3 or gcc-4.0.[01] into a clean $PREFIX (the only two I've tried like this),
     6 the configure script happily copies the glibc include files from include to sys-include;
     7 here's the line from the log file (with $PREFIX instead of the real prefix):
     8 
     9 Copying $PREFIX/i686-unknown-linux-gnu/include to $PREFIX/i686-unknown-linux-gnu/sys-include
    10 
    11 But later, when running fixincludes, it gives the error message
    12  The directory that should contain system headers does not exist:
    13   $PREFIX/lib/gcc/i686-unknown-linux-gnu/3.4.3/../../../../i686-unknown-linux-gnu/sys-include
    14 
    15 Nevertheless, it continues building; the header files it installs in
    16  $PREFIX/lib/gcc/i686-unknown-linux-gnu/3.4.3/include
    17 do not include the boilerplate that would cause it to #include_next the
    18 glibc headers in the system header directory.
    19 Thus the resulting toolchain can't compile the following program:
    20 #include <limits.h>
    21 int x = PATH_MAX;
    22 because its limits.h doesn't include the glibc header.
    23 
    24 That's not nice.  I suspect the problem is that gcc/Makefile.in assumes that
    25 it can refer to $PREFIX/i686-unknown-linux-gnu  with the path 
    26                 $PREFIX/lib/../i686-unknown-linux-gnu, but
    27 that fails because the directory $PREFIX/lib doesn't exist during 'make all';
    28 it is only created later, during 'make install'.  (Which makes this problem
    29 confusing, since one only notices the breakage well after 'make install',
    30 at which point the path configure complained about does exist, and has the
    31 right stuff in it.)
    32 
    33 A possible fix is to replace the line in gcc/Makefile.in that says
    34     SYSTEM_HEADER_DIR = @SYSTEM_HEADER_DIR@
    35 with a version that gets rid of extra ..'s, e.g.
    36     SYSTEM_HEADER_DIR = `echo @SYSTEM_HEADER_DIR@ | sed -e :a -e "s,[^/]*/\.\.\/,,;ta"`
    37 (hey, that's the first time I've ever used a label in a sed script; thanks to the sed faq
    38 for explaining the :a ... ta method of looping to repeat a search-and-replace until it doesn't match.)
    39 
    40 [rediffed against gcc-4.0.0]
    41 
    42 --- gcc-4.0.0/gcc/Makefile.in.orig	2005-04-04 12:45:13.000000000 -0700
    43 +++ gcc-4.0.0/gcc/Makefile.in	2005-05-20 12:33:43.000000000 -0700
    44 @@ -378,7 +378,10 @@
    45  CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@
    46  
    47  # autoconf sets SYSTEM_HEADER_DIR to one of the above.
    48 -SYSTEM_HEADER_DIR = @SYSTEM_HEADER_DIR@
    49 +# Purge it of unneccessary internal relative paths
    50 +# to directories that might not exist yet.
    51 +# The sed idiom for this is to repeat the search-and-replace until it doesn't match, using :a ... ta.
    52 +SYSTEM_HEADER_DIR = `echo @SYSTEM_HEADER_DIR@ | sed -e :a -e "s,[^/]*/\.\.\/,," -e ta`
    53  
    54  # Control whether to run fixproto and fixincludes.
    55  STMP_FIXPROTO = @STMP_FIXPROTO@
    56 @@ -2838,13 +2841,15 @@
    57  ../$(build_subdir)/fixincludes/fixincl: ; @ :
    58  
    59  # Build fixed copies of system files.
    60 +# Abort if no system headers available, unless building a crosscompiler.
    61 +# FIXME: abort unless building --without-headers would be more accurate and less ugly
    62  stmp-fixinc: gsyslimits.h macro_list \
    63    ../$(build_subdir)/fixincludes/fixincl \
    64    ../$(build_subdir)/fixincludes/fixinc.sh
    65  	@if test ! -d ${SYSTEM_HEADER_DIR}; then \
    66  	  echo The directory that should contain system headers does not exist: >&2 ; \
    67  	  echo "  ${SYSTEM_HEADER_DIR}" >&2 ; \
    68 -	  if test "x${SYSTEM_HEADER_DIR}" = "x${gcc_tooldir}/sys-include"; \
    69 +	  if test "x${SYSTEM_HEADER_DIR}" = "x`echo "${gcc_tooldir}/sys-include" | sed -e :a -e "s,[^/]*/\.\.\/,," -e ta`"; \
    70  	  then sleep 1; else exit 1; fi; \
    71  	fi
    72  	rm -rf include; mkdir include