⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gcc-final.html

📁 CLFS(Cross-Compiled Linux From Scratch)的文档 Version CLFS-SVN-20060417
💻 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>      5.8.&nbsp;GCC-4.1.0 - Cross Compiler Final    </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-MIPS">    <div class="navheader">      <div class="headertitles">        <h4>          Cross-Compiled Linux From Scratch - Version CLFS-SVN-20060417-MIPS        </h4>        <h3>          Chapter&nbsp;5.&nbsp;Constructing Cross-Compile Tools        </h3>      </div>      <ul class="headerlinks">        <li class="prev">          <a accesskey="p" href="glibc.html" title="Glibc-2.4">Prev</a>          <p>            Glibc-2.4          </p>        </li>        <li class="next">          <a accesskey="n" href="../part4.html" title=          "Building the Basic Tools">Next</a>          <p>            Building the Basic Tools          </p>        </li>        <li class="up">          <a accesskey="u" href="chapter.html" title=          "Chapter&nbsp;5.&nbsp;Constructing Cross-Compile Tools">Up</a>.        </li>        <li class="home">          <a accesskey="h" href="../index.html" title=          "Cross-Compiled Linux From Scratch - Version CLFS-SVN-20060417-MIPS">          Home</a>        </li>      </ul>    </div>    <div class="wrap" lang="en" xml:lang="en">      <div class="titlepage">        <h1 class="sect1">          5.8. GCC-4.1.0 - Cross Compiler Final        </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">            5.8.1. Installation of GCC Cross Compiler          </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 setup the StartFile Spec to the correct library location:        </p>        <pre class="userinput"><kbd class="command">echo "#undef STARTFILE_PREFIX_SPEC#define STARTFILE_PREFIX_SPEC \"/tools/lib/\"" &gt;&gt; gcc/config/linux.h</kbd></pre>        <p>          Now alter <span><strong class="command">gcc</strong></span>'s c          preprocessors default include search path to use <tt class=          "filename">/tools</tt> only:        </p>        <pre class="userinput"><kbd class="command">cp -v gcc/Makefile.in{,.orig}sed -e "s@\(^CROSS_SYSTEM_HEADER_DIR =\).*@\1 /tools/include@g" \ gcc/Makefile.in.orig &gt; 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>          Prepare GCC for compilation:        </p>        <pre class="userinput"><kbd class="command">../gcc-4.1.0/configure --prefix=/cross-tools \    --target=${LFS_TARGET} --host=${LFS_HOST} --disable-multilib \    --with-local-prefix=/tools --disable-nls --enable-shared \    --enable-languages=c,c++ --enable-__cxa_atexit \    --enable-c99 --enable-long-long --enable-threads=posix</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>--enable-languages=c,c++</tt></em></span>            </dt>            <dd>              <p>                This option ensures that only the C and C++ compilers are                built.              </p>            </dd>            <dt>              <span class="term"><em class=              "parameter"><tt>--enable-__cxa_atexit</tt></em></span>            </dt>            <dd>              <p>                This option allows use of __cxa_atexit, rather than atexit,                to register C++ destructors for local statics and global                objects and is essential for fully standards-compliant                handling of destructors. It also affects the C++ ABI and                therefore results in C++ shared libraries and C++ programs                that are interoperable with other Linux distributions.              </p>            </dd>            <dt>              <span class="term"><em class=              "parameter"><tt>--enable-c99</tt></em></span>            </dt>            <dd>              <p>                Enable C99 support for C programs.              </p>            </dd>            <dt>              <span class="term"><em class=              "parameter"><tt>--enable-long-long</tt></em></span>            </dt>            <dd>              <p>                Enables long long support in the compiler.              </p>            </dd>            <dt>              <span class="term"><em class=              "parameter"><tt>--enable-threads=posix</tt></em></span>            </dt>            <dd>              <p>                This enables C++ exception handling for multi-threaded code.              </p>            </dd>          </dl>        </div>        <p>          Continue with compiling the package:        </p>        <pre class="userinput"><kbd class="command">make AS_FOR_TARGET="/cross-tools/bin/${LFS_TARGET}-as" \LD_FOR_TARGET="/cross-tools/bin/${LFS_TARGET}-ld"</kbd></pre>        <p>          Install the package:        </p>        <p>          Continue with compiling the package:        </p>        <pre class="userinput"><kbd class="command">make install</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.&nbsp;Contents of GCC">Section&nbsp;10.9.2, &ldquo;Contents          of GCC.&rdquo;</a>        </p>      </div>    </div>    <div class="navfooter">      <ul>        <li class="prev">          <a accesskey="p" href="glibc.html" title="Glibc-2.4">Prev</a>          <p>            Glibc-2.4          </p>        </li>        <li class="next">          <a accesskey="n" href="../part4.html" title=          "Building the Basic Tools">Next</a>          <p>            Building the Basic Tools          </p>        </li>        <li class="up">          <a accesskey="u" href="chapter.html" title=          "Chapter&nbsp;5.&nbsp;Constructing Cross-Compile Tools">Up</a>.        </li>        <li class="home">          <a accesskey="h" href="../index.html" title=          "Cross-Compiled Linux From Scratch - Version CLFS-SVN-20060417-MIPS">          Home</a>.        </li>      </ul>    </div>  </body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -