Ignore:
Timestamp:
04/25/2012 07:26:21 PM (12 years ago)
Author:
Bruce Dubbs <bdubbs@…>
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
Message:

Merge changes developed and tested in the jh branch

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@9831 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chapter05/toolchaintechnotes.xml

    re625c49 r1a3e6a3  
    7272    </listitem>
    7373    <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>
    7776    </listitem>
    7877  </itemizedlist>
     
    119118  including <command>gcc</command>'s included search paths and their order.</para>
    120119
     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
    121124  <para>The next package installed is Glibc. The most important considerations
    122125  for building Glibc are the compiler, binary tools, and kernel headers. The
     
    137140  generally does not rely on toolchain defaults.</para>
    138141
    139   <para>After the Glibc installation, change <command>gcc</command>'s specs file
    140   to point to the new dynamic linker in <filename
    141   class="directory">/tools/lib</filename>.  This last step is vital in ensuring
    142   that searching and linking take place only within the <filename
    143   class="directory">/tools</filename> prefix. A hard-wired
    144   path to a dynamic linker is embedded into every Executable and Link Format
    145   (ELF)-shared executable.  This can be inspected by running:
    146   <userinput>readelf -l &lt;name of binary&gt; | grep interpreter</userinput>.
    147   Amending <command>gcc</command>'s specs file ensures that every program
    148   compiled from here through the end of this chapter will use the new dynamic
    149   linker in <filename class="directory">/tools/lib</filename>.</para>
    150 
    151   <para>For the second pass of GCC, its sources also need to be modified
    152   to tell GCC to use the new dynamic linker. Failure to do
    153   so will result in the GCC programs themselves having the name of the
    154   dynamic linker from the host system's <filename
    155   class="directory">/lib</filename> directory embedded into them, which
    156   would defeat the goal of getting away from the host.</para>
    157 
    158142  <para>During the second pass of Binutils, we are able to utilize the
    159143  <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>
    164155
    165156  <para>Upon entering the chroot environment in <xref
     
    171162  LFS system.</para>
    172163
    173   <!-- FIXME: Removed as part of the fix for bug 1061 - we no longer build pass1
    174       packages statically, therefore this explanation isn't required
    175 
    176   <sect2>
    177   <title>Notes on Static Linking</title>
    178 
    179   <para>Besides their specific task, most programs have to perform many
    180   common and sometimes trivial operations. These include allocating
    181   memory, searching directories, reading and writing files, string
    182   handling, pattern matching, arithmetic, and other tasks. Instead of
    183   obliging each program to reinvent the wheel, the GNU system provides
    184   all these basic functions in ready-made libraries. The major library
    185   on any Linux system is Glibc.</para>
    186 
    187   <para>There are two primary ways of linking the functions from a
    188   library to a program that uses them&mdash;statically or dynamically. When
    189   a program is linked statically, the code of the used functions is
    190   included in the executable, resulting in a rather bulky program. When
    191   a program is dynamically linked, it includes a reference to the
    192   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 the
    194   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 major
    198   advantages over static linking. First, only one copy of the executable
    199   library code is needed on the hard disk, instead of having multiple
    200   copies of the same code included in several programs, thus saving
    201   disk space. Second, when several programs use the same library
    202   function at the same time, only one copy of the function's code is
    203   required in core, thus saving memory space. Third, when a library
    204   function gets a bug fixed or is otherwise improved, only the one
    205   library needs to be recompiled instead of recompiling all programs
    206   that make use of the improved function.</para>
    207 
    208   <para>If dynamic linking has several advantages, why then do we
    209   statically link the first two packages in this chapter? The reasons
    210   are threefold&mdash;historical, educational, and technical. The
    211   historical reason is that earlier versions of LFS statically linked
    212   every program in this chapter. Educationally, knowing the difference
    213   between static and dynamic linking is useful. The technical benefit is
    214   a gained element of independence from the host, meaning that those
    215   programs can be used independently of the host system. However, it is
    216   worth noting that an overall successful LFS build can still be
    217   achieved when the first two packages are built dynamically.</para>
    218 
    219   </sect2>-->
    220 
    221164</sect1>
Note: See TracChangeset for help on using the changeset viewer.