GCC build fails at ch 6.12

Dan Nicholson dbn.lists at gmail.com
Sat Jan 20 17:20:30 PST 2007


On 1/20/07, Ben DiDonc <ben.didonc at gmail.com> wrote:
> 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

It's looking for and not finding the glibc headers. Do you have
/usr/include/stdio.h? If so, then something has gone wrong with the
toolchain adjustment or gcc-pass2 build in Ch. 5 because xgcc isn't
looking in the right place.

> 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.

Nice job on the debugging. However, this is with /tools/bin/gcc, so
this search should find stdio.h in /tools/include.

> 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:

Not quite. Gcc follows an internal path to find stuff like cc1. The
gcc build adds some magic -B parameters so it can find the freshly
built cc1 during the build.

> 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

That's not good. IIRC, it should be looking in /usr/include.

[ 5:13 PM dan at conor] /usr/lib/gcc/i686-pc-linux-gnu/4.0.3/cc1 -v <<< ' '
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory
"/usr/lib/gcc/i686-pc-linux-gnu/4.0.3/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/i686-pc-linux-gnu/4.0.3/include
 /usr/include
End of search list.

> Now, I have a few questions:
> What is xgcc and why is it used instead of cc ?

xgcc is a temporary gcc used during the build of gcc itself. Since
you're compiling a compiler, it bootstraps itself to not be polluted
by the initial compiler.

> Why doesnt xgcc look for and find the headers in /usr/include ? Is it
> something I missed in some previous chapter ?

That's a good question. My guess is the answer is in the Ch. 5
toolchain adjustment or gcc-pass2. However, I think I recall that one
of the local gurus Greg Schafer pointed out that we never actually
make gcc look in /usr/include, and that's one of the last points of
toolchain purity. So, maybe xgcc should be looking for
/tools/include/stdio.h, which would come from the glibc in Ch. 5. Do
you have /tools/include/stdio.h?

Wait. Did you pass --libexecdir=/usr/lib to the build? It seems like
it really wants to look in /usr/i686-pc-linux-gnu, but we explicitly
nip that in the bud by passing --libexecdir.

--
Dan



More information about the lfs-support mailing list