adjustingtoolchain.xml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <sect1 id="ch06-adjustingtoolchain">
  2. <title>Adjusting toolchain</title>
  3. <?dbhtml filename="adjustingtoolchain.html" dir="chapter06"?>
  4. <para>Now that we have compiled all the necessary tools, it is time to
  5. re-adjust our toolchain. We will set it up so that it will link any newly
  6. compiled program against the new Glibc. Basically, this is the reverse of
  7. what we did in the "Locking in" stage in the beginning of chapter 5.</para>
  8. <para>The first thing to do is to adjust the linker scripts. For this we
  9. retained the <filename class="directory">binutils-build</filename>
  10. directory from the second pass over Binutils. Run the following:</para>
  11. <para><screen><userinput>cd binutils-build
  12. make -C ld INSTALL=/stage1/bin/install install-data-local</userinput></screen></para>
  13. <para>This installs the adjusted linker scripts. The linker scripts contain
  14. no mention of <filename class="directory">/stage1/lib</filename> anymore.
  15. From now on every compiled program will link <emphasis>only</emphasis>
  16. against the libraries in <filename>/usr/lib</filename> and
  17. <filename>/lib</filename>. The extra
  18. <userinput>INSTALL=/stage1/bin/install</userinput> is needed because the
  19. Makefile created during the second pass still contains the reference to
  20. <filename>/usr/bin/install</filename>, which we obviously haven't installed
  21. yet.</para>
  22. <para>You can now remove the Binutils source and build directories.</para>
  23. <para>The next thing to do is to amend our GCC specs file so that it points
  24. to the new dynamic linker. Just like earlier on, we use a sed to accomplish
  25. this:</para>
  26. <para><screen><userinput>SPECFILE=/stage1/lib/gcc-lib/*/*/specs
  27. sed -e 's@/stage1/lib/ld.so.1@/lib/ld.so.1@g' \
  28. &nbsp;&nbsp;&nbsp;&nbsp;-e 's@/stage1/lib/ld-linux.so.2@/lib/ld-linux.so.2@g' $SPECFILE > XX
  29. mv XX $SPECFILE
  30. unset SPECFILE</userinput></screen></para>
  31. <para>Again, cutting and pasting the above is recommended. And just like
  32. before, it is a good idea to check the linker scripts and the specs file o
  33. ensure the intended changes were actually made.</para>
  34. <para>Note that the linker scripts will still contain a reference to
  35. <filename class="directory">/stage1/i686-pc-linux-gnu/lib</filename>. This
  36. is unavoidable, but luckily does not present a problem. There are no
  37. libraries in that location as all the temporary stage1 libraries are
  38. located in <filename class="directory">/stage1/lib</filename>.</para>
  39. </sect1>