Changeset efcb393 for chapter05/gcc-pass1.xml
- Timestamp:
- 05/03/2020 09:02:51 PM (4 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, 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:
- a715dec
- Parents:
- 9d719e2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
chapter05/gcc-pass1.xml
r9d719e2 refcb393 44 44 <title>Installation of Cross GCC</title> 45 45 46 <para>GCC nowrequires the GMP, MPFR and MPC packages. As these packages may46 <para>GCC requires the GMP, MPFR and MPC packages. As these packages may 47 47 not be included in your host distribution, they will be built with 48 48 GCC. Unpack each package into the GCC source directory and rename the … … 63 63 mv -v mpc-&mpc-version; mpc</userinput></screen> 64 64 65 <para>The following command will change the location of GCC's default 66 dynamic linker to use the one installed in <filename 67 class="directory">/tools</filename>. It also removes <filename 68 class="directory">/usr/include</filename> from GCC's include search path. 69 Issue:</para> 70 71 <screen><userinput remap="pre">for file in gcc/config/{linux,i386/linux{,64}}.h 72 do 73 cp -uv $file{,.orig} 74 sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \ 75 -e 's@/usr@/tools@g' $file.orig > $file 76 echo ' 77 #undef STANDARD_STARTFILE_PREFIX_1 78 #undef STANDARD_STARTFILE_PREFIX_2 79 #define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/" 80 #define STANDARD_STARTFILE_PREFIX_2 ""' >> $file 81 touch $file.orig 82 done</userinput></screen> 83 84 <para>In case the above seems hard to follow, let's break it down a bit. 85 First we copy the files <filename>gcc/config/linux.h</filename>, 86 <filename>gcc/config/i386/linux.h</filename>, and 87 <filename>gcc/config/i386/linux64.h</filename> to a file of 88 the same name but with an added suffix of <quote>.orig</quote>. Then the 89 first sed expression prepends <quote>/tools</quote> to every instance of 90 <quote>/lib/ld</quote>, <quote>/lib64/ld</quote> or 91 <quote>/lib32/ld</quote>, while the second one replaces hard-coded 92 instances of <quote>/usr</quote>. Next, we add our define statements which 93 alter the default startfile prefix to the end of the file. Note that the 94 trailing <quote>/</quote> in <quote>/tools/lib/</quote> is required. 95 Finally, we use <command>touch</command> to update the timestamp on the 96 copied files. When used in conjunction with <command>cp -u</command>, this 97 prevents unexpected changes to the original files in case the commands are 98 inadvertently run twice.</para> 99 100 <para>Finally, on x86_64 hosts, set the default directory name for 65 <para>On x86_64 hosts, set the default directory name for 101 66 64-bit libraries to <quote>lib</quote>:</para> 102 67 … … 108 73 esac</userinput></screen> 109 74 110 <!--111 <para>GCC doesn't detect stack protection correctly, which causes problems112 for the build of Glibc-&glibc-version;, so fix that by issuing the following113 command:</para>114 115 <screen><userinput remap="pre">sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure</userinput></screen>116 -->117 118 <!--119 <para>Also fix a problem identified upstream:</para>120 121 <screen><userinput remap="pre">sed -i 's/if \((code.*))\)/if (\1 \&\& \!DEBUG_INSN_P (insn))/' gcc/sched-deps.c</userinput></screen>122 -->123 75 <para>The GCC documentation recommends building GCC 124 76 in a dedicated build directory:</para> … … 131 83 <screen><userinput remap="configure">../configure \ 132 84 --target=$LFS_TGT \ 133 --prefix= /tools\85 --prefix=$LFS/tools \ 134 86 --with-glibc-version=2.11 \ 135 87 --with-sysroot=$LFS \ 136 88 --with-newlib \ 137 89 --without-headers \ 138 --with-local-prefix=/tools \ 139 --with-native-system-header-dir=/tools/include \ 90 --enable-initfini-array \ 140 91 --disable-nls \ 141 92 --disable-shared \ … … 182 133 183 134 <varlistentry> 184 <term><parameter>--with-local-prefix=/tools</parameter></term>185 <listitem>186 <para>The local prefix is the location in the system that GCC will search187 for locally installed include files. The default is <filename>/usr/local</filename>.188 Setting this to <filename>/tools</filename> helps keep the host location of189 <filename>/usr/local</filename> out of this GCC's search path.</para>190 </listitem>191 </varlistentry>192 193 <varlistentry>194 <term><parameter>--with-native-system-header-dir=/tools/include</parameter></term>195 <listitem>196 <para>By default, GCC searches <filename>/usr/include</filename> for197 system headers. In conjunction with the sysroot switch, this would198 normally translate to <filename>$LFS/usr/include</filename>. However199 the headers that will be installed in the next two sections will go200 to <filename>$LFS/tools/include</filename>. This switch ensures that201 gcc will find them correctly. In the second pass of GCC, this same202 switch will ensure that no headers from the host system are203 found.</para>204 </listitem>205 </varlistentry>206 207 <varlistentry>208 135 <term><parameter>--disable-shared</parameter></term> 209 136 <listitem> 210 137 <para>This switch forces GCC to link its internal libraries 211 statically. We do this to avoid possible issues with the host 212 138 statically. We need this because the shared libraries require glibc, 139 which is not yet installed on the target system.</para> 213 140 </listitem> 214 141 </varlistentry> … … 250 177 <screen><userinput remap="make">make</userinput></screen> 251 178 252 <para>Compilation is now complete. At this point, the test suite would253 normally be run, but, as mentioned before, the test suite framework is254 not in place yet. The benefits of running the tests at this point255 are minimal since the programs from this first pass will soon be256 replaced.</para>257 258 179 <para>Install the package:</para> 259 180 260 <screen><userinput remap="install">make install</userinput></screen> 261 <!-- 262 <para>Using <parameter>- -disable-shared</parameter> means that the 263 <filename>libgcc_eh.a</filename> file isn't created and installed. The 264 Glibc package depends on this library as it uses 265 <parameter>-lgcc_eh</parameter> within its build system. This dependency 266 can be satisfied by creating a symlink to <filename>libgcc.a</filename>, 267 since that file will end up containing the objects normally contained in 268 <filename>libgcc_eh.a</filename>:</para> 269 270 <screen><userinput remap="install">ln -sv libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/'`</userinput></screen> 271 --> 181 <screen><userinput remap="install">make install</userinput></screen> 182 183 <para>This build of GCC has installed a couple of internal system 184 headers. Normally one of them, <filename>limits.h</filename>, would in turn 185 include the corresponding system <filename>limits.h</filename> header, in 186 this case, <filename>$LFS/usr/include/limits.h</filename>. However, at the 187 time of this build of gcc <filename>$LFS/usr/include/limits.h</filename> 188 does not exist, so the internal header that has just been installed is a 189 partial, self-contained file and does not include the extended features of 190 the system header. This is adequate for building glibc, but the full 191 internal header will be needed later. Create a full version of the internal 192 header using a command that is identical to what the GCC build system does 193 in normal circumstances:</para> 194 195 <screen><userinput remap="install">cd .. 196 cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \ 197 `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/install-tools/include/limits.h</userinput></screen> 272 198 </sect2> 273 199
Note:
See TracChangeset
for help on using the changeset viewer.