stripping.xml 5.2 KB

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