1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3CR2//EN" "http://www.docbook.org/xml/4.3CR2/docbookx.dtd" [
3 <!ENTITY % binutils-entities SYSTEM "../ent/binutils.ent">
6 <sect1 id="ch05-binutils-pass1">
7 <title>Installing Binutils-&binutils-version; - Pass 1</title>
8 <?dbhtml filename="binutils-pass1.html"?>
10 <screen>Estimated build time: 1.0 SBU
11 Estimated required disk space: 194 MB</screen>
13 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../appendixa/binutils-contents.xml"/>
17 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../appendixa/binutils-deps.xml"/>
22 <title>Installation of Binutils</title>
24 <para>It is important that Binutils be the first package to get compiled,
25 because both Glibc and GCC perform various tests on the available linker and
26 assembler to determine which of their own features to enable.</para>
28 <note><para>Even though Binutils is an important toolchain package, we are not
29 going to run the test suite at this early stage. First, the test suite framework
30 is not yet in place and second, the programs from this first pass will soon be
31 overwritten by those installed in the second pass.</para></note>
33 <para>This package is known to behave badly when you have changed its default
34 optimization flags (including the -march and -mcpu options). Therefore, if
35 you have defined any environment variables that override default
36 optimizations, such as CFLAGS and CXXFLAGS, we recommend unsetting or
37 modifying them when building Binutils.</para>
39 <para>The Binutils documentation recommends building Binutils outside of the
40 source directory in a dedicated build directory:</para>
42 <screen><userinput>mkdir ../binutils-build
43 cd ../binutils-build</userinput></screen>
45 <note><para>If you want the SBU values listed in the rest of the book to be of
46 any use, you will have to measure the time it takes to build this package. To
47 achieve this easily, you could do something like:
48 <userinput>time { ./configure ... && ... && ... && make install; }</userinput>.</para></note>
50 <para>Now prepare Binutils for compilation:</para>
52 <screen><userinput>../binutils-&binutils-version;/configure \
53 --prefix=/tools --disable-nls</userinput></screen>
55 <para>The meaning of the configure options:</para>
58 <listitem><para><userinput>--prefix=/tools</userinput>: This tells the
59 configure script to prepare to install the Binutils programs in the
60 <filename>/tools</filename> directory.</para></listitem>
62 <listitem><para><userinput>--disable-nls</userinput>: This disables
63 internationalization (a word often shortened to i18n). We don't need this
64 for our static programs and <emphasis>nls</emphasis> often causes problems
65 when linking statically.</para></listitem>
68 <para>Continue with compiling the package:</para>
70 <screen><userinput>make configure-host
71 make LDFLAGS="-all-static"</userinput></screen>
73 <para>The meaning of the make parameters:</para>
76 <listitem><para><userinput>configure-host</userinput>: This forces all the
77 subdirectories to be configured immediately. A statically linked build will
78 fail without it. We therefore use this option to work around the
79 problem.</para></listitem>
81 <listitem><para><userinput>LDFLAGS="-all-static"</userinput>: This tells the
82 linker that all the Binutils programs should be linked statically. However,
83 strictly speaking, <userinput>"-all-static"</userinput> is first passed to the
84 <emphasis>libtool</emphasis> program which then passes
85 <userinput>"-static"</userinput> on to the linker.</para></listitem>
88 <para>And install the package:</para>
90 <screen><userinput>make install</userinput></screen>
92 <para>Now prepare the linker for the "locking in" of Glibc later on:</para>
94 <screen><userinput>make -C ld clean
95 make -C ld LDFLAGS="-all-static" LIB_PATH=/tools/lib</userinput></screen>
97 <para>The meaning of the make parameters:</para>
100 <listitem><para><userinput>-C ld clean</userinput>: This tells the make program
101 to remove all the compiled files, but only in the <filename>ld</filename>
102 subdirectory.</para></listitem>
104 <listitem><para><userinput>-C ld LDFLAGS="-all-static" LIB_PATH=/tools/lib</userinput>:
105 This option rebuilds everything in the <filename>ld</filename> subdirectory.
106 Specifying the LIB_PATH makefile variable on the command line allows us to
107 override the default value and have it point to our temporary tools location.
108 The value of this variable specifies the linker's default library search path.
109 You'll see how this preparation is used later on in the
110 chapter.</para></listitem>
114 <warning><para>Do not yet remove the Binutils build and source directories. You
115 will need them again in their current state a bit further on in this
116 chapter.</para></warning>