binutils-pass1-inst.xml 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <sect2><title>&nbsp;</title><para>&nbsp;</para></sect2>
  2. <sect2>
  3. <title>Installation of Binutils</title>
  4. <para>It is important that Binutils be the first package to get compiled,
  5. because both Glibc and GCC perform various tests on the available linker and
  6. assembler to determine which of their own features to enable.</para>
  7. <note><para>Even though Binutils is an important toolchain package, we are not
  8. going to run the test suite at this early stage. First, the test suite framework
  9. is not yet in place and second, the programs from this first pass will soon be
  10. overwritten by those installed in the second pass.</para></note>
  11. <para>This package is known to behave badly when you have changed its default
  12. optimization flags (including the -march and -mcpu options). Therefore, if
  13. you have defined any environment variables that override default
  14. optimizations, such as CFLAGS and CXXFLAGS, we recommend unsetting or
  15. modifying them when building Binutils.</para>
  16. <para>The Binutils documentation recommends building Binutils outside of the
  17. source directory in a dedicated build directory:</para>
  18. <para><screen><userinput>mkdir ../binutils-build
  19. cd ../binutils-build</userinput></screen></para>
  20. <para>Next, prepare Binutils to be compiled:</para>
  21. <para><screen><userinput>../binutils-&binutils-version;/configure \
  22. &nbsp;&nbsp;&nbsp;&nbsp;--prefix=/tools --disable-nls</userinput></screen></para>
  23. <para>The meaning of the configure options:</para>
  24. <itemizedlist>
  25. <listitem><para><userinput>--prefix=/tools</userinput>: This tells the
  26. configure script to prepare to install the Binutils programs in the
  27. <filename>/tools</filename> directory.</para></listitem>
  28. <listitem><para><userinput>--disable-nls</userinput>: This disables
  29. internationalization (a word often shortened to i18n). We don't need this
  30. for our static programs and <emphasis>nls</emphasis> often causes problems
  31. when linking statically.</para></listitem>
  32. </itemizedlist>
  33. <para>Continue with compiling the package:</para>
  34. <para><screen><userinput>make configure-host
  35. make LDFLAGS="-all-static"</userinput></screen></para>
  36. <para>The meaning of the make option:</para>
  37. <itemizedlist>
  38. <listitem><para><userinput>LDFLAGS="-all-static"</userinput>: This tells the
  39. linker that all the Binutils programs should be linked statically. However,
  40. strictly speaking, <userinput>"-all-static"</userinput> is first passed to the
  41. <emphasis>libtool</emphasis> program which then passes
  42. <userinput>"-static"</userinput> on to the linker.</para></listitem>
  43. </itemizedlist>
  44. <para>And install the package:</para>
  45. <para><screen><userinput>make install</userinput></screen></para>
  46. <para>Now prepare the linker for the "locking in" of Glibc later on:</para>
  47. <para><screen><userinput>make -C ld clean
  48. make -C ld LIB_PATH=/tools/lib</userinput></screen></para>
  49. <para>The meaning of the make options:</para>
  50. <itemizedlist>
  51. <listitem><para><userinput>-C ld clean</userinput>: This tells the make program
  52. to remove all the compiled files, but only in the <filename>ld</filename>
  53. subdirectory.</para></listitem>
  54. <listitem><para><userinput>-C ld LIB_PATH=/tools/lib</userinput>: This option
  55. rebuilds everything in the <filename>ld</filename> subdirectory. Specifying the
  56. LIB_PATH makefile variable on the command line allows us to override the default
  57. value and have it point to our temporary tools location. The value of this
  58. variable specifies the linker's default library search path. You'll see how this
  59. preparation is utilised later on in the chapter.</para></listitem>
  60. </itemizedlist>
  61. <warning><para>Do not yet remove the Binutils build and source directories. You
  62. will need them again in their current state a bit further on in this
  63. chapter.</para></warning>
  64. </sect2>