source: chapter07/stripping.xml@ 45d8933

10.0 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 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk 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
Last change on this file since 45d8933 was 45d8933, checked in by Xi Ruoyao <xry111@…>, 4 years ago

always remove the docs of temporary tools

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@12030 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 7.4 KB
RevLine 
[67d1e79]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
8<sect1 id="ch-tools-stripping">
9 <?dbhtml filename="stripping.html"?>
10
[c071af0]11 <title>Cleaning up and Saving the Temporary System</title>
[67d1e79]12
[6c329d7]13 <para>The libtool .la files are only useful when linking with static
14 libraries. They are unneeded, and potentially harmful, when using dynamic
15 shared libraries, specially when using non-autotools build systems.
16 While still in chroot, remove those files now:</para>
17
[92f1b84]18<screen><userinput>find /usr/{lib,libexec} -name \*.la -delete</userinput></screen>
[6c329d7]19
[45d8933]20 <para>Remove the documentation of the temporary tools, to prevent them
21 from ending up in the final system, and save about 35 MB:</para>
22
23<screen><userinput>rm -rf /usr/share/{info,man,doc}/*</userinput></screen>
24
[c071af0]25 <note><para>
[6c329d7]26 All the remaining steps in this section are optional. Nevertheless,
27 as soon as you begin installing packages in <xref
[c071af0]28 linkend="chapter-building-system"/>, the temporary tools will be
29 overwritten. So it may be a good idea to do a backup of the temporary
30 tools as described below. The other steps are only needed if you are
31 really short on disk space.
32 </para></note>
[67d1e79]33
[302d97a]34 <para>
35 The following steps are performed from outside the chroot
36 environment. That means, you have to leave the chroot environment
[ea7ec72]37 first before continuing. The reason for that is to:
[302d97a]38 <itemizedlist>
39 <listitem>
40 <para>
[ea7ec72]41 make sure that objects are not in use while they are
42 manipulated.
[302d97a]43 </para>
44 </listitem>
45 <listitem>
46 <para>
47 get access to file system locations outside of the chroot
48 environment to store/read the backup archive which should
49 not be placed within the
50 <filename class="directory">$LFS</filename> hierarchy for
51 safety reasons.
52 </para>
53 </listitem>
54 </itemizedlist>
55 </para>
56
57 <para>
58 Leave the chroot environment and unmount the kernel virtual file
59 systems:
60 </para>
61
62 <note>
63 <para>All of the following instructions are executed by
64 <systemitem class="username">root</systemitem>. Take extra
65 care about the commands you're going to run as mistakes
66 here can modify your host system. Be aware that the
67 environment variable <envar>LFS</envar> is set for user
68 <systemitem class="username">lfs</systemitem> by default
69 but it might <emphasis>not</emphasis> be set for
70 <systemitem class="username">root</systemitem>. Whenever
71 commands are to be executed by <systemitem class="username">root</systemitem>,
72 make sure you have set <envar>LFS</envar> accordingly.
73 This has been discussed in <xref linkend='ch-partitioning-aboutlfs'/>.
74 </para>
75 </note>
76
[ea7ec72]77<screen role="nodump"><userinput>exit
78umount $LFS/dev{/pts,}
79umount $LFS/{sys,proc,run}</userinput></screen>
80
[67d1e79]81 <sect2>
82 <title>Stripping</title>
83
[ea7ec72]84 <para>If the LFS partition is rather small, it is good to
85 know that unnecessary items can be removed. The executables and
86 libraries built so far contain a little over 90 MB of unneeded debugging
[302d97a]87 symbols.</para>
[67d1e79]88
[302d97a]89 <para>Strip off debugging symbols from binaries:</para>
90<screen role="nodump"><userinput>strip --strip-debug $LFS/usr/lib/*
91strip --strip-unneeded $LFS/usr/{,s}bin/*
92strip --strip-unneeded $LFS/tools/bin/*</userinput></screen>
[67d1e79]93
[aefc822]94 <para>These commands will skip a number of files reporting that it does not
[67d1e79]95 recognize their file format. Most of these are scripts instead of binaries.
[aefc822]96 <!--Note that we use the <command>strip</command> program built in
[302d97a]97 <quote>Binutils pass 2</quote>, since it is the one that knows how to strip
[aefc822]98 our cross-compiled programs.--></para>
99
100 <para>Take care <emphasis>NOT</emphasis> to use
[67d1e79]101 <parameter>--strip-unneeded</parameter> on the libraries. The static
102 ones would be destroyed and the toolchain packages would need to be
103 built all over again.</para>
104
[aefc822]105 <para>At this point, you should have at least 5 GB of free space on the
[ea7ec72]106 chroot partition that can be used to build and install Glibc and GCC in
[67d1e79]107 the next phase. If you can build and install Glibc, you can build and install
[aefc822]108 the rest too. You can check the free disk space with the command
[ea7ec72]109 <command>df -h $LFS</command>.</para>
[67d1e79]110
111 </sect2>
112
113 <sect2>
[3d92d63]114 <title>Backup</title>
[67d1e79]115
116 <para>
117 Now that the essential tools have been created, its time to think about
118 a backup. When every check has passed successfully in the previously
119 built packages, your temporary tools are in a good state and might be
120 backed up for later reuse. In case of fatal failures in the subsequent
[aefc822]121 chapters, it often turns out that removing everything and starting over
[c071af0]122 (more carefully) is the best option to recover. Unfortunately, all the
[302d97a]123 temporary tools will be removed, too. To avoid spending extra time to
124 redo something which has been built successfully, prepare a backup.
[67d1e79]125 </para>
126
127 <para>
[302d97a]128 Make sure you have at least 600 MB free disk space (the source tarballs
129 will be included in the backup archive) in the home directory of user
130 <systemitem class="username">root</systemitem>.
[67d1e79]131 </para>
132
[302d97a]133 <para>
134 Create the backup archive by running the following command:
135 </para>
[ea7ec72]136
137<screen role="nodump" revision="sysv"><userinput>cd $LFS &amp;&amp;
[aea20b5]138tar -cJpf $HOME/lfs-temp-tools-&version;.tar.xz .</userinput></screen>
[ea7ec72]139
140<screen role="nodump" revision="systemd"><userinput>cd $LFS &amp;&amp;
[aea20b5]141tar -cJpf $HOME/lfs-temp-tools-&versiond;.tar.xz .</userinput></screen>
[ea7ec72]142
[302d97a]143 <para>
144 Replace <envar>$HOME</envar> by a directory of your choice if you
[ea7ec72]145 do not want to have the backup stored in <systemitem
146 class="username">root</systemitem>'s home directory.
[302d97a]147 </para>
[3d92d63]148 </sect2>
149
150 <sect2>
151 <title>Restore</title>
[67d1e79]152
153 <para>
[aefc822]154 In case some mistakes have been made and you need to start over, you can
[fb386e0]155 use this backup to restore the temporary tools and save some recovery time.
[aefc822]156 Since the sources are located under
[67d1e79]157 <filename class="directory">$LFS</filename>, they are included in the
[ea7ec72]158 backup archive as well, so they do not need to be downloaded again. After
[9d8bf7e]159 checking that <envar>$LFS</envar> is set properly,
[67d1e79]160 restore the backup by executing the following commands:
161 </para>
162
[3d92d63]163<!-- Make the following look different so users don't blindly run the
164 restore when they don't need to. -->
165
166<screen role="nodump" revision="sysv"><computeroutput>cd $LFS &amp;&amp;
[ea7ec72]167rm -rf ./* &amp;&amp;
[3d92d63]168tar -xpf $HOME/lfs-temp-tools-&version;.tar.xz</computeroutput></screen>
[ea7ec72]169
[3d92d63]170<screen role="nodump" revision="systemd"><computeroutput>cd $LFS &amp;&amp;
[67d1e79]171rm -rf ./* &amp;&amp;
[3d92d63]172tar -xpf $HOME/lfs-temp-tools-&versiond;.tar.xz</computeroutput></screen>
[67d1e79]173
174 <para>
[aefc822]175 Again, double check that the environment has been setup properly
176 and continue building the rest of the system.
[67d1e79]177 </para>
178
179 <important>
180 <para>
[302d97a]181 If you left the chroot environment either to strip off debug
[c071af0]182 symbols, create a backup, or restart building using a restore,
[302d97a]183 remember to mount the kernel virtual filesystems now again as
184 described in <xref linkend='ch-tools-kernfs'/> and re-enter
185 the chroot environment (see <xref linkend='ch-tools-chroot'/>)
186 again before continuing.
187 </para>
[67d1e79]188 </important>
189
190 </sect2>
191
192</sect1>
Note: See TracBrowser for help on using the repository browser.