patches/gcc/4.0.1/100-fix-fixincl.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Apr 26 21:31:05 2008 +0000 (2008-04-26)
changeset 454 372b2f397baa
permissions -rw-r--r--
Configure tsocks with a simple heuristic.

Consider the proxy has to be in a 'local' network. It means it is directly
reachable by the local machine, even if the local machine has to hop through
one or more gates to reach the proxy (often the case in enterprise networks
where class A 10.0.0.0/8 is in fact sub-divided into smaller networks, each
one of them in a different location, eg. 10.1.0.0/16 in a place, while
10.2.0.0/16 would be on the other side of the world). Not being in the same
subnet does not mean the proxy is not available.

So we will build a mask with at most high bits set, which defines a network
that has both the local machine and the proxy. Because a machine may have
more than one interface, build a mask for each of them, removing 127.0.0.1
which is added automagically by tsocks, and removing duplicate masks.

If all of this does not work, then it means the local machine can NOT in fact
reach the proxy, which in turn means the user mis-configured something (most
probably a typo...).

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