Changeset 6e88633
- Timestamp:
- 12/03/2008 10:46:04 PM (15 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, 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
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
chapter01/changelog.xml
rb0e1dc8 r6e88633 37 37 38 38 --> 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 39 50 <listitem> 40 51 <para>2008-12-02</para> -
chapter05/adjusting.xml
rb0e1dc8 r6e88633 33 33 dumping GCC's <quote>specs</quote> file to a location where GCC will look for it 34 34 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> 36 40 37 41 <para>For the sake of accuracy, it is recommended to use a copy-and-paste 38 42 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> 49 47 50 48 <!-- Ampersands are needed to allow copy and paste --> 51 <screen><userinput>gcc -dumpspecs | sed 's@/lib /ld-linux.so.2@/tools&@g' > \49 <screen><userinput>gcc -dumpspecs | sed 's@/lib\(64\)\?/ld@/tools&@g' > \ 52 50 `dirname $(gcc -print-libgcc-file-name)`/specs</userinput></screen> 53 51 … … 87 85 /tools/lib/ld-linux.so.2]</computeroutput></screen> 88 86 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 90 89 appears as the prefix of the dynamic linker.</para> 91 90 -
chapter05/binutils-pass1.xml
rb0e1dc8 r6e88633 125 125 first pass will soon be replaced by those from the second.</para> 126 126 127 <para>Create a symlink to ensure the sanity of our toolchain:</para> 128 129 <screen><userinput remap="install">mkdir -v /tools/lib 130 ln -sv lib /tools/lib64</userinput></screen> 131 127 132 <para>Install the package:</para> 128 133 129 134 <screen><userinput remap="install">make install</userinput></screen> 130 135 131 <para> Next, prepare the linker for the <quote>Adjusting</quote> phase136 <para>Finally, prepare the linker for the <quote>Adjusting</quote> phase 132 137 later on:</para> 133 138 -
chapter05/gcc-pass1.xml
rb0e1dc8 r6e88633 63 63 <screen><userinput remap="configure">CC="gcc -B/usr/bin/" ../gcc-&gcc-version;/configure --prefix=/tools \ 64 64 --with-local-prefix=/tools --disable-nls --disable-shared --disable-libssp \ 65 -- enable-languages=c</userinput></screen>65 --disable-multilib --enable-languages=c</userinput></screen> 66 66 67 67 <variablelist> … … 112 112 <para>This option ensures that only the C compiler is built. 113 113 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> 114 121 </listitem> 115 122 </varlistentry> -
chapter05/gcc-pass2.xml
rb0e1dc8 r6e88633 100 100 against the new Glibc. Issue:</para> 101 101 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) 103 104 do 104 105 cp -uv $file{,.orig} … … 113 114 <para>In case the above seems hard to follow, let's break it down a bit. 114 115 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>. 116 118 For each file found, we copy it to a file of the same name but with an added 117 119 suffix of <quote>.orig</quote>. Then the first sed expression prepends … … 125 127 </para> 126 128 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 > $file 135 done</userinput></screen> 136 127 137 <para>As in the first build of GCC it requires the GMP and MPFR packages. 128 138 Unpack the tarballs and move them into the required directory names:</para> … … 147 157 --enable-shared --enable-threads=posix \ 148 158 --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> 150 161 151 162 <variablelist> -
chapter05/glibc.xml
rb0e1dc8 r6e88633 65 65 that is changed when setting -march.</para> 66 66 67 <screen><userinput remap="configure">echo "CFLAGS += -march=i486 -mtune=native" > configparms</userinput></screen> 67 <screen><userinput remap="configure">case `uname -m` in 68 i?86) echo "CFLAGS += -march=i486 -mtune=native" > configparms ;; 69 esac</userinput></screen> 68 70 69 71 <para>Next, prepare Glibc for compilation:</para> -
chapter05/toolchaintechnotes.xml
rb0e1dc8 r6e88633 28 28 <important> 29 29 <para>Before continuing, be aware of the name of the working platform, 30 often referred to as the target triplet. Many times, the target31 triplet will probably be <emphasis>i686-pc-linux-gnu</emphasis>. A32 s imple way to determine the name of the target triplet is to run the33 <command>config.guess</command> script that comes with the source for34 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> 36 36 37 37 <para>Also be aware of the name of the platform's dynamic linker, often … … 40 40 provided by Glibc finds and loads the shared libraries needed by a program, 41 41 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 48 45 inspect a random binary from the host system by running: 49 46 <userinput>readelf -l <name of binary> | grep interpreter</userinput> -
chapter06/binutils.xml
rb0e1dc8 r6e88633 98 98 ultimately be located) is set to <filename 99 99 class="directory">$(exec_prefix)/$(target_alias)</filename>. For 100 example, i686machines would expand that to <filename101 class="directory">/usr/ i686-pc-linux-gnu</filename>. Because this is100 example, x86_64 machines would expand that to <filename 101 class="directory">/usr/x86_64-unknown-linux-gnu</filename>. Because this is 102 102 a custom system, this target-specific directory in <filename 103 103 class="directory">/usr</filename> is not required. <filename -
chapter06/coreutils.xml
rb0e1dc8 r6e88633 47 47 fixes this behavior for Intel architectures:</para> 48 48 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; ;; 51 esac</userinput></screen> 50 52 51 53 <para>There's an internal issue with Coreutils which makes some of the -
chapter06/creatingdirs.xml
rb0e1dc8 r6e88633 25 25 ln -sv share/{man,doc,info} $dir 26 26 done 27 ln -sv lib /lib64 28 ln -sv lib /usr/lib64 27 29 mkdir -v /var/{lock,log,mail,run,spool} 28 30 mkdir -pv /var/{opt,cache,lib/{misc,locate},local}</userinput></screen> -
chapter06/gcc.xml
rb0e1dc8 r6e88633 49 49 <screen><userinput remap="pre">sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in</userinput></screen> 50 50 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"/> 52 53 built GCC with the <option>-fomit-frame-pointer</option> compiler flag. 53 54 Non-bootstrap builds omit this flag by default, so apply the following … … 55 56 builds:</para> 56 57 57 <screen><userinput remap="pre">sed -i 's/^XCFLAGS =$/& -fomit-frame-pointer/' gcc/Makefile.in</userinput></screen> 58 <screen><userinput remap="pre">case `uname -m` in 59 i?86) sed -i 's/^XCFLAGS =$/& -fomit-frame-pointer/' \ 60 gcc/Makefile.in ;; 61 esac</userinput></screen> 58 62 59 63 <para>The <command>fixincludes</command> script is known to occasionally … … 77 81 --enable-threads=posix --enable-__cxa_atexit \ 78 82 --enable-clocale=gnu --enable-languages=c,c++ \ 79 --disable- bootstrap</userinput></screen>83 --disable-multilib --disable-bootstrap</userinput></screen> 80 84 81 85 <para>Note that for other languages, there are some prerequsites that … … 161 165 /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crtn.o succeeded</computeroutput></screen> 162 166 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 163 175 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" 164 176 href="readjusting.xml" … … 173 185 <screen><computeroutput>#include <...> search starts here: 174 186 /usr/local/include 175 /usr/lib/gcc/ i686-pc-linux-gnu/&gcc-version;/include187 /usr/lib/gcc/x86_64-unknown-linux-gnu/&gcc-version;/include 176 188 /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/include-fixed 177 189 /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> 178 193 179 194 <note><para>As of version 4.3.0, GCC now unconditionally installs the … … 195 210 196 211 <screen><computeroutput>SEARCH_DIR("/usr/i686-pc-linux-gnu/lib") 212 SEARCH_DIR("/usr/local/lib") 213 SEARCH_DIR("/lib") 214 SEARCH_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") 220 SEARCH_DIR("/usr/local/lib64") 221 SEARCH_DIR("/lib64") 222 SEARCH_DIR("/usr/lib64") 223 SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib") 197 224 SEARCH_DIR("/usr/local/lib") 198 225 SEARCH_DIR("/lib") -
chapter06/glibc.xml
rb0e1dc8 r6e88633 85 85 to check the Glibc we have just installed with the following:</para> 86 86 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 | \ 88 awk '{print $4}' | sed -e 's@/tools@@' -e 's@]$@@') 89 sed -i "s|libs -o|libs -L/usr/lib -Wl,-dynamic-linker=$DL -o|" \ 90 scripts/test-installation.pl 91 unset DL</userinput></screen> --> 90 92 91 93 <para>First apply two patches which correct failures in the test … … 110 112 cd ../glibc-build</userinput></screen> 111 113 112 <para>Again, add the needed compiler flag to CFLAGS:</para> 113 114 <screen><userinput remap="configure">echo "CFLAGS += -march=i486 -mtune=native" > 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" > configparms ;; 118 esac</userinput></screen> 115 119 116 120 <para>Prepare Glibc for compilation:</para> -
chapter06/introduction.xml
rb0e1dc8 r6e88633 24 24 installed.</para> 25 25 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> 40 41 41 42 <para>The order that packages are installed in this chapter needs to be -
chapter06/readjusting.xml
rb0e1dc8 r6e88633 38 38 this:</para> 39 39 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' \ 50 41 -e '/\*startfile_prefix_spec:/{n;s@.*@/usr/lib/ @}' \ 51 42 -e '/\*cpp:/{n;s@$@ -isystem /usr/include@}' > \ … … 98 89 99 90 <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> 101 93 102 94 <screen><computeroutput>SEARCH_DIR("/tools/i686-pc-linux-gnu/lib") … … 106 98 <para os="l">Next make sure that we're using the correct libc:</para> 107 99 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> 109 101 110 102 <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> 112 105 113 106 <screen os="o"><computeroutput>attempt to open /lib/libc.so.6 succeeded</computeroutput></screen> … … 119 112 <para os="r">If everything is working correctly, there should be no errors, 120 113 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> 122 116 123 117 <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.