patches/gcc/4.1.0/100-gcc-4.1-fix-fixincl.patch
changeset 746 b150d6f590fc
parent 745 e445c00d134d
child 747 d3e603e7c17c
     1.1 --- a/patches/gcc/4.1.0/100-gcc-4.1-fix-fixincl.patch	Mon Jul 28 20:17:48 2008 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,71 +0,0 @@
     1.4 -See http://gcc.gnu.org/PR22541
     1.5 -
     1.6 -From: Dan Kegel
     1.7 -
     1.8 -When building gcc-3.4.3 or gcc-4.x into a clean $PREFIX,
     1.9 -the configure script happily copies the glibc include files from include to sys-include;
    1.10 -here's the line from the log file (with $PREFIX instead of the real prefix):
    1.11 -
    1.12 -Copying $PREFIX/i686-unknown-linux-gnu/include to $PREFIX/i686-unknown-linux-gnu/sys-include
    1.13 -
    1.14 -But later, when running fixincludes, it gives the error message
    1.15 - The directory that should contain system headers does not exist:
    1.16 -  $PREFIX/lib/gcc/i686-unknown-linux-gnu/3.4.3/../../../../i686-unknown-linux-gnu/sys-include
    1.17 -
    1.18 -Nevertheless, it continues building; the header files it installs in
    1.19 - $PREFIX/lib/gcc/i686-unknown-linux-gnu/3.4.3/include
    1.20 -do not include the boilerplate that would cause it to #include_next the
    1.21 -glibc headers in the system header directory.
    1.22 -Thus the resulting toolchain can't compile the following program:
    1.23 -#include <limits.h>
    1.24 -int x = PATH_MAX;
    1.25 -because its limits.h doesn't include the glibc header.
    1.26 -
    1.27 -The problem is that gcc/Makefile.in assumes that
    1.28 -it can refer to $PREFIX/i686-unknown-linux-gnu  with the path
    1.29 -                $PREFIX/lib/../i686-unknown-linux-gnu, but
    1.30 -that fails because the directory $PREFIX/lib doesn't exist during 'make all';
    1.31 -it is only created later, during 'make install'.  (Which makes this problem
    1.32 -confusing, since one only notices the breakage well after 'make install',
    1.33 -at which point the path configure complained about does exist, and has the
    1.34 -right stuff in it.)
    1.35 -
    1.36 -A fix that I've been using for a while is to use sed to canonicalize
    1.37 -the path.  The sed syntax is a bit obtuse, but it works. 
    1.38 -
    1.39 -(hey, that's the first time I've ever used a label in a sed script; thanks to the sed faq
    1.40 -for explaining the :a ... ta method of looping to repeat a search-and-replace until it doesn't match.)
    1.41 -
    1.42 -[rediffed against gcc-4.1-20060210]
    1.43 -
    1.44 ---- gcc-4.1-20060210/gcc/Makefile.in.old	2006-01-11 06:29:29.000000000 -0800
    1.45 -+++ gcc-4.1-20060210/gcc/Makefile.in	2006-02-14 16:08:54.000000000 -0800
    1.46 -@@ -388,7 +388,10 @@
    1.47 - CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@
    1.48 - 
    1.49 - # autoconf sets SYSTEM_HEADER_DIR to one of the above.
    1.50 --SYSTEM_HEADER_DIR = @SYSTEM_HEADER_DIR@
    1.51 -+# Purge it of unneccessary internal relative paths
    1.52 -+# to directories that might not exist yet.
    1.53 -+# The sed idiom for this is to repeat the search-and-replace until it doesn't match, using :a ... ta.
    1.54 -+SYSTEM_HEADER_DIR = `echo @SYSTEM_HEADER_DIR@ | sed -e :a -e "s,[^/]*/\.\.\/,," -e ta`
    1.55 - 
    1.56 - # Control whether to run fixproto and fixincludes.
    1.57 - STMP_FIXPROTO = @STMP_FIXPROTO@
    1.58 -@@ -3167,13 +3170,15 @@
    1.59 - ../$(build_subdir)/fixincludes/fixincl: ; @ :
    1.60 - 
    1.61 - # Build fixed copies of system files.
    1.62 -+# Abort if no system headers available, unless building a crosscompiler.
    1.63 -+# Canonicalize $gcc_tooldir/sys-include in same way as $SYSTEM_HEADER_DIR was canonicalized so test still works
    1.64 - stmp-fixinc: gsyslimits.h macro_list \
    1.65 -   $(build_objdir)/fixincludes/fixincl \
    1.66 -   $(build_objdir)/fixincludes/fixinc.sh
    1.67 - 	@if ! $(inhibit_libc) && test ! -d ${SYSTEM_HEADER_DIR}; then \
    1.68 - 	  echo The directory that should contain system headers does not exist: >&2 ; \
    1.69 - 	  echo "  ${SYSTEM_HEADER_DIR}" >&2 ; \
    1.70 --	  if test "x${SYSTEM_HEADER_DIR}" = "x${gcc_tooldir}/sys-include"; \
    1.71 -+	  if test "x${SYSTEM_HEADER_DIR}" = "x`echo "${gcc_tooldir}/sys-include" | sed -e :a -e "s,[^/]*/\.\.\/,," -e ta`"; \
    1.72 - 	  then sleep 1; else exit 1; fi; \
    1.73 - 	fi
    1.74 - 	rm -rf include; mkdir include