Changeset 4e82d47 for chapter05/gcc-pass2.xml
- Timestamp:
- 12/05/2008 08:46:02 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:
- 6f2cc22
- Parents:
- 6e88633
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
chapter05/gcc-pass2.xml
r6e88633 r4e82d47 42 42 43 43 <sect2 role="installation"> 44 <title>Re-installation of GCC</title> 45 46 <para>The tools required to test GCC and Binutils—Tcl, Expect 47 and DejaGNU—are installed now. GCC and Binutils can now be 48 rebuilt, linking them against the new Glibc and testing them properly 49 (if running the test suites in this chapter). Please note that these 50 test suites are highly dependent on properly functioning PTYs which 51 are provided by the host. PTYs are most commonly implemented via the 52 <systemitem class="filesystem">devpts</systemitem> file system. Check 53 to see if the host system is set up correctly in this regard by 54 performing a quick test:</para> 55 56 <screen><userinput remap="test">expect -c "spawn ls"</userinput></screen> 57 58 <para>The response might be:</para> 59 60 <screen><computeroutput>The system has no more ptys. 61 Ask your system administrator to create more.</computeroutput></screen> 62 63 <para>If the above message is received, the host does not have its PTYs 64 set up properly. In this case, there is no point in running the test 65 suites for GCC and Binutils until this issue is resolved. Please consult 66 the LFS FAQ at <ulink url="&lfs-root;/lfs/faq.html#no-ptys"/> for more 67 information on how to get PTYs working.</para> 68 69 <para>As previously explained in <xref linkend="ch-tools-adjusting"/>, 70 under normal circumstances the GCC <command>fixincludes</command> script 44 <title>Installation of GCC</title> 45 46 <para>Versions of GCC later than 4.3 will treat this build as if 47 it were a relocated compiler and disallow searching for startfiles in 48 the location specified by <parameter>--prefix</parameter>. Since this 49 will not be a relocated compiler, and the startfiles in 50 <filename class="directory">/tools</filename> are crucial to building 51 a working compiler linked to the libs in <filename class="directory">/tools</filename>, 52 apply the following patch which partially reverts GCC to its old behavior:</para> 53 54 <screen><userinput remap="pre">patch -Np1 -i ../&gcc-startfiles-patch;</userinput></screen> 55 56 <para>Under normal circumstances the GCC <command>fixincludes</command> script 71 57 is run in order to fix potentially broken header files. As GCC-&gcc-version; 72 58 and Glibc-&glibc-version; have already been installed at this point, and … … 81 67 sed 's@\./fixinc\.sh@-c true@' gcc/Makefile.in.orig > gcc/Makefile.in</userinput></screen> 82 68 83 <para>The bootstrap build performed in <xref linkend="ch-tools-gcc-pass1"/> 84 built GCC with the <option>-fomit-frame-pointer</option> compiler flag. 85 Non-bootstrap builds omit this flag by default, so apply the following 86 <command>sed</command> to use it in order to ensure consistent compiler 87 builds:</para> 69 <para>Non-bootstrap builds omit the <option>-fomit-frame-pointer</option> 70 build flag by default, and the goal should be to produce a compiler that is 71 exactly the same as if it were bootstrapped. Apply the following 72 <command>sed</command> command to force the build to use the flag:</para> 88 73 89 74 <screen><userinput remap="pre">cp -v gcc/Makefile.in{,.tmp} … … 92 77 93 78 <para>The following command will change the location of GCC's default 94 dynamic linker to use the one weinstalled in79 dynamic linker to use the one installed in 95 80 <filename class="directory">/tools</filename>. It also removes <filename 96 81 class="directory">/usr/include</filename> from GCC's include search path. … … 106 91 sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \ 107 92 -e 's@/usr@/tools@g' $file.orig > $file 108 echo "93 echo ' 109 94 #undef STANDARD_INCLUDE_DIR 110 #define STANDARD_INCLUDE_DIR 0" >> $file 95 #define STANDARD_INCLUDE_DIR 0 96 #define STANDARD_STARTFILE_PREFIX_1 "" 97 #define STANDARD_STARTFILE_PREFIX_2 ""' >> $file 111 98 touch $file.orig 112 99 done</userinput></screen> … … 121 108 <quote>/lib64/ld</quote> or <quote>/lib32/ld</quote>, while the second one 122 109 replaces hard-coded instances of <quote>/usr</quote>. Then we add our define 123 statements which alter the include search path to the end of the file. Finally, 124 we use <command>touch</command> to update the timestamp on the copied files. 110 statements which alter the include search path and the default startfile prefix 111 to the end of the file. 112 Finally, we use <command>touch</command> to update the timestamp on the copied files. 125 113 When used in conjunction with <command>cp -u</command>, this prevents unexpected 126 114 changes to the original files in case the command is inadvertently run twice. 127 115 </para> 128 116 129 <para> Unsetting the multlib spec for GCC ensures that it117 <para>On x86_64, unsetting the multlib spec for GCC ensures that it 130 118 won't attempt to link against libraries on the host:</para> 131 119 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> 120 <screen><userinput remap="pre">case $(uname -m) in 121 x86_64) 122 for file in $(find gcc/config -name t-linux64) ; do \ 123 cp -v $file{,.orig} 124 sed '/MULTILIB_OSDIRNAMES/d' $file.orig > $file 125 done 126 ;; 127 esac</userinput></screen> 136 128 137 129 <para>As in the first build of GCC it requires the GMP and MPFR packages. … … 153 145 <para>Now prepare GCC for compilation:</para> 154 146 155 <screen><userinput remap="configure">../gcc-&gcc-version;/configure --prefix=/tools \ 147 <screen><userinput remap="configure">CC="$LFS_TGT-gcc -B/tools/lib/" \ 148 AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib \ 149 ../gcc-&gcc-version;/configure --prefix=/tools \ 156 150 --with-local-prefix=/tools --enable-clocale=gnu \ 157 151 --enable-shared --enable-threads=posix \ … … 228 222 <screen><userinput remap="make">make</userinput></screen> 229 223 230 <para>Compilation is now complete. As previously mentioned, running the test231 suites for the temporary tools compiled in this chapter is not mandatory.232 To run the GCC test suite anyway, use the following command:</para>233 234 <screen><userinput remap="test">make -k check</userinput></screen>235 236 <para>The <parameter>-k</parameter> flag is used to make the test suite run237 through to completion and not stop at the first failure. The GCC test238 suite is very comprehensive and is almost guaranteed to generate a few239 failures.</para>240 241 <para>For a discussion of test failures that are of particular242 importance, please see <xref linkend="ch-system-gcc" role="."/></para>243 244 224 <para>Install the package:</para> 245 225 246 226 <screen><userinput remap="install">make install</userinput></screen> 247 227 248 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" 249 href="adjusting.xml" 250 xpointer="xpointer(/sect1/caution[1])"/> 228 <para>As a finishing touch, create a symlink. Many programs and scripts 229 run <command>cc</command> instead of <command>gcc</command>, which is 230 used to keep programs generic and therefore usable on all kinds of UNIX 231 systems where the GNU C compiler is not always installed. Running 232 <command>cc</command> leaves the system administrator free to decide 233 which C compiler to install:</para> 234 235 <screen><userinput remap="install">ln -vs gcc /tools/bin/cc</userinput></screen> 236 237 <caution> 238 <para>At this point, it is imperative to stop and ensure that the basic 239 functions (compiling and linking) of the new toolchain are working as 240 expected. To perform a sanity check, run the following commands:</para> 241 242 <screen><userinput>echo 'main(){}' > dummy.c 243 cc dummy.c 244 readelf -l a.out | grep ': /tools'</userinput></screen> 245 246 <para>If everything is working correctly, there should be no errors, 247 and the output of the last command will be of the form:</para> 248 249 <screen><computeroutput>[Requesting program interpreter: 250 /tools/lib/ld-linux.so.2]</computeroutput></screen> 251 252 <para>Note that <filename class="directory">/tools/lib</filename>, or 253 <filename class="directory">/tools/lib64</filename> for 64-bit machines 254 appears as the prefix of the dynamic linker.</para> 255 256 <para>If the output is not shown as above or there was no output at all, 257 then something is wrong. Investigate and retrace the steps to find out 258 where the problem is and correct it. This issue must be resolved before 259 continuing on. First, perform the sanity check again, using 260 <command>gcc</command> instead of <command>cc</command>. If this works, 261 then the <filename class="symlink">/tools/bin/cc</filename> symlink is 262 missing. Install the symlink as per above. 263 Next, ensure that the <envar>PATH</envar> is correct. This 264 can be checked by running <command>echo $PATH</command> and verifying that 265 <filename class="directory">/tools/bin</filename> is at the head of the 266 list. If the <envar>PATH</envar> is wrong it could mean that you are not 267 logged in as user <systemitem class="username">lfs</systemitem> or that 268 something went wrong back in <xref linkend="ch-tools-settingenviron" 269 role="."/></para> 270 271 <para>Once all is well, clean up the test files:</para> 272 273 <screen><userinput>rm -v dummy.c a.out</userinput></screen> 274 275 </caution> 251 276 252 277 </sect2>
Note:
See TracChangeset
for help on using the changeset viewer.