1 | <chapter id="chapter05">
|
---|
2 | <title>Preparing the LFS system</title>
|
---|
3 | <?dbhtml filename="chapter05.html" dir="chapter05"?>
|
---|
4 |
|
---|
5 | &c5-introduction;
|
---|
6 | &c5-whystatic;
|
---|
7 | &c5-creatingstage1dir;
|
---|
8 | &c5-addinguser;
|
---|
9 | &c5-settingenviron;
|
---|
10 | &c5-binutils-pass1;
|
---|
11 | &c5-gcc-pass1;
|
---|
12 | &c5-kernelheaders;
|
---|
13 | &c5-glibc;
|
---|
14 | &c5-lockingglibc;
|
---|
15 | &c5-tcl;
|
---|
16 | &c5-expect;
|
---|
17 | &c5-dejagnu;
|
---|
18 | &c5-gcc-pass2;
|
---|
19 | &c5-binutils-pass2;
|
---|
20 | &c5-gawk;
|
---|
21 | &c5-coreutils;
|
---|
22 | &c5-bzip2;
|
---|
23 | &c5-gzip;
|
---|
24 | &c5-diffutils;
|
---|
25 | &c5-findutils;
|
---|
26 | &c5-make;
|
---|
27 | &c5-grep;
|
---|
28 | &c5-sed;
|
---|
29 | &c5-gettext;
|
---|
30 | &c5-ncurses;
|
---|
31 | &c5-patch;
|
---|
32 | &c5-tar;
|
---|
33 | &c5-texinfo;
|
---|
34 | &c5-bash;
|
---|
35 | &c5-utillinux;
|
---|
36 | &c5-perl;
|
---|
37 |
|
---|
38 |
|
---|
39 | <sect1 id="ch05-adjustingtoolchain">
|
---|
40 | <title>Re-adjusting the toolchain</title>
|
---|
41 | <?dbhtml filename="adjustingtoolchain.html" dir="chapter05"?>
|
---|
42 |
|
---|
43 | <para>Now that we have compiled all the necessary tools, it is time to
|
---|
44 | re-adjust our toolchain. We will set it up so that it will link any newly
|
---|
45 | compiled program against the new Glibc, which is the first thing to get
|
---|
46 | compiled in the next chapter. Basically, this is the reverse of what we did
|
---|
47 | in the "Locking in" stage in the beginning of this chapter.</para>
|
---|
48 |
|
---|
49 | <para>The first thing to do is to adjust the linker scripts. For this we
|
---|
50 | retained the <filename>binutils-build</filename> directory from the second
|
---|
51 | pass over Binutils. Do the following:</para>
|
---|
52 |
|
---|
53 | <para><screen><userinput>cd binutils-build
|
---|
54 | make -C ld INSTALL=/stage1/bin/install install-data-local</userinput></screen></para>
|
---|
55 |
|
---|
56 | <para>This installs the adjusted linker scripts. The linker scripts now contain
|
---|
57 | no mention of <filename>/stage1/lib</filename>. From now on every compiled
|
---|
58 | program will link <emphasis>only</emphasis> against the libraries in
|
---|
59 | <filename>/usr/lib</filename> and <filename>/lib</filename>. The extra
|
---|
60 | <userinput>INSTALL=/stage1/bin/install</userinput> is needed because the
|
---|
61 | Makefile created during the second pass still contains the reference to
|
---|
62 | <filename>/usr/bin/install</filename>, which we obviously haven't installed
|
---|
63 | yet.</para>
|
---|
64 |
|
---|
65 | <para>You can now remove the Binutils source and build directories.</para>
|
---|
66 |
|
---|
67 | <para>The next thing to do is to amend our GCC specs file so that it points to
|
---|
68 | the new dynamic linker. Just like earlier on, we use a sed to accomplish
|
---|
69 | this:</para>
|
---|
70 |
|
---|
71 | <para><screen><userinput>CURRENTSPECFILE=/stage1/lib/gcc-lib/*/*/specs
|
---|
72 | sed -e 's@/stage1/lib/ld.so.1@/lib/ld.so.1@g' \
|
---|
73 | -e 's@/stage1/lib/ld-linux.so.2@/lib/ld-linux.so.2@g' \
|
---|
74 | $CURRENTSPECFILE > newspecfile
|
---|
75 | mv newspecfile $CURRENTSPECFILE
|
---|
76 | unset CURRENTSPECFILE</userinput></screen></para>
|
---|
77 |
|
---|
78 | <para>Again, cutting and pasting the above is recommended. And just like
|
---|
79 | before, it is a good idea to check the linker scripts and the specs file to
|
---|
80 | ensure the intended changes were actually made.</para>
|
---|
81 |
|
---|
82 | <para>Note that the linker scripts will still contain a reference to
|
---|
83 | <filename>/stage1/i686-pc-linux-gnu/lib</filename>. This is unavoidable, but
|
---|
84 | luckily does not present a problem. There are no libraries in that location
|
---|
85 | as all the temporary stage1 libraries are located in
|
---|
86 | <filename>/stage1/lib</filename>.</para>
|
---|
87 |
|
---|
88 | </sect1>
|
---|
89 |
|
---|
90 |
|
---|
91 |
|
---|
92 | <sect1 id="ch05-stripping">
|
---|
93 | <title>Stripping</title>
|
---|
94 | <?dbhtml filename="stripping.html" dir="chapter05"?>
|
---|
95 |
|
---|
96 | <para>If your LFS partition is rather small, you will be glad to learn that you
|
---|
97 | can throw away some unnecessary things. The executables and libraries you have
|
---|
98 | built so far contain about 130 MB of unneeded debugging symbols. Remove those
|
---|
99 | symbols like this:</para>
|
---|
100 |
|
---|
101 | <para><screen><userinput>strip --strip-unneeded /stage1/{,s}bin/*
|
---|
102 | strip --strip-debug /stage1/lib/*</userinput></screen></para>
|
---|
103 |
|
---|
104 | <para>The first of the above commands will skip some twenty files, reporting
|
---|
105 | that it doesn't recognize their file format. Most of them are scripts instead
|
---|
106 | of binaries.</para>
|
---|
107 |
|
---|
108 | <para>Take care <emphasis>not</emphasis> to use
|
---|
109 | <userinput>--strip-unneeded</userinput> on the libraries -- they would be
|
---|
110 | destroyed and you would have to build Glibc all over again.</para>
|
---|
111 |
|
---|
112 | <para>To save another couple of megabytes, you can throw away the documentation
|
---|
113 | and some of the bigger unneeded programs:</para>
|
---|
114 |
|
---|
115 | <para><screen><userinput>rm -r /stage1/share/{doc,info,man}
|
---|
116 | rm /stage1/bin/{addr2line,gprof,nm,size,strings,strip}</userinput></screen></para>
|
---|
117 |
|
---|
118 | <para>You will now need to have at least 700 MB of free space on your LFS
|
---|
119 | filesystem to be able to build and install Glibc in the next phase.</para>
|
---|
120 |
|
---|
121 | </sect1>
|
---|
122 |
|
---|
123 | </chapter>
|
---|
124 |
|
---|