%general-entities; ]> Cross GCC-&gcc-version; - Static GCC cross tools, static Installation of Cross GCC Compiler with Static libgcc and no Threads Here we will compile GCC, as a cross-compiler that will create executables for our target architecture, statically so that it will not need to look for Glibc's startfiles, which do not yet exist in /tools. We will use this cross-compiler, plus the cross-linker we have just installed with Binutils, to compile Glibc. After Glibc is installed into /tools, we can rebuild GCC so that it will then be able to build executables that link against the libraries in /tools. Make a couple of essential adjustments to GCC's specs to ensure GCC uses our build environment: patch -Np1 -i ../&gcc-specs-patch; Change the StartFile Spec so that GCC looks in /tools: echo -en '\n#undef STANDARD_STARTFILE_PREFIX_1\n#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"\n' >> gcc/config/linux.h echo -en '\n#undef STANDARD_STARTFILE_PREFIX_2\n#define STANDARD_STARTFILE_PREFIX_2 ""\n' >> gcc/config/linux.h We will create a dummy limits.h so the build will not use the one provided by the host distro: touch /tools/include/limits.h AR=ar LDFLAGS="-Wl,-rpath,/cross-tools/lib" \ ../gcc-&gcc-version;/configure --prefix=/cross-tools \ --build=${CLFS_HOST} --host=${CLFS_HOST} --target=${CLFS_TARGET} \ --with-sysroot=${CLFS} --with-local-prefix=/tools \ --with-native-system-header-dir=/tools/include --disable-nls \ --disable-shared --with-mpfr=/cross-tools --with-gmp=/cross-tools \ --with-isl=/cross-tools --with-cloog=/cross-tools --with-mpc=/cross-tools \ --without-headers --with-newlib --disable-decimal-float --disable-libgomp \ --disable-libmudflap --disable-libssp --disable-libatomic --disable-libitm \ --disable-libsanitizer --disable-libquadmath --disable-threads \ --disable-multilib --disable-target-zlib --with-system-zlib \ --enable-languages=c --enable-checking=release The meaning of the new configure options: --build This specifies the system on which the cross-compiler is being built. --with-local-prefix=/tools The purpose of this switch is to remove /usr/local/include from gcc's include search path. This is not absolutely essential, however, it helps to minimize the influence of the host system. --with-native-system-headers-dir=/tools/include This switch ensures that GCC will search for the system headers in /tools/include and that host system headers will not be searched. --disable-shared This tells GCC not to create a shared library. --without-headers Disables GCC from using the target's Libc when cross compiling. --with-newlib This causes GCC to enable the inhibit_libc flag, which prevents libgcc from building code that uses libc support. --disable-decimal-float Disables support for the C decimal floating point extension. --disable-lib* These options prevent GCC from building a number of libraries that are not needed at this time. --disable-threads This will prevent GCC from looking for the multi-thread include files, since they haven't been created for this architecture yet. GCC will be able to find the multi-thread information after the Glibc headers are created. --disable-target-zlib This tells GCC not to build the copy of Zlib in its source tree. --with-system-zlib This tells GCC to link to the system-installed zlib instead of the one in its source tree. --enable-languages=c This option ensures that only the C compiler is built. --enable-checking=release This option selects the complexity of the internal consistency checks and adds error checking within the compiler. Continue with compiling the package: make all-gcc all-target-libgcc The meaning of the new make options: all-gcc all-target-libgcc Compiles only the parts of GCC that are needed at this time, rather than the full package. Install the package: make install-gcc install-target-libgcc <para>Details on this package are located in <xref linkend="contents-gcc" role="."/></para> </sect2> </sect1>