- Timestamp:
- 02/01/2004 09:49:10 PM (20 years ago)
- Branches:
- 10.0, 10.0-rc1, 10.1, 10.1-rc1, 11.0, 11.0-rc1, 11.0-rc2, 11.0-rc3, 11.1, 11.1-rc1, 11.2, 11.2-rc1, 11.3, 11.3-rc1, 12.0, 12.0-rc1, 12.1, 12.1-rc1, 6.0, 6.1, 6.1.1, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 7.0, 7.1, 7.2, 7.3, 7.4, 7.5, 7.5-systemd, 7.6, 7.6-systemd, 7.7, 7.7-systemd, 7.8, 7.8-systemd, 7.9, 7.9-systemd, 8.0, 8.1, 8.2, 8.3, 8.4, 9.0, 9.1, arm, bdubbs/gcc13, ml-11.0, multilib, renodr/libudev-from-systemd, s6-init, trunk, v5_1, v5_1_1, xry111/arm64, xry111/arm64-12.0, xry111/clfs-ng, xry111/lfs-next, xry111/loongarch, xry111/loongarch-12.0, xry111/loongarch-12.1, xry111/mips64el, xry111/pip3, xry111/rust-wip-20221008, xry111/update-glibc
- Children:
- 247acde
- Parents:
- c288d97
- Location:
- chapter05
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
chapter05/bash.xml
rc288d97 r90e3cb3 37 37 <screen><userinput>make install</userinput></screen> 38 38 39 <para>And make a link for the programs that use < userinput>sh</userinput>39 <para>And make a link for the programs that use <command>sh</command> 40 40 for a shell:</para> 41 41 -
chapter05/binutils-pass1.xml
rc288d97 r90e3cb3 67 67 <listitem><para><userinput>LDFLAGS="-all-static"</userinput>: This tells the 68 68 linker that all the Binutils programs should be linked statically. However, 69 strictly speaking, < userinput>"-all-static"</userinput> is first passed to the70 < emphasis>libtool</emphasis> program which then passes71 < userinput>"-static"</userinput> on to the linker.</para></listitem>69 strictly speaking, <emphasis>"-all-static"</emphasis> is first passed to the 70 <command>libtool</command> program which then passes 71 <emphasis>"-static"</emphasis> on to the linker.</para></listitem> 72 72 </itemizedlist> 73 73 -
chapter05/bzip2.xml
rc288d97 r90e3cb3 14 14 <title>Installation of Bzip2</title> 15 15 16 <para>The Bzip2 package doesn't contain a < userinput>configure</userinput>16 <para>The Bzip2 package doesn't contain a <command>configure</command> 17 17 script. Compile and install it with a straightforward:</para> 18 18 -
chapter05/chapter05.xml
rc288d97 r90e3cb3 24 24 25 25 <para>The build instructions assume that you are using the 26 < userinput>bash</userinput> shell. It is also expected that you have already26 <command>bash</command> shell. It is also expected that you have already 27 27 unpacked a source package (while logged in as user <emphasis>lfs</emphasis> -- 28 28 explained shortly) and performed a <userinput>cd</userinput> into the source … … 101 101 <filename class="directory">/lib</filename> directory on your host system. A 102 102 surefire way is to inspect a random binary from your host system by running: 103 <userinput> 'readelf -l <name of binary> | grep interpreter'</userinput>103 <userinput>readelf -l <name of binary> | grep interpreter</userinput> 104 104 and noting the output. The authoritative reference covering all platforms is in 105 105 the <filename>shlib-versions</filename> file in the root of the Glibc source … … 119 119 choose.</para></listitem> 120 120 121 <listitem><para>Careful manipulation of < userinput>gcc</userinput>'s121 <listitem><para>Careful manipulation of <command>gcc</command>'s 122 122 <emphasis>specs</emphasis> file to tell the compiler which target dynamic 123 123 linker will be used.</para></listitem> … … 126 126 <para>Binutils is installed first because both GCC and Glibc perform various 127 127 feature tests on the assembler and linker during their respective runs of 128 < userinput>./configure</userinput> to determine which software features to enable128 <command>./configure</command> to determine which software features to enable 129 129 or disable. This is more important than one might first realize. An incorrectly 130 130 configured GCC or Glibc can result in a subtly broken toolchain where the impact … … 138 138 the tools in one location are hard linked to the other. An important facet of 139 139 the linker is its library search order. Detailed information can be obtained 140 from < userinput>ld</userinput> by passing it the <emphasis>--verbose</emphasis>141 flag. For example: < userinput>'ld --verbose | grep SEARCH'</userinput> will140 from <command>ld</command> by passing it the <emphasis>--verbose</emphasis> 141 flag. For example: <command>ld --verbose | grep SEARCH</command> will 142 142 show you the current search paths and their order. You can see what files are 143 actually linked by < userinput>ld</userinput> by compiling a dummy program and144 passing the <emphasis>--verbose</emphasis> switch . For example:145 < userinput>'gcc dummy.c -Wl,--verbose 2>&1 | grep succeeded'</userinput>146 will show you all the files successfully opened during the link .</para>143 actually linked by <command>ld</command> by compiling a dummy program and 144 passing the <emphasis>--verbose</emphasis> switch to the linker. For example: 145 <command>gcc dummy.c -Wl,--verbose 2>&1 | grep succeeded</command> 146 will show you all the files successfully opened during the linking.</para> 147 147 148 148 <para>The next package installed is GCC and during its run of 149 < userinput>./configure</userinput> you'll see, for example:</para>149 <command>./configure</command> you'll see, for example:</para> 150 150 151 151 <blockquote><screen>checking what assembler to use... /tools/i686-pc-linux-gnu/bin/as … … 154 154 <para>This is important for the reasons mentioned above. It also demonstrates 155 155 that GCC's configure script does not search the $PATH directories to find which 156 tools to use. However, during the actual operation of < userinput>gcc</userinput>156 tools to use. However, during the actual operation of <command>gcc</command> 157 157 itself, the same search paths are not necessarily used. You can find out which 158 standard linker < userinput>gcc</userinput> will use by running:159 < userinput>'gcc -print-prog-name=ld'</userinput>.160 Detailed information can be obtained from < userinput>gcc</userinput> by passing158 standard linker <command>gcc</command> will use by running: 159 <command>gcc -print-prog-name=ld</command>. 160 Detailed information can be obtained from <command>gcc</command> by passing 161 161 it the <emphasis>-v</emphasis> flag while compiling a dummy program. For 162 example: < userinput>'gcc -v dummy.c'</userinput> will show you detailed162 example: <command>gcc -v dummy.c</command> will show you detailed 163 163 information about the preprocessor, compilation and assembly stages, including 164 < userinput>gcc</userinput>'s include search paths and their order.</para>164 <command>gcc</command>'s include search paths and their order.</para> 165 165 166 166 <para>The next package installed is Glibc. The most important considerations for 167 167 building Glibc are the compiler, binary tools and kernel headers. The compiler 168 is generally no problem as Glibc will always use the < userinput>gcc</userinput>168 is generally no problem as Glibc will always use the <command>gcc</command> 169 169 found in a $PATH directory. The binary tools and kernel headers can be a little 170 170 more troublesome. Therefore we take no risks and use the available configure 171 171 switches to enforce the correct selections. After the run of 172 < userinput>./configure</userinput> you can check the contents of the172 <command>./configure</command> you can check the contents of the 173 173 <filename>config.make</filename> file in the 174 174 <filename class="directory">glibc-build</filename> directory for all the 175 175 important details. You'll note some interesting items like the use of 176 < userinput>CC="gcc -B/tools/bin/"</userinput> to control which binary tools are176 <emphasis>CC="gcc -B/tools/bin/"</emphasis> to control which binary tools are 177 177 used, and also the use of the <emphasis>-nostdinc</emphasis> and 178 178 <emphasis>-isystem</emphasis> flags to control the compiler's include search … … 183 183 <para>After the Glibc installation, we make some adjustments to ensure that 184 184 searching and linking take place only within our <filename>/tools</filename> 185 prefix. We install an adjusted < userinput>ld</userinput>, which has a hard-wired185 prefix. We install an adjusted <command>ld</command>, which has a hard-wired 186 186 search path limited to <filename class="directory">/tools/lib</filename>. Then 187 we amend < userinput>gcc</userinput>'s specs file to point to our new dynamic187 we amend <command>gcc</command>'s specs file to point to our new dynamic 188 188 linker in <filename class="directory">/tools/lib</filename>. This last step is 189 189 <emphasis>vital</emphasis> to the whole process. As mentioned above, a 190 190 hard-wired path to a dynamic linker is embedded into every ELF shared 191 191 executable. You can inspect this by running: 192 <userinput>'readelf -l <name of binary> | grep interpreter'</userinput>. 193 By amending <userinput>gcc</userinput>'s specs file, we are ensuring that every 194 program compiled from here through the end of <xref linkend="chapter05"/> will 195 use our new dynamic linker in 196 <filename class="directory">/tools/lib</filename>.</para> 192 <command>readelf -l <name of binary> | grep interpreter</command>. 193 By amending <command>gcc</command>'s specs file, we are ensuring that every 194 program compiled from here through the end of this chapter will use our new 195 dynamic linker in <filename class="directory">/tools/lib</filename>.</para> 197 196 198 197 <para>The need to use the new dynamic linker is also the reason why we apply the … … 204 203 <para>During the second pass of Binutils, we are able to utilize the 205 204 <emphasis>--with-lib-path</emphasis> configure switch to control 206 < userinput>ld</userinput>'s library search path. From this point onwards, the205 <command>ld</command>'s library search path. From this point onwards, the 207 206 core toolchain is self-contained and self-hosted. The remainder of the 208 207 <xref linkend="chapter05"/> packages all build against the new Glibc in … … 214 213 <filename class="directory">/usr</filename>, we perform a quick changeover of 215 214 the toolchain defaults, then proceed for real in building the rest of the 216 target <xref linkend="chapter06"/>LFS system.</para>215 target LFS system.</para> 217 216 218 217 <sect2> … … 289 288 <screen><userinput>ln -s $LFS/tools /</userinput></screen> 290 289 291 <note><para>The above command is correct. The < userinput>ln</userinput> command290 <note><para>The above command is correct. The <command>ln</command> command 292 291 has a few syntactic variations, so be sure to check the info page before 293 292 reporting what you may think is an error.</para></note> … … 350 349 <screen><userinput>su - lfs</userinput></screen> 351 350 352 <para>The "< userinput>-</userinput>" instructs <userinput>su</userinput> to353 start a<emphasis>login</emphasis> shell.</para>351 <para>The "<command>-</command>" instructs <command>su</command> to start a 352 <emphasis>login</emphasis> shell.</para> 354 353 355 354 </sect1> … … 361 360 362 361 <para>We're going to set up a good working environment by creating two new 363 startup files for the < userinput>bash</userinput> shell. While logged in as362 startup files for the <command>bash</command> shell. While logged in as 364 363 user <emphasis>lfs</emphasis>, issue the following command to create a new 365 364 <filename>.bash_profile</filename>:</para> … … 373 372 <filename>/etc/profile</filename> of your host (probably containing some 374 373 settings of environment variables) and then <filename>.bash_profile</filename>. 375 The < userinput>exec env -i ... /bin/bash</userinput> command in the latter file374 The <command>exec env -i ... /bin/bash</command> command in the latter file 376 375 replaces the running shell with a new one with a completely empty environment, 377 376 except for the HOME, TERM and PS1 variables. This ensures that no unwanted and … … 394 393 <userinput>EOF</userinput></screen> 395 394 396 <para>The < userinput>set +h</userinput> command turns off397 < userinput>bash</userinput>'s hash function. Normally hashing is a useful398 feature: < userinput>bash</userinput> uses a hash table to remember the395 <para>The <command>set +h</command> command turns off 396 <command>bash</command>'s hash function. Normally hashing is a useful 397 feature: <command>bash</command> uses a hash table to remember the 399 398 full pathnames of executable files to avoid searching the PATH time and time 400 399 again to find the same executable. However, we'd like the new tools to be 401 400 used as soon as they are installed. By switching off the hash function, our 402 "interactive" commands (< userinput>make</userinput>,403 < userinput>patch</userinput>, <userinput>sed</userinput>,404 < userinput>cp</userinput> and so forth) will always use401 "interactive" commands (<command>make</command>, 402 <command>patch</command>, <command>sed</command>, 403 <command>cp</command> and so forth) will always use 405 404 the newest available version during the build process.</para> 406 405 … … 520 519 You will need to investigate and retrace your steps to find out where the 521 520 problem is and correct it. There is no point in continuing until this is done. 522 First, redo the sanity check using < userinput>gcc</userinput> instead of523 < userinput>cc</userinput>. If this works it means the521 First, redo the sanity check using <command>gcc</command> instead of 522 <command>cc</command>. If this works it means the 524 523 <filename class="symlink">/tools/bin/cc</filename> symlink is missing. Revisit 525 524 <xref linkend="ch-tools-gcc-pass1"/> and fix the symlink. Second, ensure your $PATH … … 588 587 589 588 <para>Take care <emphasis>not</emphasis> to use 590 < userinput>--strip-unneeded</userinput> on the libraries -- they would be589 <emphasis>--strip-unneeded</emphasis> on the libraries -- they would be 591 590 destroyed and you would have to build Glibc all over again.</para> 592 591 -
chapter05/gcc-pass1.xml
rc288d97 r90e3cb3 43 43 <listitem><para><userinput>--with-local-prefix=/tools</userinput>: The 44 44 purpose of this switch is to remove <filename>/usr/local/include</filename> 45 from < userinput>gcc</userinput>'s include search path. This is not absolutely45 from <command>gcc</command>'s include search path. This is not absolutely 46 46 essential; however, we want to try to minimize the influence of the host 47 47 system, thus making this a sensible thing to do.</para></listitem> … … 52 52 having <filename>libgcc_eh.a</filename> available ensures that the configure 53 53 script for Glibc (the next package we compile) produces the proper results. 54 Note that the < userinput>gcc</userinput> binaries will still be linked55 statically, as this is controlled by the < userinput>-static</userinput>54 Note that the <command>gcc</command> binaries will still be linked 55 statically, as this is controlled by the <command>-static</command> 56 56 value of BOOT_LDFLAGS further on.</para></listitem> 57 57 … … 93 93 <para>As a finishing touch we'll create the <filename 94 94 class="symlink">/tools/bin/cc</filename> symlink. Many programs and 95 scripts run < userinput>cc</userinput> instead of <userinput>gcc</userinput>,95 scripts run <command>cc</command> instead of <command>gcc</command>, 96 96 a thing meant to keep programs generic and therefore usable on all kinds of 97 97 Unix systems. Not everybody has the GNU C compiler installed. Simply running 98 < userinput>cc</userinput> leaves the system administrator free to decide what98 <command>cc</command> leaves the system administrator free to decide what 99 99 C compiler to install, as long as there's a symlink pointing to it:</para> 100 100 -
chapter05/gcc-pass2.xml
rc288d97 r90e3cb3 113 113 <screen><userinput>make</userinput></screen> 114 114 115 <para>There is no need to use the < userinput>bootstrap</userinput> target now,115 <para>There is no need to use the <emphasis>bootstrap</emphasis> target now, 116 116 as the compiler we're using to compile this GCC was built from the exact same 117 117 version of the GCC sources we used earlier.</para> … … 124 124 <screen><userinput>make -k check</userinput></screen> 125 125 126 <para>The < userinput>-k</userinput> flag is used to make the test suite run126 <para>The <emphasis>-k</emphasis> flag is used to make the test suite run 127 127 through to completion and not stop at the first failure. The GCC test suite is 128 128 very comprehensive and is almost guaranteed to generate a few failures. To get … … 143 143 144 144 <para>The unexpected pass for g++ is due to the use of 145 < userinput>--enable-__cxa_atexit</userinput>. Apparently not all platforms145 <emphasis>--enable-__cxa_atexit</emphasis>. Apparently not all platforms 146 146 supported by GCC have support for "__cxa_atexit" in their C libraries, so this 147 147 test is not always expected to pass.</para> 148 148 149 149 <para>The 24 unexpected passes for libstdc++ are due to the use of 150 < userinput>--enable-clocale=gnu</userinput>, which is the correct choice on150 <emphasis>--enable-clocale=gnu</emphasis>, which is the correct choice on 151 151 Glibc-based systems of versions 2.2.5 and above. The underlying locale support 152 152 in the GNU C library is superior to that of the otherwise selected "generic" -
chapter05/glibc.xml
rc288d97 r90e3cb3 54 54 55 55 <listitem><para><userinput>--without-gd</userinput>: This switch ensures 56 that we don't build the < userinput>memusagestat</userinput> program, which56 that we don't build the <command>memusagestat</command> program, which 57 57 strangely enough insists on linking against the host's libraries (libgd, 58 58 libpng, libz, and so forth).</para></listitem> … … 123 123 could still occur -- the <emphasis>math</emphasis> 124 124 tests for example. When experiencing a failure, make a note of it, then 125 continue by reissuing the < userinput>make check</userinput>. The test suite125 continue by reissuing the <command>make check</command>. The test suite 126 126 should pick up where it left off and continue on. You can circumvent this 127 stop-start sequence by issuing a < userinput>make -k check</userinput>. But if127 stop-start sequence by issuing a <command>make -k check</command>. But if 128 128 you do that, be sure to log the output so that you can later peruse the log 129 129 file and examine the total number of failures.</para> … … 157 157 <para>An alternative to running the previous command is to install only those 158 158 locales which you need or want. This can be achieved by using the 159 < userinput>localedef</userinput> command. Information on this can be found in159 <command>localedef</command> command. Information on this can be found in 160 160 the <filename>INSTALL</filename> file in the Glibc source. However, there are 161 161 a number of locales that are essential for the tests of future packages to -
chapter05/grep.xml
rc288d97 r90e3cb3 23 23 <itemizedlist> 24 24 <listitem><para><userinput>--disable-perl-regexp</userinput>: This makes sure 25 that < userinput>grep</userinput> does not get linked against a PCRE library25 that <command>grep</command> does not get linked against a PCRE library 26 26 that may be present on the host and would not be available once we enter the 27 27 chroot environment.</para></listitem> -
chapter05/kernelheaders.xml
rc288d97 r90e3cb3 13 13 <para>As some packages need to refer to the kernel header files, we're going 14 14 to unpack the kernel archive now, set it up, and copy the required files to a 15 place where < userinput>gcc</userinput> can later find them.</para>15 place where <command>gcc</command> can later find them.</para> 16 16 17 17 <para>Prepare for the header installation with:</para> -
chapter05/patch.xml
rc288d97 r90e3cb3 18 18 <screen><userinput>CPPFLAGS=-D_GNU_SOURCE ./configure --prefix=/tools</userinput></screen> 19 19 20 <para>The preprocessor flag < userinput>-D_GNU_SOURCE</userinput> is only needed20 <para>The preprocessor flag <emphasis>-D_GNU_SOURCE</emphasis> is only needed 21 21 on the PowerPC platform. On other architectures you can leave it out.</para> 22 22
Note:
See TracChangeset
for help on using the changeset viewer.