Ticket #2461: toolchain-3.patch
File toolchain-3.patch, 6.4 KB (added by , 15 years ago) |
---|
-
chapter05/toolchaintechnotes.xml
17 17 to at any time during the process.</para> 18 18 19 19 <para>The overall goal of <xref linkend="chapter-temporary-tools"/> is to 20 provide a temporary environment that can be chrooted into and from which can be21 produceda clean, trouble-free build of the target LFS system in <xref22 linkend="chapter-building-system"/> . Along the way, we separate the new system23 from the host system as much as possible, and in doing so, build a24 self-contained and self-hosted toolchain. It should be noted that the build25 process has been designed to minimize the risks for new readers and provide26 maximumeducational value at the same time.</para>20 provide a temporary environment that can be chrooted into, 21 where a clean, trouble-free build of the target LFS system in <xref 22 linkend="chapter-building-system"/> can be produced. Along the way, we 23 separate the new system from the host system as much as possible, and in 24 doing so, build a self-contained and self-hosted toolchain. 25 The build process has been designed to minimize the risks for new 26 readers and to provide the most educational value at the same time.</para> 27 27 28 28 <important> 29 29 <para>Before continuing, be aware of the name of the working platform, … … 98 98 <para>The next package installed is GCC. An example of what can be 99 99 seen during its run of <command>configure</command> is:</para> 100 100 101 <screen><computeroutput>checking what assembler to use... 102 /tools/i686-pc-linux-gnu/bin/as 103 checking what linker to use... /tools/i686-pc-linux-gnu/bin/ld</computeroutput></screen> 101 <screen><computeroutput>checking what assembler to use... /tools/i686-lfs-linux-gnu/bin/as 102 checking what linker to use... /tools/i686-lfs-linux-gnu/bin/ld</computeroutput></screen> 104 103 105 104 <para>This is important for the reasons mentioned above. It also demonstrates 106 105 that GCC's configure script does not search the PATH directories to find which … … 117 116 118 117 <para>The next package installed is Glibc. The most important considerations 119 118 for building Glibc are the compiler, binary tools, and kernel headers. The 120 compiler is generally not an issue since Glibc will always use the 121 <command>gcc</command> found in a <envar>PATH</envar> directory. The binary 122 tools and kernel headers can be a bit more complicated. Therefore, take no 123 risks and use the available configure switches to enforce the correct 124 selections. After the run of <command>configure</command>, check the contents 125 of the <filename>config.make</filename> file in the <filename 119 compiler is generally not an issue since Glibc will always use the compiler 120 relating to the <parameter>--host</parameter> parameter passed to its 121 configure script, e.g. in our case, 122 <command>i686-lfs-linux-gnu-gcc</command>. The binary tools and kernel 123 headers can be a bit more complicated. Therefore, take no risks and use the 124 available configure switches to enforce the correct selections. After the run 125 of <command>configure</command>, check the contents of the 126 <filename>config.make</filename> file in the <filename 126 127 class="directory">glibc-build</filename> directory for all important details. 127 Note the use of <parameter>CC=" gcc -B/tools/bin/"</parameter> to control which128 binary tools are used and the use of the <parameter>-nostdinc</parameter> 129 and<parameter>-isystem</parameter> flags to control the compiler's include128 Note the use of <parameter>CC="i686-lfs-gnu-gcc"</parameter> to control which 129 binary tools are used and the use of the <parameter>-nostdinc</parameter> and 130 <parameter>-isystem</parameter> flags to control the compiler's include 130 131 search path. These items highlight an important aspect of the Glibc 131 132 package—it is very self-sufficient in terms of its build machinery and 132 133 generally does not rely on toolchain defaults.</para> 133 134 134 <para>After the Glibc installation, make some adjustments to ensure that 135 searching and linking take place only within the <filename 136 class="directory">/tools</filename> prefix. Install an adjusted 137 <command>ld</command>, which has a hard-wired search path limited to 138 <filename class="directory">/tools/lib</filename>. Then amend 139 <command>gcc</command>'s specs file to point to the new dynamic linker in 140 <filename class="directory">/tools/lib</filename>. This last step is vital 141 to the whole process. As mentioned above, a hard-wired path to a dynamic 142 linker is embedded into every Executable and Link Format (ELF)-shared 143 executable. This can be inspected by running: 135 <para>After the Glibc installation, change <command>gcc</command>'s specs file 136 to point to the new dynamic linker in <filename 137 class="directory">/tools/lib</filename>. This last step is vital in ensuring 138 that searching and linking take place only within the <filename 139 class="directory">/tools</filename> prefix. A hard-wired 140 path to a dynamic linker is embedded into every Executable and Link Format 141 (ELF)-shared executable. This can be inspected by running: 144 142 <userinput>readelf -l <name of binary> | grep interpreter</userinput>. 145 Amending gcc's specs file ensures that every program compiled from here146 through the end of this chapter will use the new dynamic linker in147 <filename class="directory">/tools/lib</filename>.</para>143 Amending <command>gcc</command>'s specs file ensures that every program 144 compiled from here through the end of this chapter will use the new dynamic 145 linker in <filename class="directory">/tools/lib</filename>.</para> 148 146 149 147 <para>For the second pass of GCC, its sources also need to be modified 150 148 to tell GCC to use the new dynamic linker. Failure to do … … 164 162 linkend="chapter-building-system"/>, the first major package to be 165 163 installed is Glibc, due to its self-sufficient nature mentioned above. 166 164 Once this Glibc is installed into <filename 167 class="directory">/usr</filename>, perform a quick changeover of the168 toolchain defaults, then proceed in building the rest of the target165 class="directory">/usr</filename>, we will perform a quick changeover of the 166 toolchain defaults, and then proceed in building the rest of the target 169 167 LFS system.</para> 170 168 171 169 <!-- FIXME: Removed as part of the fix for bug 1061 - we no longer build pass1