source: chapter05/binutils-pass1.xml@ 6e6641f

12.2 12.2-rc1 multilib trunk xry111/arm64 xry111/clfs-ng xry111/loongarch xry111/loongarch-12.2 xry111/multilib
Last change on this file since 6e6641f was 6e6641f, checked in by Xi Ruoyao <xry111@…>, 2 months ago

binutils: Add --enable-new-dtags

This option makes ld use DT_RUNPATH instead of DT_RPATH. DT_RPATH is
generally considered bad because it takes precedence over
LD_LIBRARY_PATH. For example, eog is linked with -rpath /usr/lib/eog,
and with DT_RPATH if an old eog is already installed we are basically
impossible to debug a new eog build w/o overwriting the system
installation first or explicitly using "ld.so --inhibit-rpath" to
invoke it.

This "new" actually means "new in 2000," it's 24 years ago and all other
distros has enabled it. Thus I guess some unexplainable "test suite
uses installed library instead of the just built one" issues in BLFS are
actually caused by this difference: the package author just assumes
everyone is using DT_RUNPATH thus they just set LD_LIBRARY_PATH and
consider it enough to test with the just built libraries, but DT_RPATH
breaks this expectation.

Let's eliminate the difference as it seems not doing anything good and
doing so just takes one switch.

  • Property mode set to 100644
File size: 6.4 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
4 <!ENTITY % general-entities SYSTEM "../general.ent">
5 %general-entities;
6]>
7
8<sect1 id="ch-tools-binutils-pass1" role="wrap">
9 <?dbhtml filename="binutils-pass1.html"?>
10
11 <sect1info condition="script">
12 <productname>binutils-pass1</productname>
13 <productnumber>&binutils-version;</productnumber>
14 <address>&binutils-url;</address>
15 </sect1info>
16
17 <title>Binutils-&binutils-version; - Pass 1</title>
18
19 <indexterm zone="ch-tools-binutils-pass1">
20 <primary sortas="a-Binutils">Binutils</primary>
21 <secondary>tools, pass 1</secondary>
22 </indexterm>
23
24 <sect2 role="package">
25 <title/>
26
27 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
28 href="../chapter08/binutils.xml"
29 xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
30
31 <segmentedlist>
32 <segtitle>&buildtime;</segtitle>
33 <segtitle>&diskspace;</segtitle>
34
35 <seglistitem>
36 <seg>&binutils-tmpp1-sbu;</seg>
37 <seg>&binutils-tmpp1-du;</seg>
38 </seglistitem>
39 </segmentedlist>
40
41 </sect2>
42
43 <sect2 role="installation">
44 <title>Installation of Cross Binutils</title>
45
46 <note><para>Go back and re-read the notes in the section titled <xref
47 linkend="ch-tools-generalinstructions"/>.
48 Understanding the notes labeled important can save you a lot
49 of problems later.</para></note>
50
51 <para>It is important that Binutils be the first package compiled
52 because both Glibc and GCC perform various tests on the available
53 linker and assembler to determine which of their own features to
54 enable.</para>
55
56 <para>The Binutils documentation recommends building Binutils
57 in a dedicated build directory:</para>
58
59<screen><userinput remap="pre">mkdir -v build
60cd build</userinput></screen>
61
62 <note>
63 <para>In order for the SBU values listed in the rest of the book
64 to be of any use, measure the time it takes to build this package from
65 the configuration, up to and including the first install. To achieve
66 this easily, wrap the commands in a <command>time</command>
67 command like this: <userinput>time { ../configure ... &amp;&amp; make
68 &amp;&amp; make install; }</userinput>.</para>
69 </note>
70
71 <para>Now prepare Binutils for compilation:</para>
72
73 <screen><userinput remap="configure">../configure --prefix=$LFS/tools \
74 --with-sysroot=$LFS \
75 --target=$LFS_TGT \
76 --disable-nls \
77 --enable-gprofng=no \
78 --disable-werror \
79 --enable-new-dtags \
80 --enable-default-hash-style=gnu</userinput></screen>
81
82 <variablelist>
83 <title>The meaning of the configure options:</title>
84
85 <varlistentry>
86 <term><parameter>--prefix=$LFS/tools</parameter></term>
87 <listitem>
88 <para>This tells the configure script to prepare to install the
89 Binutils programs in the <filename
90 class="directory">$LFS/tools</filename> directory.</para>
91 </listitem>
92 </varlistentry>
93
94 <varlistentry>
95 <term><parameter>--with-sysroot=$LFS</parameter></term>
96 <listitem>
97 <para>For cross compilation, this tells the build system to look in
98 $LFS for the target system libraries as needed.</para>
99 </listitem>
100 </varlistentry>
101
102 <varlistentry>
103 <term><envar>--target=$LFS_TGT</envar></term>
104 <listitem>
105 <para>Because the machine description in the <envar>LFS_TGT</envar>
106 variable is slightly different than the value returned by the
107 <command>config.guess</command> script, this switch will tell the
108 <command>configure</command> script to adjust binutil's build system
109 for building a cross linker. </para>
110 </listitem>
111 </varlistentry>
112
113 <varlistentry>
114 <term><parameter>--disable-nls</parameter></term>
115 <listitem>
116 <para>This disables internationalization as i18n is not needed for the
117 temporary tools.</para>
118 </listitem>
119 </varlistentry>
120
121 <varlistentry>
122 <term><parameter>--enable-gprofng=no</parameter></term>
123 <listitem>
124 <para>This disables building gprofng which is not needed for the
125 temporary tools.</para>
126 </listitem>
127 </varlistentry>
128
129 <varlistentry>
130 <term><parameter>--disable-werror</parameter></term>
131 <listitem>
132 <para>This prevents the build from stopping in the event that there
133 are warnings from the host's compiler.</para>
134 </listitem>
135 </varlistentry>
136
137 <varlistentry>
138 <term><parameter>--enable-new-dtags</parameter></term>
139 <listitem>
140 <para>This makes the linker use the <quote>runpath</quote> tag for
141 embedding library search paths into executables and shared libraries,
142 instead of the traditional <quote>rpath</quote> tag. It makes
143 debugging dynamically linked executables easier and works around
144 potential issues in the test suite of some packages.</para>
145 </listitem>
146 </varlistentry>
147
148 <varlistentry>
149 <term><parameter>--enable-default-hash-style=gnu</parameter></term>
150 <listitem>
151 <para>By default, the linker would generate both the GNU-style
152 hash table and the classic ELF hash table for shared libraries and
153 dynamically linked executables. The hash tables are only intended
154 for a dynamic linker to perform symbol lookup. On LFS the dynamic
155 linker (provided by the Glibc package) will always use the
156 GNU-style hash table which is faster to query. So the classic
157 ELF hash table is completely useless. This makes the linker
158 only generate the GNU-style hash table by default, so we can avoid
159 wasting time to generate the classic ELF hash table when we build
160 the packages, or wasting disk space to store it.</para>
161 </listitem>
162 </varlistentry>
163
164 </variablelist>
165
166 <para>Continue with compiling the package:</para>
167
168<screen><userinput remap="make">make</userinput></screen>
169
170 <para>Install the package:</para>
171
172<screen><userinput remap="install">make install</userinput></screen>
173
174 </sect2>
175
176 <sect2 role="content">
177 <title/>
178
179 <para>Details on this package are located in
180 <xref linkend="contents-binutils" role="."/></para>
181
182 </sect2>
183
184</sect1>
Note: See TracBrowser for help on using the repository browser.