adjusting.xml 3.6 KB

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