source: chapter06/readjusting.xml@ 29723b9

Last change on this file since 29723b9 was 6a0e6f3, checked in by Matthew Burgess <matthew@…>, 20 years ago
  • Remove the spurious <info> tags that I thought were necessary but evidently aren't

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

  • Property mode set to 100644
File size: 4.8 KB
RevLine 
[673b0d8]1<?xml version="1.0" encoding="ISO-8859-1"?>
[1fe35e1]2<!DOCTYPE section [
[673b0d8]3 <!ENTITY % general-entities SYSTEM "../general.ent">
4 %general-entities;
5]>
[1fe35e1]6<section xmlns="http://docbook.org/docbook-ng"
7 xml:id="ch-system-readjusting">
[6a0e6f3]8<title>Re-adjusting the toolchain</title>
[673b0d8]9<?dbhtml filename="readjusting.html"?>
10
11<para>Now that the new and final C libraries have been installed, it's time to
12adjust our toolchain again. We'll adjust it so that it will link any newly
13compiled program against these new libraries. This is in fact the same thing we
14did in the <quote>Adjusting</quote> phase in the beginning of the previous
15chapter, even though it looks like the reverse: then we guided the chain from
16the host's <filename class="directory">/{,usr/}lib</filename> to the new
17<filename class="directory">/tools/lib</filename>, now we guide it from that
18same <filename class="directory">/tools/lib</filename> to the LFS's <filename
19class="directory">/{,usr/}lib</filename>.</para>
20
21<para>First we adjust the linker. For this we retained the
22source and build directories from the second pass over Binutils. Install the
23adjusted linker by running the following from within the
24<filename class="directory">binutils-build</filename> directory:</para>
25
26<screen><userinput>make -C ld INSTALL=/tools/bin/install install</userinput></screen>
27
28<note><para>If you somehow missed the earlier warning to retain the Binutils
29source and build directories from the second pass in
30<xref linkend="chapter-temporary-tools"/>, or otherwise accidentally deleted them or just
31don't have access to them, don't worry, all is not lost. Just ignore the above
32command. The result will be that the next package, Binutils, will link against
33the C libraries in <filename class="directory">/tools</filename> rather
34than in <filename class="directory">/{,usr/}lib</filename>. This is not ideal,
35however, our testing has shown that the resulting Binutils program binaries
36should be identical.</para></note>
37
38<para>From now on every compiled program will link <emphasis>only</emphasis>
[8ad7980]39against the libraries in <filename class="directory">/usr/lib</filename> and
40<filename class="directory">/lib</filename>. The extra
41<parameter>INSTALL=/tools/bin/install</parameter> is needed because the Makefile
[673b0d8]42created during the second pass still contains the reference to
[8ad7980]43<command>/usr/bin/install</command>, which we obviously haven't installed yet.
[673b0d8]44Some host distributions contain a <filename class="symlink">ginstall</filename>
45symbolic link which takes precedence in the Makefile and thus can cause a
46problem here. The above command takes care of this also.</para>
47
48<para>You can now remove the Binutils source and build directories.</para>
49
50<para>The next thing to do is to amend our GCC specs file so that it points
51to the new dynamic linker. Just like earlier on, we use a sed to accomplish
52this:</para>
53
54<!-- Ampersands are needed to allow cut and paste -->
55
[6e8fc7d]56<screen><userinput>perl -pi -e 's@ /tools/lib/ld-linux.so.2@ /lib/ld-linux.so.2@g;' \
57 -e 's@\*startfile_prefix_spec:\n@$_/usr/lib/@g;' \
[2ec4b60]58 `gcc --print-file specs`</userinput></screen>
[673b0d8]59
60<para>Again, cutting and pasting the above is recommended. And just like
61before, it is a good idea to visually inspect the specs file to verify the
62intended change was actually made.</para>
63
64<important><para>If you are working on a platform where the name of the dynamic
65linker is something other than <filename>ld-linux.so.2</filename>, you
66<emphasis>must</emphasis> substitute <filename>ld-linux.so.2</filename> with the
67name of your platform's dynamic linker in the above commands. Refer back to
68<xref linkend="ch-tools-toolchaintechnotes"/> if necessary.</para></important>
69
70
71<caution><para>It is imperative at this point to stop and ensure that the
72basic functions (compiling and linking) of the adjusted toolchain are working
73as expected. For this we are going to perform a simple sanity check:</para>
74
75<screen><userinput>echo 'main(){}' &gt; dummy.c
76cc dummy.c
77readelf -l a.out | grep ': /lib'</userinput></screen>
78
79<para>If everything is working correctly, there should be no errors, and the
80output of the last command will be (allowing for platform specific differences
81in dynamic linker name):</para>
82
[8ad7980]83<screen><computeroutput>[Requesting program interpreter: /lib/ld-linux.so.2]</computeroutput></screen>
[673b0d8]84
85<para>Note especially that <filename class="directory">/lib</filename> is now
86the prefix of our dynamic linker.</para>
87
88<para> If you did not receive the output
89as shown above, or received no output at all, then something is seriously wrong.
90You will need to investigate and retrace your steps to find out where the
91problem is and correct it. There is no point in continuing until this is done.
92Most likely something went wrong with the specs file amendment above.</para>
93
94<para>Once you are satisfied that all is well, clean up the test files:</para>
95
96<screen><userinput>rm dummy.c a.out</userinput></screen>
97</caution>
98
99
[1fe35e1]100</section>
Note: See TracBrowser for help on using the repository browser.