Changeset 1a3e6a3 for chapter05/toolchaintechnotes.xml
- Timestamp:
- 04/25/2012 07:26:21 PM (12 years ago)
- Branches:
- 10.0, 10.0-rc1, 10.1, 10.1-rc1, 11.0, 11.0-rc1, 11.0-rc2, 11.0-rc3, 11.1, 11.1-rc1, 11.2, 11.2-rc1, 11.3, 11.3-rc1, 12.0, 12.0-rc1, 12.1, 12.1-rc1, 7.2, 7.3, 7.4, 7.5, 7.5-systemd, 7.6, 7.6-systemd, 7.7, 7.7-systemd, 7.8, 7.8-systemd, 7.9, 7.9-systemd, 8.0, 8.1, 8.2, 8.3, 8.4, 9.0, 9.1, arm, bdubbs/gcc13, ml-11.0, multilib, renodr/libudev-from-systemd, s6-init, trunk, xry111/arm64, xry111/arm64-12.0, xry111/clfs-ng, xry111/lfs-next, xry111/loongarch, xry111/loongarch-12.0, xry111/loongarch-12.1, xry111/mips64el, xry111/pip3, xry111/rust-wip-20221008, xry111/update-glibc
- Children:
- cd3c10c
- Parents:
- e625c49
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
chapter05/toolchaintechnotes.xml
re625c49 r1a3e6a3 72 72 </listitem> 73 73 <listitem> 74 <para>Careful manipulation of <command>gcc</command>'s 75 <filename>specs</filename> file tells the compiler which target dynamic 76 linker will be used</para> 74 <para>Careful manipulation of the GCC source tells the compiler which target 75 dynamic linker will be used.</para> 77 76 </listitem> 78 77 </itemizedlist> … … 119 118 including <command>gcc</command>'s included search paths and their order.</para> 120 119 120 <para>Next installed are sanitized Linux API headers. These allow the standard 121 C library (Glibc) to interface with features that the Linux kernel will 122 provide.</para> 123 121 124 <para>The next package installed is Glibc. The most important considerations 122 125 for building Glibc are the compiler, binary tools, and kernel headers. The … … 137 140 generally does not rely on toolchain defaults.</para> 138 141 139 <para>After the Glibc installation, change <command>gcc</command>'s specs file140 to point to the new dynamic linker in <filename141 class="directory">/tools/lib</filename>. This last step is vital in ensuring142 that searching and linking take place only within the <filename143 class="directory">/tools</filename> prefix. A hard-wired144 path to a dynamic linker is embedded into every Executable and Link Format145 (ELF)-shared executable. This can be inspected by running:146 <userinput>readelf -l <name of binary> | grep interpreter</userinput>.147 Amending <command>gcc</command>'s specs file ensures that every program148 compiled from here through the end of this chapter will use the new dynamic149 linker in <filename class="directory">/tools/lib</filename>.</para>150 151 <para>For the second pass of GCC, its sources also need to be modified152 to tell GCC to use the new dynamic linker. Failure to do153 so will result in the GCC programs themselves having the name of the154 dynamic linker from the host system's <filename155 class="directory">/lib</filename> directory embedded into them, which156 would defeat the goal of getting away from the host.</para>157 158 142 <para>During the second pass of Binutils, we are able to utilize the 159 143 <parameter>--with-lib-path</parameter> configure switch to control 160 <command>ld</command>'s library search path. From this point onwards, 161 the core toolchain is self-contained and self-hosted. The remainder of 162 the <xref linkend="chapter-temporary-tools"/> packages all build against 163 the new Glibc in <filename class="directory">/tools</filename>.</para> 144 <command>ld</command>'s library search path.</para> 145 146 <para>For the second pass of GCC, its sources also need to be modified to 147 tell GCC to use the new dynamic linker. Failure to do so will result in the 148 GCC programs themselves having the name of the dynamic linker from the host 149 system's <filename class="directory">/lib</filename> directory embedded into 150 them, which would defeat the goal of getting away from the host. From this 151 point onwards, the core toolchain is self-contained and self-hosted. The 152 remainder of the <xref linkend="chapter-temporary-tools"/> packages all build 153 against the new Glibc in <filename 154 class="directory">/tools</filename>.</para> 164 155 165 156 <para>Upon entering the chroot environment in <xref … … 171 162 LFS system.</para> 172 163 173 <!-- FIXME: Removed as part of the fix for bug 1061 - we no longer build pass1174 packages statically, therefore this explanation isn't required175 176 <sect2>177 <title>Notes on Static Linking</title>178 179 <para>Besides their specific task, most programs have to perform many180 common and sometimes trivial operations. These include allocating181 memory, searching directories, reading and writing files, string182 handling, pattern matching, arithmetic, and other tasks. Instead of183 obliging each program to reinvent the wheel, the GNU system provides184 all these basic functions in ready-made libraries. The major library185 on any Linux system is Glibc.</para>186 187 <para>There are two primary ways of linking the functions from a188 library to a program that uses them—statically or dynamically. When189 a program is linked statically, the code of the used functions is190 included in the executable, resulting in a rather bulky program. When191 a program is dynamically linked, it includes a reference to the192 dynamic linker, the name of the library, and the name of the function,193 resulting in a much smaller executable. A third option is to use the194 programming interface of the dynamic linker (see <filename>dlopen(3)</filename>195 for more information).</para>196 197 <para>Dynamic linking is the default on Linux and has three major198 advantages over static linking. First, only one copy of the executable199 library code is needed on the hard disk, instead of having multiple200 copies of the same code included in several programs, thus saving201 disk space. Second, when several programs use the same library202 function at the same time, only one copy of the function's code is203 required in core, thus saving memory space. Third, when a library204 function gets a bug fixed or is otherwise improved, only the one205 library needs to be recompiled instead of recompiling all programs206 that make use of the improved function.</para>207 208 <para>If dynamic linking has several advantages, why then do we209 statically link the first two packages in this chapter? The reasons210 are threefold—historical, educational, and technical. The211 historical reason is that earlier versions of LFS statically linked212 every program in this chapter. Educationally, knowing the difference213 between static and dynamic linking is useful. The technical benefit is214 a gained element of independence from the host, meaning that those215 programs can be used independently of the host system. However, it is216 worth noting that an overall successful LFS build can still be217 achieved when the first two packages are built dynamically.</para>218 219 </sect2>-->220 221 164 </sect1>
Note:
See TracChangeset
for help on using the changeset viewer.