GCC build fails at ch 6.12

Ben DiDonc ben.didonc at gmail.com
Sat Jan 20 17:01:26 PST 2007


Hi everyone,
I m having a go at LFS (v6.2) and everything went smoothly until I got
to chapter 6.12 (GCC build).
I applied the various sed substitutions, ran configure and got to the
"make" command. Everything compiles fine for about 3 SBUs and then it
fails with:

/sources/gcc-build-pass3/gcc/xgcc -B/sources/gcc-build-pass3/gcc/
-B/usr/i686-pc-linux-gnu/bin/ -B/usr/i686-pc-linux-gnu/lib/ -isystem
/usr/i686-pc-linux-gnu/include -isystem
/usr/i686-pc-linux-gnu/sys-include -O2 -DIN_GCC    -W -Wall
-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes
-Wold-style-definition  -isystem ./include  -I. -I.
-I../../gcc-4.0.3/gcc -I../../gcc-4.0.3/gcc/.
-I../../gcc-4.0.3/gcc/../include
-I../../gcc-4.0.3/gcc/../libcpp/include   -g0 -finhibit-size-directive
-fno-inline-functions -fno-exceptions -fno-zero-initialized-in-bss
-fno-unit-at-a-time -fno-omit-frame-pointer \
   -c ../../gcc-4.0.3/gcc/crtstuff.c -DCRT_BEGIN \
  -o crtbegin.o
In file included from ../../gcc-4.0.3/gcc/crtstuff.c:64:
../../gcc-4.0.3/gcc/tsystem.h:90:19: error: stdio.h: No such file or directory
../../gcc-4.0.3/gcc/tsystem.h:93:23: error: sys/types.h: No such file
or directory
../../gcc-4.0.3/gcc/tsystem.h:96:19: error: errno.h: No such file or directory
../../gcc-4.0.3/gcc/tsystem.h:103:20: error: string.h: No such file or directory
../../gcc-4.0.3/gcc/tsystem.h:104:20: error: stdlib.h: No such file or directory
../../gcc-4.0.3/gcc/tsystem.h:105:20: error: unistd.h: No such file or directory
In file included from /sources/gcc-build-pass3/gcc/include/syslimits.h:7,
                 from /sources/gcc-build-pass3/gcc/include/limits.h:11,
                 from ../../gcc-4.0.3/gcc/tsystem.h:108,
                 from ../../gcc-4.0.3/gcc/crtstuff.c:64:
/sources/gcc-build-pass3/gcc/include/limits.h:122:61: error: limits.h:
No such file or directory
In file included from ../../gcc-4.0.3/gcc/crtstuff.c:64:
../../gcc-4.0.3/gcc/tsystem.h:111:18: error: time.h: No such file or directory
make[1]: *** [crtbegin.o] Error 1
make[1]: Leaving directory `/sources/gcc-build-pass3/gcc'
make: *** [all-gcc] Error 2


Now google and the mailing list being my friends, I read many threads
about people having similar problems. The most common answer was "the
linux-libc headers are missing". In my case, they ARE installed (as
per ch 6.7) in /usr/include as well as in /tools/include.

I have no idea as to why the compile fails because the supposedly
missing headers are at least in one standard location (/usr/include).

So I created a dummy.c:
#include "stdio.h"
main(){}

and tried compiling it with "cc dummy.c -v -Wl,--verbose". It
succeeded with the important bit in the output being:

#include "..." search starts here:
#include <...> search starts here:
 /tools/include
 /tools/lib/gcc/i686-pc-linux-gnu/4.0.3/include
End of search list.

I figured the problem was somewhere else. By looking at the command
which generated the error, I figured the compiler used in this case
was /sources/gcc-build-pass3/gcc/xgcc (not /tools/bin/cc as used to
compile my dummy.c). So i decided to compile dummy.c with xgcc instead
to see what happens:

root:/sources/gcc-build-pass3/gcc# ./xgcc ../dummy.c -v -Wl,--verbose
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.0.3/configure --prefix=/usr
--libexecdir=/usr/lib --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --enable-languages=c,c++
Thread model: posix
gcc version 4.0.3
 cc1 -quiet -v -iprefix
/sources/gcc-build-pass3/gcc/../lib/gcc/i686-pc-linux-gnu/4.0.3/
../dummy.c -quiet -dumpbase dummy.c -mtune=pentiumpro -auxbase dummy
-version -o /tmp/ccDUnTxI.s
xgcc: installation problem, cannot exec 'cc1': No such file or directory

xgcc cannot find cc1 because it s not in the PATH (but it is in the
current directory .). So I copied/pasted the cc1 command:

root:/sources/gcc-build-pass3/gcc# ./cc1 -quiet -v -iprefix
/sources/gcc-build-pass3/gcc/../lib/gcc/i686-pc-linux-gnu/4.0.3/
../dummy.c -quiet -dumpbase dummy.c -mtune=pentiumpro -auxbase dummy
-version -o /tmp/ccDUnTxI.s
ignoring nonexistent directory
"/sources/gcc-build-pass3/gcc/../lib/gcc/i686-pc-linux-gnu/4.0.3/include"
ignoring nonexistent directory
"/sources/gcc-build-pass3/gcc/../lib/gcc/i686-pc-linux-gnu/4.0.3/../../../../i686-pc-linux-gnu/include"
ignoring nonexistent directory "/usr/lib/gcc/i686-pc-linux-gnu/4.0.3/include"
ignoring nonexistent directory "/usr/lib/../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
End of search list.
GNU C version 4.0.3 (i686-pc-linux-gnu)
        compiled by GNU C version 4.0.3.
GGC heuristics: --param ggc-min-expand=60 --param ggc-min-heapsize=56358
../dummy.c:1:19: error: stdio.h: No such file or directory

And there it is the cause of the problem: the headers are NOT searched
in /usr/include, but in other dirs, including /usr/local/include and
/usr/i686-pc-linux-gnu/include

I decided to symlink /usr/i686-pc-linux-gnu/include to /usr/include
(after mkdir /usr/i686-pc-linux-gnu) and I finally managed to build
gcc.

Now, I have a few questions:
What is xgcc and why is it used instead of cc ?
Why doesnt xgcc look for and find the headers in /usr/include ? Is it
something I missed in some previous chapter ?

Anyway, I m really enjoying building my LFS system. Great book ,
congrats to the authors !
And thanks for enlightening me on the above points !

Ben



More information about the lfs-support mailing list