[673b0d8] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
[b06ca36] | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
[673b0d8] | 4 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
[81109e3] | 7 |
|
---|
[673b0d8] | 8 | <sect1 id="ch-tools-adjusting">
|
---|
[81109e3] | 9 | <?dbhtml filename="adjusting.html"?>
|
---|
| 10 |
|
---|
| 11 | <title>Adjusting the Toolchain</title>
|
---|
[673b0d8] | 12 |
|
---|
[81109e3] | 13 | <para>Now that the temporary C libraries have been installed, all
|
---|
| 14 | tools compiled in the rest of this chapter should be linked against
|
---|
[4e82d47] | 15 | these libraries. In order to accomplish this, the cross-compiler's
|
---|
| 16 | specs file needs to be adjusted to point to the new dynamic linker
|
---|
| 17 | in <filename class="directory">/tools</filename>.</para>
|
---|
| 18 |
|
---|
| 19 | <para>This is done by dumping the compiler's <quote>specs</quote> file to a
|
---|
| 20 | location where it will look for it by default.
|
---|
| 21 | A simple <command>sed</command> substitution then alters the
|
---|
[6e88633] | 22 | dynamic linker that GCC will use. The principle here is to find all references
|
---|
| 23 | to the dynamic linker file in <filename class="directory">/lib</filename>
|
---|
| 24 | or possibly <filename class="directory">/lib64</filename> if the host system
|
---|
| 25 | is 64-bit capable, and adjust them to point to the new location in
|
---|
| 26 | <filename class="directory">/tools</filename>.</para>
|
---|
[81fd230] | 27 |
|
---|
[19f8a62] | 28 | <para>For the sake of accuracy, it is recommended to use a copy-and-paste
|
---|
| 29 | method when issuing the following command. Be sure to visually inspect the
|
---|
[6e88633] | 30 | specs file to verify that it has properly adjusted all references to the
|
---|
| 31 | dynamic linker location. Refer to <xref
|
---|
| 32 | linkend="ch-tools-toolchaintechnotes" role=","/> for the default name
|
---|
| 33 | of the dynamic linker, if necessary.</para>
|
---|
[81109e3] | 34 |
|
---|
[19f8a62] | 35 | <!-- Ampersands are needed to allow copy and paste -->
|
---|
[4e82d47] | 36 | <screen><userinput>SPECS=`dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/specs
|
---|
| 37 | $LFS_TGT-gcc -dumpspecs | sed \
|
---|
| 38 | -e 's@/lib\(64\)\?/ld@/tools&@g' \
|
---|
| 39 | -e "/^\*cpp:$/{n;s,$, -isystem /tools/include,}" > $SPECS
|
---|
| 40 | echo "New specs file is: $SPECS"
|
---|
| 41 | unset SPECS</userinput></screen>
|
---|
[673b0d8] | 42 |
|
---|
[81109e3] | 43 | <caution>
|
---|
| 44 | <para>At this point, it is imperative to stop and ensure that the basic
|
---|
| 45 | functions (compiling and linking) of the new toolchain are working as
|
---|
| 46 | expected. To perform a sanity check, run the following commands:</para>
|
---|
[fba1478] | 47 |
|
---|
[673b0d8] | 48 | <screen><userinput>echo 'main(){}' > dummy.c
|
---|
[4e82d47] | 49 | $LFS_TGT-gcc -B/tools/lib dummy.c
|
---|
[673b0d8] | 50 | readelf -l a.out | grep ': /tools'</userinput></screen>
|
---|
| 51 |
|
---|
[81109e3] | 52 | <para>If everything is working correctly, there should be no errors,
|
---|
| 53 | and the output of the last command will be of the form:</para>
|
---|
[673b0d8] | 54 |
|
---|
[dc96e56] | 55 | <screen><computeroutput>[Requesting program interpreter: /tools/lib/ld-linux.so.2]</computeroutput></screen>
|
---|
[673b0d8] | 56 |
|
---|
[6e88633] | 57 | <para>Note that <filename class="directory">/tools/lib</filename>, or
|
---|
| 58 | <filename class="directory">/tools/lib64</filename> for 64-bit machines
|
---|
[81109e3] | 59 | appears as the prefix of the dynamic linker.</para>
|
---|
| 60 |
|
---|
| 61 | <para>If the output is not shown as above or there was no output at all,
|
---|
| 62 | then something is wrong. Investigate and retrace the steps to find out
|
---|
| 63 | where the problem is and correct it. This issue must be resolved before
|
---|
[4e82d47] | 64 | continuing on. Something may have gone wrong with the
|
---|
[81109e3] | 65 | specs file amendment above. In this case, redo the specs file amendment,
|
---|
| 66 | being careful to copy-and-paste the commands.</para>
|
---|
| 67 |
|
---|
| 68 | <para>Once all is well, clean up the test files:</para>
|
---|
[81fd230] | 69 |
|
---|
[5998892] | 70 | <screen><userinput>rm -v dummy.c a.out</userinput></screen>
|
---|
[05d80ab8] | 71 |
|
---|
[81109e3] | 72 | </caution>
|
---|
[673b0d8] | 73 |
|
---|
[4e82d47] | 74 | <note><para>Building Binutils in the next section will serve as an additional check that
|
---|
| 75 | the toolchain has been built properly. If Binutils fails to build, it is an
|
---|
| 76 | indication that something has gone wrong with the previous Binutils, GCC, or Glibc
|
---|
| 77 | installations.</para></note>
|
---|
[9b41802] | 78 |
|
---|
[673b0d8] | 79 | </sect1>
|
---|