stripping.xml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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-stripping">
  8. <?dbhtml filename="stripping.html"?>
  9. <title>Stripping</title>
  10. <para>The steps in this section are optional, but if the LFS partition is
  11. rather small, it is beneficial to learn that unnecessary items can be removed.
  12. The executables and libraries built so far contain about 70 MB of unneeded
  13. debugging symbols. Remove those symbols with:</para>
  14. <screen><userinput>$LFS_TGT-strip --strip-debug $LFS/usr/lib/*
  15. $LFS_TGT-strip --strip-unneeded $LFS/usr/{,s}bin/*</userinput></screen>
  16. <para>These commands will skip a number of files, reporting that it does not
  17. recognize their file format. Most of these are scripts instead of binaries.
  18. Note that we use the <command>strip</command> program built in
  19. <quote>Binutils pass 1</quote>, since it is the one that knows how to strip
  20. our cross-compiled programs.</para>
  21. <!-- Normally, the host "strip" could be used too, since it is actually the
  22. same computer. But Some old versions of binutils may generate buggy crt1.o
  23. and the like, because they do not know about recently introduced symbol
  24. types. For more details,
  25. see https://sourceware.org/bugzilla/show_bug.cgi?id=22875-->
  26. <para>Take care <emphasis>not</emphasis> to use
  27. <parameter>--strip-unneeded</parameter> on the libraries. The static
  28. ones would be destroyed and the toolchain packages would need to be
  29. built all over again.</para>
  30. <para>To save more, remove the documentation:</para>
  31. <screen><userinput>rm -rf $LFS/usr/{,share}/{info,man,doc}</userinput></screen>
  32. <para>The libtool .la files are only useful when linking with static
  33. libraries. They are unneeded, and potentially harmful, when using dynamic
  34. shared libraries, specially when using also non-autotools build systems.
  35. Remove those files now:</para>
  36. <screen><userinput>find $LFS/usr/{lib,libexec} -name \*.la -delete</userinput></screen>
  37. <para>At this point, you should have at least 3 GB of free space in
  38. <envar>$LFS</envar> that can be used to build and install Glibc and Gcc in
  39. the next phase. If you can build and install Glibc, you can build and install
  40. the rest too.</para>
  41. <sect2>
  42. <title>Backup / Restore</title>
  43. <para>
  44. Now that the essential tools has been created, its time to think about
  45. a backup. When every check has passed successfully in the previously
  46. built packages, your temporary tools are in a good state and might be
  47. backed up for later reuse. In case of fatal failures in the subsequent
  48. sections, it often turns out that removing everything and start over
  49. (more carefully) is the best option to recover. Unfortunatly, all the
  50. temporary tools will be removed, too. To avoid extra time to redo
  51. something which has been built successfully, make sure you have at least
  52. 600 MB free disk space (the source tarballs will be included in the
  53. backup archive) in the home directory of user
  54. <systemitem class="username">lfs</systemitem> and prepare a backup:
  55. </para>
  56. <screen role="nodump"><userinput>cd $LFS &amp;&amp;
  57. tar -cJpf $HOME/temp-tools.tar.xz .
  58. </userinput></screen>
  59. <para>
  60. In case you have to start over as some mistakes has been made, you can
  61. use this backup to restore the temporary tools and save some time on
  62. the way to recover. Since the sources are located under
  63. <filename class="directory">$LFS</filename>, they are included in the
  64. backup archive as well, so you need not to download them again. After
  65. checking that <filename class="directory">$LFS</filename> is set proper,
  66. restore the backup by executing the following commands:
  67. </para>
  68. <screen role="nodump"><userinput>cd $LFS &amp;&amp;
  69. rm -rf ./* &amp;&amp;
  70. tar -xpf $HOME/temp-tools.tar.xz
  71. </userinput></screen>
  72. <para>
  73. Again, double check that the environment has been setup proper and
  74. continue building the rest of the system.
  75. </para>
  76. </sect2>
  77. </sect1>