yann@402: See http://gcc.gnu.org/PR22541 yann@402: yann@402: From: Dan Kegel yann@402: yann@402: When building gcc-3.4.3 or gcc-4.x into a clean $PREFIX, yann@402: the configure script happily copies the glibc include files from include to sys-include; yann@402: here's the line from the log file (with $PREFIX instead of the real prefix): yann@402: yann@402: Copying $PREFIX/i686-unknown-linux-gnu/include to $PREFIX/i686-unknown-linux-gnu/sys-include yann@402: yann@402: But later, when running fixincludes, it gives the error message yann@402: The directory that should contain system headers does not exist: yann@402: $PREFIX/lib/gcc/i686-unknown-linux-gnu/3.4.3/../../../../i686-unknown-linux-gnu/sys-include yann@402: yann@402: Nevertheless, it continues building; the header files it installs in yann@402: $PREFIX/lib/gcc/i686-unknown-linux-gnu/3.4.3/include yann@402: do not include the boilerplate that would cause it to #include_next the yann@402: glibc headers in the system header directory. yann@402: Thus the resulting toolchain can't compile the following program: yann@402: #include yann@402: int x = PATH_MAX; yann@402: because its limits.h doesn't include the glibc header. yann@402: yann@402: The problem is that gcc/Makefile.in assumes that yann@402: it can refer to $PREFIX/i686-unknown-linux-gnu with the path yann@402: $PREFIX/lib/../i686-unknown-linux-gnu, but yann@402: that fails because the directory $PREFIX/lib doesn't exist during 'make all'; yann@402: it is only created later, during 'make install'. (Which makes this problem yann@402: confusing, since one only notices the breakage well after 'make install', yann@402: at which point the path configure complained about does exist, and has the yann@402: right stuff in it.) yann@402: yann@402: A fix that I've been using for a while is to use sed to canonicalize yann@402: the path. The sed syntax is a bit obtuse, but it works. yann@402: yann@402: (hey, that's the first time I've ever used a label in a sed script; thanks to the sed faq yann@402: for explaining the :a ... ta method of looping to repeat a search-and-replace until it doesn't match.) yann@402: yann@402: [rediffed against gcc-4.1-20060210] yann@402: yann@402: --- gcc-4.1-20060210/gcc/Makefile.in.old 2006-01-11 06:29:29.000000000 -0800 yann@402: +++ gcc-4.1-20060210/gcc/Makefile.in 2006-02-14 16:08:54.000000000 -0800 yann@402: @@ -388,7 +388,10 @@ yann@402: CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@ yann@402: yann@402: # autoconf sets SYSTEM_HEADER_DIR to one of the above. yann@402: -SYSTEM_HEADER_DIR = @SYSTEM_HEADER_DIR@ yann@402: +# Purge it of unneccessary internal relative paths yann@402: +# to directories that might not exist yet. yann@402: +# The sed idiom for this is to repeat the search-and-replace until it doesn't match, using :a ... ta. yann@402: +SYSTEM_HEADER_DIR = `echo @SYSTEM_HEADER_DIR@ | sed -e :a -e "s,[^/]*/\.\.\/,," -e ta` yann@402: yann@402: # Control whether to run fixproto and fixincludes. yann@402: STMP_FIXPROTO = @STMP_FIXPROTO@ yann@402: @@ -3167,13 +3170,15 @@ yann@402: ../$(build_subdir)/fixincludes/fixincl: ; @ : yann@402: yann@402: # Build fixed copies of system files. yann@402: +# Abort if no system headers available, unless building a crosscompiler. yann@402: +# Canonicalize $gcc_tooldir/sys-include in same way as $SYSTEM_HEADER_DIR was canonicalized so test still works yann@402: stmp-fixinc: gsyslimits.h macro_list \ yann@402: $(build_objdir)/fixincludes/fixincl \ yann@402: $(build_objdir)/fixincludes/fixinc.sh yann@402: @if ! $(inhibit_libc) && test ! -d ${SYSTEM_HEADER_DIR}; then \ yann@402: echo The directory that should contain system headers does not exist: >&2 ; \ yann@402: echo " ${SYSTEM_HEADER_DIR}" >&2 ; \ yann@402: - if test "x${SYSTEM_HEADER_DIR}" = "x${gcc_tooldir}/sys-include"; \ yann@402: + if test "x${SYSTEM_HEADER_DIR}" = "x`echo "${gcc_tooldir}/sys-include" | sed -e :a -e "s,[^/]*/\.\.\/,," -e ta`"; \ yann@402: then sleep 1; else exit 1; fi; \ yann@402: fi yann@402: rm -rf include; mkdir include