📄 gcc.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content= "application/xhtml+xml; charset=iso-8859-1" /> <title> 6.4. GCC-4.1.0 </title> <link rel="stylesheet" href="../stylesheets/lfs.css" type="text/css" /> <meta name="generator" content="DocBook XSL Stylesheets V1.69.1" /> <link rel="stylesheet" href="../stylesheets/lfs-print.css" type= "text/css" media="print" /> </head> <body id="lfs" class="CLFS-SVN-20060417-x86"> <div class="navheader"> <div class="headertitles"> <h4> Cross-Compiled Linux From Scratch - Version CLFS-SVN-20060417-x86 </h4> <h3> Chapter 6. Constructing a Temporary System </h3> </div> <ul class="headerlinks"> <li class="prev"> <a accesskey="p" href="binutils.html" title= "Binutils-2.16.1">Prev</a> <p> Binutils-2.16.1 </p> </li> <li class="next"> <a accesskey="n" href="gawk.html" title="Gawk-3.1.5">Next</a> <p> Gawk-3.1.5 </p> </li> <li class="up"> <a accesskey="u" href="chapter.html" title= "Chapter 6. Constructing a Temporary System">Up</a>. </li> <li class="home"> <a accesskey="h" href="../index.html" title= "Cross-Compiled Linux From Scratch - Version CLFS-SVN-20060417-x86"> Home</a> </li> </ul> </div> <div class="wrap" lang="en" xml:lang="en"> <div class="titlepage"> <h1 class="sect1"> 6.4. GCC-4.1.0 </h1> </div> <div class="package" lang="en" xml:lang="en"> <p> The GCC package contains the GNU compiler collection, which includes the C and C++ compilers. </p> <div class="segmentedlist"> <div class="seglistitem"> <div class="seg"> <strong><span class="segtitle">Installation depends on:</span></strong> <span class="seg">Bash, Binutils, Coreutils, DejaGNU, Diffutils, Expect, Findutils, Gawk, Gettext, Glibc, Grep, Make, Patch, Perl, Sed, Tcl, and Texinfo</span> </div> </div> </div> </div> <div class="installation" lang="en" xml:lang="en"> <div class="titlepage"> <h2 class="sect2"> 6.4.1. Installation of GCC </h2> </div> <p> The following patch fixes an issue where gcc doesn't generate some code properly. </p> <pre class="userinput"><kbd class="command">patch -Np1 -i ../gcc-4.1.0-fold_const_fix-1.patch</kbd></pre> <p> First make a couple of essential adjustments to the specs file to ensure GCC uses our build environment: </p> <pre class="userinput"><kbd class="command">patch -Np1 -i ../gcc-4.1.0-specs-1.patch</kbd></pre> <p> To make sure that a couple of tools use the proper syntax, apply the following patch: </p> <pre class="userinput"><kbd class="command">patch -Np1 -i ../gcc-4.1.0-posix-1.patch</kbd></pre> <p> The following patch ensures that <span><strong class= "command">gcc</strong></span> does not search the <tt class= "filename">/usr</tt> directory for <tt class= "filename">libgcc_s.so</tt> when cross-compiling: </p> <pre class="userinput"><kbd class="command">patch -Np1 -i ../gcc-4.1.0-cross_search_paths-1.patch</kbd></pre> <p> Now we will change <span><strong class= "command">cpp</strong></span>'s search path not to look in <tt class="filename">/usr/include</tt>: </p> <pre class="userinput"><kbd class="command">cp -v gcc/cppdefault.c{,.orig}sed -e '/#define STANDARD_INCLUDE_DIR/s@"/usr/include"@0@g' \ gcc/cppdefault.c.orig > gcc/cppdefault.c</kbd></pre> <p> Also, we need to set the directory searched by the fixincludes process for system headers, so it won't look at the host's headers: </p> <pre class="userinput"><kbd class="command">cp -v gcc/Makefile.in{,.orig}sed -e 's@\(^NATIVE_SYSTEM_HEADER_DIR =\).*@\1 /tools/include@g' \ gcc/Makefile.in.orig > gcc/Makefile.in</kbd></pre> <div class="important"> <div class="admonhead"> <img alt="[Important]" src="../images/important.png" /> <h3 class="admontitle"> Important </h3> </div> <div class="admonbody"> <p> The above patches and sed's are critical in ensuring a successful overall build. Do not forget to apply them. </p> </div> </div> <p> The GCC documentation recommends building GCC outside of the source directory in a dedicated build directory: </p> <pre class="userinput"><kbd class="command">mkdir -v ../gcc-buildcd ../gcc-build</kbd></pre> <p> Before starting to build GCC, remember to unset any environment variables that override the default optimization flags. </p> <p> Prepare GCC for compilation: </p> <pre class="userinput"><kbd class="command">../gcc-4.1.0/configure --prefix=/tools \ --build=${LFS_HOST} --host=${LFS_TARGET} --target=${LFS_TARGET} \ --with-local-prefix=/tools --enable-long-long --enable-c99 \ --enable-shared --enable-threads=posix --enable-__cxa_atexit \ --disable-nls --enable-languages=c,c++ --disable-libstdcxx-pch</kbd></pre> <div class="variablelist"> <p class="title"> <b>The meaning of the new configure options:</b> </p> <dl> <dt> <span class="term"><em class= "parameter"><tt>--disable-libstdcxx-pch</tt></em></span> </dt> <dd> <p> Do not build the pre-compiled header (PCH) for <tt class= "filename">libstdc++</tt>. It takes up a lot of space, and we have no use for it. </p> </dd> </dl> </div> <p> Compile the package: </p> <pre class="userinput"><kbd class="command">make AS_FOR_TARGET="/cross-tools/bin/${AS}" \LD_FOR_TARGET="/cross-tools/bin/${LD}"</kbd></pre> <p> Install the package: </p> <pre class="userinput"><kbd class="command">make install</kbd></pre> <p> Many packages use the name <span><strong class= "command">cc</strong></span> to call the C compiler. To satisfy those packages, create a symlink: </p> <pre class="userinput"><kbd class="command">ln -sv gcc /tools/bin/cc</kbd></pre> </div> <div class="content" lang="en" xml:lang="en"> <p> Details on this package are located in <a href= "../final-system/gcc.html#contents-gcc" title= "10.9.2. Contents of GCC">Section 10.9.2, “Contents of GCC.”</a> </p> </div> </div> <div class="navfooter"> <ul> <li class="prev"> <a accesskey="p" href="binutils.html" title= "Binutils-2.16.1">Prev</a> <p> Binutils-2.16.1 </p> </li> <li class="next"> <a accesskey="n" href="gawk.html" title="Gawk-3.1.5">Next</a> <p> Gawk-3.1.5 </p> </li> <li class="up"> <a accesskey="u" href="chapter.html" title= "Chapter 6. Constructing a Temporary System">Up</a>. </li> <li class="home"> <a accesskey="h" href="../index.html" title= "Cross-Compiled Linux From Scratch - Version CLFS-SVN-20060417-x86"> Home</a>. </li> </ul> </div> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -