Hi Christer, thankyou very much for your help. I have tested your changes: For binutils 2.26: $ configure --prefix=/opt/rpi --with-sysroot=/opt/rpi/sysroot --disable.nls --target=arm-linux-gnueabihf --disable-multilib $ make $ make install For stage 1 of gcc 7.2.0: $ configure --prefix=/opt/rpi --target=arm-linux-gnueabihf --enable-languages=c --without-headers --disable-nls --disable-multilib --disable-threads --disable-shared $ make all-gcc all-target-libgcc $ make install-gcc install-target-libgcc For linux kernel headers (following your suggestion): $ cd linux $ make headers_install ARCH=arm INSTALL_HDR_PATH=/opt/rpi/sysroot For glibc 2.29 (following your suggestion): $ configure --prefix=/usr --host=arm-linux-gnueabihf --with-headers=/opt/rpi/sysroot/include --disable-multilib $ make $ make install DESTDIR=/opt/rpi/sysroot Until this point everyting ok (I realized that now /opt/rpi/sysroot is populated with /usr and the rest of standard folders and with include files). The problem arises when compiling stage 2 of gcc using the modifications you suggested (I use separated build folders for stages 1 and 2): $ configure --prefix=/opt/rpi --target=arm-linux-gnueabihf --enable-languages=c,c++ --disable-nls --disable-multilib --with-sysroot=/opt/rpi/sysroot $ make The process terminates with the following output: /opt/rpi/build/gcc-7.2.0-final/./gcc/xgcc -B/opt/rpi/build/gcc-7.2.0-final/./gcc/ -B/opt/rpi/arm-linux-gnueabihf/bin/ -B/opt/rpi/arm-linux-gnueabihf/lib/ -isystem /opt/rpi/arm-linux-gnueabihf/include -isystem /opt/rpi/arm-linux-gnueabihf/sys-include -g -O2 -O2 -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fPIC -fno-inline -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -fPIC -fno-inline -I. -I. -I../.././gcc -I../../../../src/gcc-7.2.0/libgcc -I../../../../src/gcc-7.2.0/libgcc/. -I../../../../src/gcc-7.2.0/libgcc/../gcc -I../../../../src/gcc-7.2.0/libgcc/../include -DHAVE_CC_TLS -o _muldi3.o -MT _muldi3.o -MD -MP -MF _muldi3.dep -DL_muldi3 -c ../../../../src/gcc-7.2.0/libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS In file included from /opt/rpi/sysroot/usr/include/errno.h:28:0, from ../../../../src/gcc-7.2.0/libgcc/../gcc/tsystem.h:93, from ../../../../src/gcc-7.2.0/libgcc/libgcc2.c:27: /opt/rpi/sysroot/usr/include/bits/errno.h:26:11: fatal error: linux/errno.h: No such file or directory # include <linux/errno.h> Any idea or suggestion? Thanks! 2017-08-16 12:09 GMT+01:00 Christer Solskogen <christer.solskogen@xxxxxxxxx>: > On 16-Aug-17 12:52, Avelino Herrera Morales wrote: >> >> Hi all, >> >> I am attempting to build the binutils/gcc/glibc toolchain to build a >> cross compiled Linux from scratch for my Raspberry Pi. I succesfully >> have compiled binutils, stage 1 of gcc and glibc: >> >> For binutils 2.29: >> $ configure --prefix=/opt/rpi --disable.nls >> --target=arm-linux-gnueabihf --disable-multilib >> $ make >> $ make install >> >> For gcc 7.2.0 (stage 1): >> $ export PATH=/opt/rpi/bin:${PATH} >> $ configure --prefix=/opt/rpi --target=arm-linux-gnueabihf >> --enable-languages=c --without-headers --disable-nls >> --disable-multilib --disable-threads --disable-shared >> $ make all-gcc all-target-libgcc >> $ make install-gcc install-target-libgcc >> >> Get current kernel headers: >> $ cd /opt/rpi/src >> $ git clone https://github.com/raspberrypi/linux.git >> $ cd linux >> $ make headers_install ARCH=arm >> INSTALL_HDR_PATH=/opt/rpi/src/kernel-headers >> > > Don't do that that way. > Install the kernel headers in in sysroot like this: > /opt/rpi/sysroot > >> For glibc 2.26: >> $ configure --prefix=/opt/rpi --host=arm-linux-gnueabihf >> --with-headers=/opt/rpi/src/kernel-headers/include --disable-multilib >> $ make >> $ make install >> > > Use --prefix=/usr and --with-headers=/opt/rpi/sysroot. Then use make install > DESTDIR="/opt/rpi/sysroot" > > >> Until here all is ok, but I am a bit confused about how to compile >> stage 2 of gcc. I have tested some configurations (found all over the >> internet) but no one compiles ok the stage 2. >> >> Any idea for how to compile the stage 2? I guess I should use the >> "--with-sysroot" configuration option but I don't understand it. >> > > IIRC --with-sysroot=/opt/rpi/sysroot should be used on both stage2 of gcc > and binutils. > > > -- > chs > -- Avelino Herrera Morales http://avelino.atlantes.org https://twitter.com/avelinohm https://facebook.com/avelinoherrera https://plus.google.com/+AvelinoHerreraMorales