Changeset 6e88633


Ignore:
Timestamp:
12/03/2008 10:46:04 PM (15 years ago)
Author:
Jeremy Huntwork <jhuntwork@…>
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, 6.5, 6.6, 6.7, 6.8, 7.0, 7.1, 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:
4e82d47
Parents:
b0e1dc8
Message:

Initial addition of support for x86_64

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

Files:
14 edited

Legend:

Unmodified
Added
Removed
  • chapter01/changelog.xml

    rb0e1dc8 r6e88633  
    3737
    3838-->
     39    <listitem>
     40      <para>2008-12-03</para>
     41      <itemizedlist>
     42        <listitem>
     43          <para>[jhuntwork] - Initial addition of support for building on x86_64.
     44          Several ideas, principles and build instructions originated in DIY-Linux.
     45          Thanks, Greg Schafer.</para>
     46        </listitem>
     47      </itemizedlist>
     48    </listitem>
     49
    3950    <listitem>
    4051      <para>2008-12-02</para>
  • chapter05/adjusting.xml

    rb0e1dc8 r6e88633  
    3333  dumping GCC's <quote>specs</quote> file to a location where GCC will look for it
    3434  by default. A simple <command>sed</command> substitution then alters the
    35   dynamic linker that GCC will use.</para>
     35  dynamic linker that GCC will use. The principle here is to find all references
     36  to the dynamic linker file in <filename class="directory">/lib</filename>
     37  or possibly <filename class="directory">/lib64</filename> if the host system
     38  is 64-bit capable, and adjust them to point to the new location in
     39  <filename class="directory">/tools</filename>.</para>
    3640
    3741  <para>For the sake of accuracy, it is recommended to use a copy-and-paste
    3842  method when issuing the following command. Be sure to visually inspect the
    39   specs file and verify that all occurrences of <quote>/lib/ld-linux.so.2</quote>
    40   have been replaced with <quote>/tools/lib/ld-linux.so.2</quote>:</para>
    41 
    42   <important>
    43     <para>If working on a platform where the name of the dynamic linker is
    44     something other than <filename class="libraryfile">ld-linux.so.2</filename>,
    45     replace <quote>ld-linux.so.2</quote> with the name of the platform's
    46     dynamic linker in the following commands. Refer to <xref
    47     linkend="ch-tools-toolchaintechnotes" role=","/> if necessary.</para>
    48   </important>
     43  specs file to verify that it has properly adjusted all references to the
     44  dynamic linker location. Refer to <xref
     45    linkend="ch-tools-toolchaintechnotes" role=","/> for the default name
     46  of the dynamic linker, if necessary.</para>
    4947
    5048<!-- Ampersands are needed to allow copy and paste -->
    51 <screen><userinput>gcc -dumpspecs | sed 's@/lib/ld-linux.so.2@/tools&amp;@g' &gt; \
     49<screen><userinput>gcc -dumpspecs | sed 's@/lib\(64\)\?/ld@/tools&amp;@g' &gt; \
    5250  `dirname $(gcc -print-libgcc-file-name)`/specs</userinput></screen>
    5351
     
    8785    /tools/lib/ld-linux.so.2]</computeroutput></screen>
    8886
    89     <para>Note that <filename class="directory">/tools/lib</filename>
     87    <para>Note that <filename class="directory">/tools/lib</filename>, or
     88    <filename class="directory">/tools/lib64</filename> for 64-bit machines
    9089    appears as the prefix of the dynamic linker.</para>
    9190
  • chapter05/binutils-pass1.xml

    rb0e1dc8 r6e88633  
    125125    first pass will soon be replaced by those from the second.</para>
    126126
     127    <para>Create a symlink to ensure the sanity of our toolchain:</para>
     128
     129<screen><userinput remap="install">mkdir -v /tools/lib
     130ln -sv lib /tools/lib64</userinput></screen>
     131
    127132    <para>Install the package:</para>
    128133
    129134<screen><userinput remap="install">make install</userinput></screen>
    130135
    131     <para>Next, prepare the linker for the <quote>Adjusting</quote> phase
     136    <para>Finally, prepare the linker for the <quote>Adjusting</quote> phase
    132137    later on:</para>
    133138
  • chapter05/gcc-pass1.xml

    rb0e1dc8 r6e88633  
    6363<screen><userinput remap="configure">CC="gcc -B/usr/bin/" ../gcc-&gcc-version;/configure --prefix=/tools \
    6464    --with-local-prefix=/tools --disable-nls --disable-shared --disable-libssp \
    65     --enable-languages=c</userinput></screen>
     65    --disable-multilib --enable-languages=c</userinput></screen>
    6666
    6767    <variablelist>
     
    112112          <para>This option ensures that only the C compiler is built.
    113113          This is the only language needed now.</para>
     114        </listitem>
     115      </varlistentry>
     116
     117      <varlistentry>
     118        <term><parameter>--disable-multilib</parameter></term>
     119        <listitem>
     120          <para>We currently only want to build support for 64-bit libraries.</para>
    114121        </listitem>
    115122      </varlistentry>
  • chapter05/gcc-pass2.xml

    rb0e1dc8 r6e88633  
    100100    against the new Glibc. Issue:</para>
    101101
    102 <screen><userinput remap="pre">for file in $(find gcc/config -name linux64.h -o -name linux.h)
     102<screen><userinput remap="pre">for file in \
     103 $(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h)
    103104do
    104105  cp -uv $file{,.orig}
     
    113114    <para>In case the above seems hard to follow, let's break it down a bit.
    114115    First we find all the files under the gcc/config directory that are named
    115     either <filename>linux.h</filename> or <filename>linux64.h</filename>.
     116    either <filename>linux.h</filename>, <filename>linux64.h</filename> or
     117    <filename>sysv4.h</filename>.
    116118    For each file found, we copy it to a file of the same name but with an added
    117119    suffix of <quote>.orig</quote>. Then the first sed expression prepends
     
    125127    </para>
    126128
     129    <para>Unsetting the multlib spec for GCC ensures that it
     130    won't attempt to link against libraries on the host:</para>
     131
     132<screen><userinput remap="pre">for file in $(find gcc/config -name t-linux64) ; do \
     133   cp -v $file{,.orig}
     134   sed '/MULTILIB_OSDIRNAMES/d' $file.orig &gt; $file
     135done</userinput></screen>
     136
    127137    <para>As in the first build of GCC it requires the GMP and MPFR packages.
    128138    Unpack the tarballs and move them into the required directory names:</para>
     
    147157    --enable-shared --enable-threads=posix \
    148158    --enable-__cxa_atexit --enable-languages=c,c++ \
    149     --disable-libstdcxx-pch --disable-bootstrap</userinput></screen>
     159    --disable-libstdcxx-pch --disable-multilib \
     160    --disable-bootstrap</userinput></screen>
    150161
    151162    <variablelist>
  • chapter05/glibc.xml

    rb0e1dc8 r6e88633  
    6565    that is changed when setting -march.</para>
    6666
    67 <screen><userinput remap="configure">echo "CFLAGS += -march=i486 -mtune=native" &gt; configparms</userinput></screen>
     67<screen><userinput remap="configure">case `uname -m` in
     68  i?86) echo "CFLAGS += -march=i486 -mtune=native" &gt; configparms ;;
     69esac</userinput></screen>
    6870
    6971    <para>Next, prepare Glibc for compilation:</para>
  • chapter05/toolchaintechnotes.xml

    rb0e1dc8 r6e88633  
    2828  <important>
    2929    <para>Before continuing, be aware of the name of the working platform,
    30     often referred to as the target triplet. Many times, the target
    31     triplet will probably be <emphasis>i686-pc-linux-gnu</emphasis>. A
    32     simple way to determine the name of the target triplet is to run the
    33     <command>config.guess</command> script that comes with the source for
    34     many packages. Unpack the Binutils sources and run the script:
    35     <userinput>./config.guess</userinput> and note the output.</para>
     30    often referred to as the target triplet. A simple way to determine the
     31    name of the target triplet is to run the <command>config.guess</command>
     32    script that comes with the source for many packages. Unpack the Binutils
     33    sources and run the script: <userinput>./config.guess</userinput> and note
     34    the output. For example, for a modern 32-bit Intel processor the
     35    output will likely be <emphasis>i686-pc-linux-gnu</emphasis>.</para>
    3636
    3737    <para>Also be aware of the name of the platform's dynamic linker, often
     
    4040    provided by Glibc finds and loads the shared libraries needed by a program,
    4141    prepares the program to run, and then runs it. The name of the dynamic
    42     linker will usually be <filename class="libraryfile">ld-linux.so.2</filename>.
    43     On platforms that are less prevalent, the name might be <filename
    44     class="libraryfile">ld.so.1</filename>, and newer 64 bit platforms might
    45     be named something else entirely. The name of the platform's dynamic linker
    46     can be determined by looking in the <filename class="directory">/lib</filename>
    47     directory on the host system. A sure-fire way to determine the name is to
     42    linker for a 32-bit Intel machine will be
     43    <filename class="libraryfile">ld-linux.so.2</filename>.
     44    A sure-fire way to determine the name of the dynamic linker is to
    4845    inspect a random binary from the host system by running:
    4946    <userinput>readelf -l &lt;name of binary&gt; | grep interpreter</userinput>
  • chapter06/binutils.xml

    rb0e1dc8 r6e88633  
    9898          ultimately be located) is set to <filename
    9999          class="directory">$(exec_prefix)/$(target_alias)</filename>. For
    100           example, i686 machines would expand that to <filename
    101           class="directory">/usr/i686-pc-linux-gnu</filename>. Because this is
     100          example, x86_64 machines would expand that to <filename
     101          class="directory">/usr/x86_64-unknown-linux-gnu</filename>. Because this is
    102102          a custom system, this target-specific directory in <filename
    103103          class="directory">/usr</filename> is not required. <filename
  • chapter06/coreutils.xml

    rb0e1dc8 r6e88633  
    4747    fixes this behavior for Intel architectures:</para>
    4848
    49 <screen><userinput remap="pre">patch -Np1 -i ../&coreutils-uname-patch;</userinput></screen>
     49<screen><userinput remap="pre">case `uname -m` in
     50 i?86 | x86_64) patch -Np1 -i ../&coreutils-uname-patch; ;;
     51esac</userinput></screen>
    5052
    5153    <para>There's an internal issue with Coreutils which makes some of the
  • chapter06/creatingdirs.xml

    rb0e1dc8 r6e88633  
    2525  ln -sv share/{man,doc,info} $dir
    2626done
     27ln -sv lib /lib64
     28ln -sv lib /usr/lib64
    2729mkdir -v /var/{lock,log,mail,run,spool}
    2830mkdir -pv /var/{opt,cache,lib/{misc,locate},local}</userinput></screen>
  • chapter06/gcc.xml

    rb0e1dc8 r6e88633  
    4949<screen><userinput remap="pre">sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in</userinput></screen>
    5050
    51     <para>The bootstrap build performed in <xref linkend="ch-tools-gcc-pass1"/>
     51    <para>For x86 machines, the bootstrap build performed in
     52    <xref linkend="ch-tools-gcc-pass2"/>
    5253    built GCC with the <option>-fomit-frame-pointer</option> compiler flag.
    5354    Non-bootstrap builds omit this flag by default, so apply the following
     
    5556    builds:</para>
    5657
    57 <screen><userinput remap="pre">sed -i 's/^XCFLAGS =$/&amp; -fomit-frame-pointer/' gcc/Makefile.in</userinput></screen>
     58<screen><userinput remap="pre">case `uname -m` in
     59  i?86) sed -i 's/^XCFLAGS =$/&amp; -fomit-frame-pointer/' \
     60        gcc/Makefile.in ;;
     61esac</userinput></screen>
    5862
    5963    <para>The <command>fixincludes</command> script is known to occasionally
     
    7781    --enable-threads=posix --enable-__cxa_atexit \
    7882    --enable-clocale=gnu --enable-languages=c,c++ \
    79     --disable-bootstrap</userinput></screen>
     83    --disable-multilib --disable-bootstrap</userinput></screen>
    8084
    8185    <para>Note that for other languages, there are some prerequsites that
     
    161165/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crtn.o succeeded</computeroutput></screen>
    162166
     167  <para>Depending on your machine architecture, the above may differ slightly,
     168  the difference usually being the name of the directory
     169  after <filename class="directory">/usr/lib/gcc</filename>. If your machine is
     170  a 64-bit system, you may also see a directory named <filename class="directory">lib64</filename>
     171  towards the end of the string. The important thing to
     172  look for here is that gcc has found all three <filename>crt*.o</filename> files under
     173  the <filename class="directory">/usr/lib</filename> directory.</para>
     174
    163175    <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
    164176    href="readjusting.xml"
     
    173185<screen><computeroutput>#include &lt;...&gt; search starts here:
    174186 /usr/local/include
    175  /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/include
     187 /usr/lib/gcc/x86_64-unknown-linux-gnu/&gcc-version;/include
    176188 /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/include-fixed
    177189 /usr/include</computeroutput></screen>
     190
     191   <para>Again, note that the directory named after your target triplet may be
     192   different than the above, depending on your architecture.</para>
    178193
    179194    <note><para>As of version 4.3.0, GCC now unconditionally installs the
     
    195210
    196211<screen><computeroutput>SEARCH_DIR("/usr/i686-pc-linux-gnu/lib")
     212SEARCH_DIR("/usr/local/lib")
     213SEARCH_DIR("/lib")
     214SEARCH_DIR("/usr/lib");</computeroutput></screen>
     215
     216   <para>A 64-bit system may see a few more directories. For example, here
     217   is the output from a x86_64 machine:</para>
     218
     219<screen><computeroutput>SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib64")
     220SEARCH_DIR("/usr/local/lib64")
     221SEARCH_DIR("/lib64")
     222SEARCH_DIR("/usr/lib64")
     223SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib")
    197224SEARCH_DIR("/usr/local/lib")
    198225SEARCH_DIR("/lib")
  • chapter06/glibc.xml

    rb0e1dc8 r6e88633  
    8585    to check the Glibc we have just installed with the following:</para>
    8686
    87 <screen><userinput remap="pre">sed -i \
    88 's|libs -o|libs -L/usr/lib -Wl,-dynamic-linker=/lib/ld-linux.so.2 -o|' \
    89         scripts/test-installation.pl</userinput></screen> -->
     87<screen><userinput remap="pre">DL=$(readelf -l /bin/sh | grep interpreter | \
     88awk '{print $4}' | sed -e 's@/tools@@' -e 's@]$@@')
     89sed -i &quot;s|libs -o|libs -L/usr/lib -Wl,-dynamic-linker=$DL -o|&quot; \
     90        scripts/test-installation.pl
     91unset DL</userinput></screen> -->
    9092
    9193    <para>First apply two patches which correct failures in the test
     
    110112cd ../glibc-build</userinput></screen>
    111113
    112     <para>Again, add the needed compiler flag to CFLAGS:</para>
    113 
    114 <screen><userinput remap="configure">echo "CFLAGS += -march=i486 -mtune=native" &gt; configparms</userinput></screen>
     114    <para>Again, add the needed compiler flags to CFLAGS for x86 machines:</para>
     115
     116<screen><userinput remap="configure">case `uname -m` in
     117  i?86) echo "CFLAGS += -march=i486 -mtune=native" &gt; configparms ;;
     118esac</userinput></screen>
    115119
    116120    <para>Prepare Glibc for compilation:</para>
  • chapter06/introduction.xml

    rb0e1dc8 r6e88633  
    2424  installed.</para>
    2525
    26   <para>If using compiler optimizations, please
    27   review the optimization hint at <ulink url="&hints-root;optimization.txt"/>.
    28   Compiler optimizations can make a program run slightly faster, but they may
    29   also cause compilation difficulties and problems when running the program.
    30   If a package refuses to compile when using optimization, try to compile it
    31   without optimization and see if that fixes the problem. Even if the package
    32   does compile when using optimization, there is the risk it may have been
    33   compiled incorrectly because of the complex interactions between the code
    34   and build tools.  Also note that the <option>-march</option> and
    35   <option>-mtune</option> options may cause problems with the toolchain packages
    36   (Binutils, GCC and Glibc).  The small potential gains achieved in using
    37   compiler optimizations are often outweighed by the risks. First-time builders
    38   of LFS are encouraged to build without custom optimizations. The subsequent
    39   system will still run very fast and be stable at the same time.</para>
     26  <para>If using compiler optimizations, please review the optimization hint at
     27  <ulink url="&hints-root;optimization.txt"/>.  Compiler optimizations can make
     28  a program run slightly faster, but they may also cause compilation
     29  difficulties and problems when running the program.  If a package refuses to
     30  compile when using optimization, try to compile it without optimization and
     31  see if that fixes the problem. Even if the package does compile when using
     32  optimization, there is the risk it may have been compiled incorrectly because
     33  of the complex interactions between the code and build tools.  Also note that
     34  the <option>-march</option> and <option>-mtune</option> options using values
     35  not specified in the book have not been tested. This may cause problems with
     36  the toolchain packages (Binutils, GCC and Glibc).  The small potential gains
     37  achieved in using compiler optimizations are often outweighed by the risks.
     38  First-time builders of LFS are encouraged to build without custom
     39  optimizations. The subsequent system will still run very fast and be stable
     40  at the same time.</para>
    4041
    4142  <para>The order that packages are installed in this chapter needs to be
  • chapter06/readjusting.xml

    rb0e1dc8 r6e88633  
    3838  this:</para>
    3939
    40   <important>
    41     <para>If working on a platform where the name of the dynamic linker is
    42     something other than <filename class="libraryfile">ld-linux.so.2</filename>,
    43     substitute <quote>ld-linux.so.2</quote> with the name of the platform's
    44     dynamic linker in the following commands. Refer to <xref
    45     linkend="ch-tools-toolchaintechnotes" role=","/> if necessary.</para>
    46   </important>
    47 
    48 <screen><userinput>gcc -dumpspecs | sed \
    49     -e 's@/tools/lib/ld-linux.so.2@/lib/ld-linux.so.2@g' \
     40<screen><userinput>gcc -dumpspecs | sed -e 's@/tools@@g' \
    5041    -e '/\*startfile_prefix_spec:/{n;s@.*@/usr/lib/ @}' \
    5142    -e '/\*cpp:/{n;s@$@ -isystem /usr/include@}' &gt; \
     
    9889
    9990  <para os="k">If everything is working correctly, there should be no errors,
    100   and the output of the last command will be:</para>
     91  and the output of the last command (allowing for platform-specific target triplets)
     92  will be:</para>
    10193
    10294<screen><computeroutput>SEARCH_DIR("/tools/i686-pc-linux-gnu/lib")
     
    10698  <para os="l">Next make sure that we're using the correct libc:</para>
    10799
    108 <screen os="m"><userinput>grep "/lib/libc.so.6 " dummy.log</userinput></screen>
     100<screen os="m"><userinput>grep "/lib.*/libc.so.6 " dummy.log</userinput></screen>
    109101
    110102  <para os="n">If everything is working correctly, there should be no errors,
    111   and the output of the last command will be:</para>
     103  and the output of the last command (allowing for a lib64 directory on 64-bit hosts)
     104  will be:</para>
    112105
    113106<screen os="o"><computeroutput>attempt to open /lib/libc.so.6 succeeded</computeroutput></screen>
     
    119112  <para os="r">If everything is working correctly, there should be no errors,
    120113  and the output of the last command will be (allowing for
    121   platform-specific differences in dynamic linker name):</para>
     114  platform-specific differences in dynamic linker name and a lib64 directory
     115  on 64-bit hosts):</para>
    122116
    123117<screen os="s"><computeroutput>found ld-linux.so.2 at /lib/ld-linux.so.2</computeroutput></screen>
Note: See TracChangeset for help on using the changeset viewer.