diff options
author | Bruce Dubbs <bdubbs@linuxfromscratch.org> | 2020-06-16 11:56:28 +0000 |
---|---|---|
committer | Bruce Dubbs <bdubbs@linuxfromscratch.org> | 2020-06-16 11:56:28 +0000 |
commit | 675606bde2ba53946537b42a5aa576692a311621 (patch) | |
tree | af20c20ce3841c16b24d0b9903af6878a4a0f5a6 /chapter05/gcc-pass1.xml | |
parent | 560065f976e371779928dbf8b9428217f3f57331 (diff) | |
parent | 1cd59612d00603c9ce773ad821a15d20bc4fa0b7 (diff) |
Split Chapter 5 into three separate chapters.
Implement a new method of cross-building the LFS tool chain
and other tools to simplify the method of isolating the
new system from the original host. This will be the start of
LFS-10.0.
Move old trunk/BOOK to branches/old-trunk.
git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@11946 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689
Diffstat (limited to 'chapter05/gcc-pass1.xml')
-rw-r--r-- | chapter05/gcc-pass1.xml | 139 |
1 files changed, 37 insertions, 102 deletions
diff --git a/chapter05/gcc-pass1.xml b/chapter05/gcc-pass1.xml index d209cd44f..0cd852ee6 100644 --- a/chapter05/gcc-pass1.xml +++ b/chapter05/gcc-pass1.xml @@ -25,7 +25,7 @@ <title/> <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" - href="../chapter06/gcc.xml" + href="../chapter08/gcc.xml" xpointer="xpointer(/sect1/sect2[1]/para[1])"/> <segmentedlist> @@ -33,8 +33,8 @@ <segtitle>&diskspace;</segtitle> <seglistitem> - <seg>&gcc-ch5p1-sbu;</seg> - <seg>&gcc-ch5p1-du;</seg> + <seg>&gcc-tmpp1-sbu;</seg> + <seg>&gcc-tmpp1-du;</seg> </seglistitem> </segmentedlist> @@ -43,7 +43,7 @@ <sect2 role="installation"> <title>Installation of Cross GCC</title> - <para>GCC now requires the GMP, MPFR and MPC packages. As these packages may + <para>GCC requires the GMP, MPFR and MPC packages. As these packages may not be included in your host distribution, they will be built with GCC. Unpack each package into the GCC source directory and rename the resulting directories so the GCC build procedures will automatically @@ -62,42 +62,7 @@ mv -v gmp-&gmp-version; gmp tar -xf ../mpc-&mpc-version;.tar.gz mv -v mpc-&mpc-version; mpc</userinput></screen> - <para>The following command will change the location of GCC's default - dynamic linker to use the one installed in <filename - class="directory">/tools</filename>. It also removes <filename - class="directory">/usr/include</filename> from GCC's include search path. - Issue:</para> - -<screen><userinput remap="pre">for file in gcc/config/{linux,i386/linux{,64}}.h -do - cp -uv $file{,.orig} - sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \ - -e 's@/usr@/tools@g' $file.orig > $file - echo ' -#undef STANDARD_STARTFILE_PREFIX_1 -#undef STANDARD_STARTFILE_PREFIX_2 -#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/" -#define STANDARD_STARTFILE_PREFIX_2 ""' >> $file - touch $file.orig -done</userinput></screen> - - <para>In case the above seems hard to follow, let's break it down a bit. - First we copy the files <filename>gcc/config/linux.h</filename>, - <filename>gcc/config/i386/linux.h</filename>, and - <filename>gcc/config/i386/linux64.h</filename> to a file of - the same name but with an added suffix of <quote>.orig</quote>. Then the - first sed expression prepends <quote>/tools</quote> to every instance of - <quote>/lib/ld</quote>, <quote>/lib64/ld</quote> or - <quote>/lib32/ld</quote>, while the second one replaces hard-coded - instances of <quote>/usr</quote>. Next, we add our define statements which - alter the default startfile prefix to the end of the file. Note that the - trailing <quote>/</quote> in <quote>/tools/lib/</quote> is required. - Finally, we use <command>touch</command> to update the timestamp on the - copied files. When used in conjunction with <command>cp -u</command>, this - prevents unexpected changes to the original files in case the commands are - inadvertently run twice.</para> - - <para>Finally, on x86_64 hosts, set the default directory name for + <para>On x86_64 hosts, set the default directory name for 64-bit libraries to <quote>lib</quote>:</para> <screen><userinput remap="pre">case $(uname -m) in @@ -107,19 +72,6 @@ done</userinput></screen> ;; esac</userinput></screen> -<!-- - <para>GCC doesn't detect stack protection correctly, which causes problems - for the build of Glibc-&glibc-version;, so fix that by issuing the following - command:</para> - -<screen><userinput remap="pre">sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure</userinput></screen> ---> - -<!-- - <para>Also fix a problem identified upstream:</para> - -<screen><userinput remap="pre">sed -i 's/if \((code.*))\)/if (\1 \&\& \!DEBUG_INSN_P (insn))/' gcc/sched-deps.c</userinput></screen> ---> <para>The GCC documentation recommends building GCC in a dedicated build directory:</para> @@ -130,13 +82,12 @@ cd build</userinput></screen> <screen><userinput remap="configure">../configure \ --target=$LFS_TGT \ - --prefix=/tools \ + --prefix=$LFS/tools \ --with-glibc-version=2.11 \ --with-sysroot=$LFS \ --with-newlib \ --without-headers \ - --with-local-prefix=/tools \ - --with-native-system-header-dir=/tools/include \ + --enable-initfini-array \ --disable-nls \ --disable-shared \ --disable-multilib \ @@ -181,46 +132,39 @@ cd build</userinput></screen> </varlistentry> <varlistentry> - <term><parameter>--with-local-prefix=/tools</parameter></term> + <term><parameter>--enable-initfini-array</parameter></term> <listitem> - <para>The local prefix is the location in the system that GCC will search - for locally installed include files. The default is <filename>/usr/local</filename>. - Setting this to <filename>/tools</filename> helps keep the host location of - <filename>/usr/local</filename> out of this GCC's search path.</para> + <para>This switch forces the use of some internal data structures + that are needed but cannot be detected when building a cross + compiler.</para> </listitem> </varlistentry> <varlistentry> - <term><parameter>--with-native-system-header-dir=/tools/include</parameter></term> + <term><parameter>--disable-shared</parameter></term> <listitem> - <para>By default, GCC searches <filename>/usr/include</filename> for - system headers. In conjunction with the sysroot switch, this would - normally translate to <filename>$LFS/usr/include</filename>. However - the headers that will be installed in the next two sections will go - to <filename>$LFS/tools/include</filename>. This switch ensures that - gcc will find them correctly. In the second pass of GCC, this same - switch will ensure that no headers from the host system are - found.</para> + <para>This switch forces GCC to link its internal libraries + statically. We need this because the shared libraries require glibc, + which is not yet installed on the target system.</para> </listitem> </varlistentry> <varlistentry> - <term><parameter>--disable-shared</parameter></term> + <term><parameter>--disable-multilib</parameter></term> <listitem> - <para>This switch forces GCC to link its internal libraries - statically. We do this to avoid possible issues with the host - system.</para> + <para>On x86_64, LFS does not support a multilib configuration. + This switch is harmless for x86.</para> </listitem> </varlistentry> <varlistentry> <term><parameter>--disable-decimal-float, --disable-threads, - --disable-libatomic, --disable-libgomp, <!--- -disable-libmpx,--> + --disable-libatomic, --disable-libgomp, --disable-libquadmath, --disable-libssp, --disable-libvtv, --disable-libstdcxx</parameter></term> <listitem> <para>These switches disable support for the decimal floating point - extension, threading, libatomic, libgomp, <!--libmpx, --> libquadmath, libssp, + extension, threading, libatomic, libgomp, libquadmath, libssp, libvtv, and the C++ standard library respectively. These features will fail to compile when building a cross-compiler and are not necessary for the task of cross-compiling the temporary libc.</para> @@ -228,14 +172,6 @@ cd build</userinput></screen> </varlistentry> <varlistentry> - <term><parameter>--disable-multilib</parameter></term> - <listitem> - <para>On x86_64, LFS does not yet support a multilib configuration. - This switch is harmless for x86.</para> - </listitem> - </varlistentry> - - <varlistentry> <term><parameter>--enable-languages=c,c++</parameter></term> <listitem> <para>This option ensures that only the C and C++ compilers are built. @@ -249,26 +185,25 @@ cd build</userinput></screen> <screen><userinput remap="make">make</userinput></screen> - <para>Compilation is now complete. At this point, the test suite would - normally be run, but, as mentioned before, the test suite framework is - not in place yet. The benefits of running the tests at this point - are minimal since the programs from this first pass will soon be - replaced.</para> - <para>Install the package:</para> -<screen><userinput remap="install">make install</userinput></screen> -<!-- - <para>Using <parameter>- -disable-shared</parameter> means that the - <filename>libgcc_eh.a</filename> file isn't created and installed. The - Glibc package depends on this library as it uses - <parameter>-lgcc_eh</parameter> within its build system. This dependency - can be satisfied by creating a symlink to <filename>libgcc.a</filename>, - since that file will end up containing the objects normally contained in - <filename>libgcc_eh.a</filename>:</para> - -<screen><userinput remap="install">ln -sv libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/'`</userinput></screen> ---> + <screen><userinput remap="install">make install</userinput></screen> + + <para>This build of GCC has installed a couple of internal system + headers. Normally one of them, <filename>limits.h</filename>, would in turn + include the corresponding system <filename>limits.h</filename> header, in + this case, <filename>$LFS/usr/include/limits.h</filename>. However, at the + time of this build of GCC <filename>$LFS/usr/include/limits.h</filename> + does not exist, so the internal header that has just been installed is a + partial, self-contained file and does not include the extended features of + the system header. This is adequate for building glibc, but the full + internal header will be needed later. Create a full version of the internal + header using a command that is identical to what the GCC build system does + in normal circumstances:</para> + +<screen><userinput remap="install">cd .. +cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \ + `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/install-tools/include/limits.h</userinput></screen> </sect2> <sect2 role="content"> |