https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87769
--- Comment #2 from Mateusz Zych <mte.zych at gmail dot com> --- Hi Andrew ;) Thanks for your reply. You are right that, in order to create standalone GCC, I need to provide C standard library, because GCC can work with various C standard library implementations. The GNU C Library (glibc) is just one implementation, which is not always used (for example Android is using bionic). To correct my script, I changed it to download and compile binutils, glibc and gcc respectively: # GNU Binutils wget https://ftp.gnu.org/gnu/binutils/binutils-2.31.tar.gz tar -xvf binutils-2.31.tar.gz mv binutils-2.31 binutils-source mkdir binutils-build cd binutils-build ../binutils-source/configure --build=x86_64-linux-gnu \ --host=x86_64-linux-gnu \ --target=x86_64-linux-gnu \ --prefix=$PWD/gcc \ --disable-multilib \ --disable-nls make -j 4 make install cd .. # GNU C Library (glibc) wget https://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.gz tar -xvf glibc-2.28.tar.gz mv glibc-2.28 glibc-source mkdir glibc-build cd glibc-build ../glibc-source/configure --build=x86_64-linux-gnu \ --host=x86_64-linux-gnu \ --target=x86_64-linux-gnu \ --prefix=$PWD/gcc \ --disable-multilib \ --disable-nls \ --disable-timezone-tools make -j 4 make install cd .. # GCC wget https://ftp.gnu.org/gnu/gcc/gcc-8.2.0/gcc-8.2.0.tar.gz tar -xvf gcc-8.2.0.tar.gz mv gcc-8.2.0 gcc-source cd gcc-source ./contrib/download_prerequisites cd .. mkdir gcc-build cd gcc-build ../gcc-source/configure --build=x86_64-linux-gnu \ --host=x86_64-linux-gnu \ --target=x86_64-linux-gnu \ --prefix=$PWD/gcc \ --enable-languages=c,c++ \ --disable-multilib \ --disable-nls make -j 4 make install cd .. This improved things, in a sense that, in my simple C++ application compiled using GCC build from source it includes only these headers from host machine: - /usr/include/asm-generic/errno-base.h - /usr/include/asm-generic/errno.h - /usr/include/linux/errno.h - /usr/include/x86_64-linux-gnu/asm/errno.h However, header files from host machine are still being included! This can be seen when listing include directories used by GCC build from source: /home/mzych/gcc/bin/../lib/gcc/x86_64-linux-gnu/8.2.0/../../../../include/c++/8.2.0 /home/mzych/gcc/bin/../lib/gcc/x86_64-linux-gnu/8.2.0/../../../../include/c++/8.2.0/x86_64-linux-gnu /home/mzych/gcc/bin/../lib/gcc/x86_64-linux-gnu/8.2.0/../../../../include/c++/8.2.0/backward /home/mzych/gcc/bin/../lib/gcc/x86_64-linux-gnu/8.2.0/include /home/mzych/gcc/bin/../lib/gcc/x86_64-linux-gnu/8.2.0/include-fixed ---> /usr/local/include /home/mzych/gcc/bin/../lib/gcc/../../include ---> /usr/include/x86_64-linux-gnu ---> /usr/include OK, maybe I'm completely wrong here, but I think that it would be great to introduce to GCC a configuration option, which would prevent GCC from using any headers and libraries from host machine. In this configuration, GCC would simply return compilation error in case where required header or library would not found in its own directory tree. BTW, I was searching for such an option, but I couldn't find it. - https://gcc.gnu.org/install/configure.html Thanks, Mateusz