aboutsummaryrefslogtreecommitdiffstats
path: root/chapter05
diff options
context:
space:
mode:
authorJeremy Huntwork <jhuntwork@linuxfromscratch.org>2008-12-03 22:46:04 +0000
committerJeremy Huntwork <jhuntwork@linuxfromscratch.org>2008-12-03 22:46:04 +0000
commit6e886330cf157dc71e6a0a1fca410d7005683167 (patch)
tree0d8c4ae5a6429328469c512bb9f6661ad3886e19 /chapter05
parentb0e1dc860c471d7047fc906001f3a336ef5f357c (diff)
Initial addition of support for x86_64
git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@8754 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689
Diffstat (limited to 'chapter05')
-rw-r--r--chapter05/adjusting.xml25
-rw-r--r--chapter05/binutils-pass1.xml7
-rw-r--r--chapter05/gcc-pass1.xml9
-rw-r--r--chapter05/gcc-pass2.xml17
-rw-r--r--chapter05/glibc.xml4
-rw-r--r--chapter05/toolchaintechnotes.xml21
6 files changed, 52 insertions, 31 deletions
diff --git a/chapter05/adjusting.xml b/chapter05/adjusting.xml
index 35d77a78f..a916e3621 100644
--- a/chapter05/adjusting.xml
+++ b/chapter05/adjusting.xml
@@ -32,23 +32,21 @@ ln -sv /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld</userinput></screen>
<para>The next task is to point GCC to the new dynamic linker. This is done by
dumping GCC's <quote>specs</quote> file to a location where GCC will look for it
by default. A simple <command>sed</command> substitution then alters the
- dynamic linker that GCC will use.</para>
+ dynamic linker that GCC will use. The principle here is to find all references
+ to the dynamic linker file in <filename class="directory">/lib</filename>
+ or possibly <filename class="directory">/lib64</filename> if the host system
+ is 64-bit capable, and adjust them to point to the new location in
+ <filename class="directory">/tools</filename>.</para>
<para>For the sake of accuracy, it is recommended to use a copy-and-paste
method when issuing the following command. Be sure to visually inspect the
- specs file and verify that all occurrences of <quote>/lib/ld-linux.so.2</quote>
- have been replaced with <quote>/tools/lib/ld-linux.so.2</quote>:</para>
-
- <important>
- <para>If working on a platform where the name of the dynamic linker is
- something other than <filename class="libraryfile">ld-linux.so.2</filename>,
- replace <quote>ld-linux.so.2</quote> with the name of the platform's
- dynamic linker in the following commands. Refer to <xref
- linkend="ch-tools-toolchaintechnotes" role=","/> if necessary.</para>
- </important>
+ specs file to verify that it has properly adjusted all references to the
+ dynamic linker location. Refer to <xref
+ linkend="ch-tools-toolchaintechnotes" role=","/> for the default name
+ of the dynamic linker, if necessary.</para>
<!-- Ampersands are needed to allow copy and paste -->
-<screen><userinput>gcc -dumpspecs | sed 's@/lib/ld-linux.so.2@/tools&amp;@g' &gt; \
+<screen><userinput>gcc -dumpspecs | sed 's@/lib\(64\)\?/ld@/tools&amp;@g' &gt; \
`dirname $(gcc -print-libgcc-file-name)`/specs</userinput></screen>
<para>During the build process, GCC runs a script
@@ -86,7 +84,8 @@ readelf -l a.out | grep ': /tools'</userinput></screen>
<screen><computeroutput>[Requesting program interpreter:
/tools/lib/ld-linux.so.2]</computeroutput></screen>
- <para>Note that <filename class="directory">/tools/lib</filename>
+ <para>Note that <filename class="directory">/tools/lib</filename>, or
+ <filename class="directory">/tools/lib64</filename> for 64-bit machines
appears as the prefix of the dynamic linker.</para>
<para>If the output is not shown as above or there was no output at all,
diff --git a/chapter05/binutils-pass1.xml b/chapter05/binutils-pass1.xml
index 805f7c996..6644c2250 100644
--- a/chapter05/binutils-pass1.xml
+++ b/chapter05/binutils-pass1.xml
@@ -124,11 +124,16 @@ cd ../binutils-build</userinput></screen>
tests at this point are minimal since the programs from this
first pass will soon be replaced by those from the second.</para>
+ <para>Create a symlink to ensure the sanity of our toolchain:</para>
+
+<screen><userinput remap="install">mkdir -v /tools/lib
+ln -sv lib /tools/lib64</userinput></screen>
+
<para>Install the package:</para>
<screen><userinput remap="install">make install</userinput></screen>
- <para>Next, prepare the linker for the <quote>Adjusting</quote> phase
+ <para>Finally, prepare the linker for the <quote>Adjusting</quote> phase
later on:</para>
<screen><userinput remap="adjust">make -C ld clean
diff --git a/chapter05/gcc-pass1.xml b/chapter05/gcc-pass1.xml
index c862d3f73..d9c6175ff 100644
--- a/chapter05/gcc-pass1.xml
+++ b/chapter05/gcc-pass1.xml
@@ -62,7 +62,7 @@ cd ../gcc-build</userinput></screen>
<screen><userinput remap="configure">CC="gcc -B/usr/bin/" ../gcc-&gcc-version;/configure --prefix=/tools \
--with-local-prefix=/tools --disable-nls --disable-shared --disable-libssp \
- --enable-languages=c</userinput></screen>
+ --disable-multilib --enable-languages=c</userinput></screen>
<variablelist>
<title>The meaning of the configure options:</title>
@@ -114,6 +114,13 @@ cd ../gcc-build</userinput></screen>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><parameter>--disable-multilib</parameter></term>
+ <listitem>
+ <para>We currently only want to build support for 64-bit libraries.</para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
<para>The following command will compile GCC not once, but several times. It
diff --git a/chapter05/gcc-pass2.xml b/chapter05/gcc-pass2.xml
index 5a41c879d..bbdda355f 100644
--- a/chapter05/gcc-pass2.xml
+++ b/chapter05/gcc-pass2.xml
@@ -99,7 +99,8 @@ sed 's/^XCFLAGS =$/&amp; -fomit-frame-pointer/' gcc/Makefile.in.tmp \
GCC. That is, all of the binaries created during the build will link
against the new Glibc. Issue:</para>
-<screen><userinput remap="pre">for file in $(find gcc/config -name linux64.h -o -name linux.h)
+<screen><userinput remap="pre">for file in \
+ $(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h)
do
cp -uv $file{,.orig}
sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&amp;@g' \
@@ -112,7 +113,8 @@ done</userinput></screen>
<para>In case the above seems hard to follow, let's break it down a bit.
First we find all the files under the gcc/config directory that are named
- either <filename>linux.h</filename> or <filename>linux64.h</filename>.
+ either <filename>linux.h</filename>, <filename>linux64.h</filename> or
+ <filename>sysv4.h</filename>.
For each file found, we copy it to a file of the same name but with an added
suffix of <quote>.orig</quote>. Then the first sed expression prepends
<quote>/tools</quote> to every instance of <quote>/lib/ld</quote>,
@@ -124,6 +126,14 @@ done</userinput></screen>
changes to the original files in case the command is inadvertently run twice.
</para>
+ <para>Unsetting the multlib spec for GCC ensures that it
+ won't attempt to link against libraries on the host:</para>
+
+<screen><userinput remap="pre">for file in $(find gcc/config -name t-linux64) ; do \
+ cp -v $file{,.orig}
+ sed '/MULTILIB_OSDIRNAMES/d' $file.orig &gt; $file
+done</userinput></screen>
+
<para>As in the first build of GCC it requires the GMP and MPFR packages.
Unpack the tarballs and move them into the required directory names:</para>
@@ -146,7 +156,8 @@ cd ../gcc-build</userinput></screen>
--with-local-prefix=/tools --enable-clocale=gnu \
--enable-shared --enable-threads=posix \
--enable-__cxa_atexit --enable-languages=c,c++ \
- --disable-libstdcxx-pch --disable-bootstrap</userinput></screen>
+ --disable-libstdcxx-pch --disable-multilib \
+ --disable-bootstrap</userinput></screen>
<variablelist>
<title>The meaning of the new configure options:</title>
diff --git a/chapter05/glibc.xml b/chapter05/glibc.xml
index 23a8d2351..3252c5a10 100644
--- a/chapter05/glibc.xml
+++ b/chapter05/glibc.xml
@@ -64,7 +64,9 @@ cd ../glibc-build</userinput></screen>
-mtune=native flag is also necessary to reset a reasonable value for -mtune
that is changed when setting -march.</para>
-<screen><userinput remap="configure">echo "CFLAGS += -march=i486 -mtune=native" &gt; configparms</userinput></screen>
+<screen><userinput remap="configure">case `uname -m` in
+ i?86) echo "CFLAGS += -march=i486 -mtune=native" &gt; configparms ;;
+esac</userinput></screen>
<para>Next, prepare Glibc for compilation:</para>
diff --git a/chapter05/toolchaintechnotes.xml b/chapter05/toolchaintechnotes.xml
index cc1f7242e..f6adefb61 100644
--- a/chapter05/toolchaintechnotes.xml
+++ b/chapter05/toolchaintechnotes.xml
@@ -27,24 +27,21 @@
<important>
<para>Before continuing, be aware of the name of the working platform,
- often referred to as the target triplet. Many times, the target
- triplet will probably be <emphasis>i686-pc-linux-gnu</emphasis>. A
- simple way to determine the name of the target triplet is to run the
- <command>config.guess</command> script that comes with the source for
- many packages. Unpack the Binutils sources and run the script:
- <userinput>./config.guess</userinput> and note the output.</para>
+ often referred to as the target triplet. A simple way to determine the
+ name of the target triplet is to run the <command>config.guess</command>
+ script that comes with the source for many packages. Unpack the Binutils
+ sources and run the script: <userinput>./config.guess</userinput> and note
+ the output. For example, for a modern 32-bit Intel processor the
+ output will likely be <emphasis>i686-pc-linux-gnu</emphasis>.</para>
<para>Also be aware of the name of the platform's dynamic linker, often
referred to as the dynamic loader (not to be confused with the standard
linker <command>ld</command> that is part of Binutils). The dynamic linker
provided by Glibc finds and loads the shared libraries needed by a program,
prepares the program to run, and then runs it. The name of the dynamic
- linker will usually be <filename class="libraryfile">ld-linux.so.2</filename>.
- On platforms that are less prevalent, the name might be <filename
- class="libraryfile">ld.so.1</filename>, and newer 64 bit platforms might
- be named something else entirely. The name of the platform's dynamic linker
- can be determined by looking in the <filename class="directory">/lib</filename>
- directory on the host system. A sure-fire way to determine the name is to
+ linker for a 32-bit Intel machine will be
+ <filename class="libraryfile">ld-linux.so.2</filename>.
+ A sure-fire way to determine the name of the dynamic linker is to
inspect a random binary from the host system by running:
<userinput>readelf -l &lt;name of binary&gt; | grep interpreter</userinput>
and noting the output. The authoritative reference covering all platforms