swift       05/12/01 18:46:28

  Modified:    xml/htdocs/doc/en/draft bootstrapping-guide.xml
  Log:
  The simple part...

Revision  Changes    Path
1.3       +140 -8    xml/htdocs/doc/en/draft/bootstrapping-guide.xml

file : 
http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/doc/en/draft/bootstrapping-guide.xml?rev=1.3&content-type=text/x-cvsweb-markup&cvsroot=gentoo
plain: 
http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/doc/en/draft/bootstrapping-guide.xml?rev=1.3&content-type=text/plain&cvsroot=gentoo
diff : 
http://www.gentoo.org/cgi-bin/viewcvs.cgi/xml/htdocs/doc/en/draft/bootstrapping-guide.xml.diff?r1=1.2&r2=1.3&cvsroot=gentoo

Index: bootstrapping-guide.xml
===================================================================
RCS file: /var/cvsroot/gentoo/xml/htdocs/doc/en/draft/bootstrapping-guide.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- bootstrapping-guide.xml     30 Nov 2005 05:14:15 -0000      1.2
+++ bootstrapping-guide.xml     1 Dec 2005 18:46:28 -0000       1.3
@@ -1,6 +1,6 @@
 <?xml version='1.0' encoding="UTF-8"?>
 
-<!-- $Header: 
/var/cvsroot/gentoo/xml/htdocs/doc/en/draft/bootstrapping-guide.xml,v 1.2 
2005/11/30 05:14:15 swift Exp $ -->
+<!-- $Header: 
/var/cvsroot/gentoo/xml/htdocs/doc/en/draft/bootstrapping-guide.xml,v 1.3 
2005/12/01 18:46:28 swift Exp $ -->
 
 <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
 
@@ -48,7 +48,8 @@
 In computer theory, bootstrapping has several meanings. All of them boil down 
to
 building more complex systems from simple ones. This document will discuss
 bootstrapping a toolchain: building a full cross-compilation environment able 
to
-build software for the target system.
+build software for the target system, followed by a rebuild of the system to 
the
+native environment.
 </p>
 
 </body>
@@ -58,7 +59,7 @@
 <body>
 
 <p>
-The process of bootstrapping a toolchain is two-fold.
+The process of bootstrapping a toolchain is three-fold.
 </p>
 
 <p>
@@ -66,6 +67,8 @@
 environment, a toolchain capable of running on one system but building software
 for a different one. The second step is to use the cross-compilation toolchain 
 to rebuild itself so that it builds code native to the system it is booted on.
+The third step uses the native compiler to (re)build all packages (including
+itself) so that every tool is built on the target system, for the target 
system.
 </p>
 
 <p>
@@ -84,11 +87,6 @@
   </li>
 </ul>
 
-<p>
-After the toolchain is bootstrapped, the third stage is to build the rest of 
the
-system using the native toolchain.
-</p>
-
 </body>
 </section>
 </chapter>
@@ -99,12 +97,146 @@
 <title>Creating the Cross-Compilation Environment</title>
 <body>
 
+<p>
+We first reserve some space in the home directory to install the
+cross-compilation environment in. We advise to perform the next steps as a
+regular, unprivileged user, so that you can not harm the current system. After
+all, we are going to rebuild core system packages on the system, ready for use
+on a different system, and we don't want to overwrite the ones on the current
+system ;)
+</p>
+
+<pre caption="Creating a destination for the cross-compilation environment">
+$ <i>mkdir ~/cd ~/cd/src</i>
+</pre>
+
+<p>
+We'll store all source code <e>and</e> binaries inside <path>~/cd</path> 
because
+we will need to use those files to boot the new system when the first two 
phases
+are complete.
+</p>
+
+<p>
+At first, extract the source code for the following packages (or similar ones,
+depending on your setup) inside the <path>~/cd/src</path> directory:
+</p>
+
+<dl>
+  <dt><c>gcc</c></dt>
+  <dd>The GNU Compiler Collection</dd>
+  <dt><c>glibc</c></dt>
+  <dd>The GNU C Library</dd>
+  <dt><c>binutils</c></dt>
+  <dd>The tools needed to build programs</dd>
+  <dt><c>vanilla-sources</c></dt>
+  <dd>The Linux kernel tree</dd>
+</dl>
+
+<p>
+These are just examples that are well known, but you can also try using the
+Intel compiler with the ucLibc library, etc.
+</p>
+
+<p>
+Copy over the header files from the kernel to the build root, allowing the 
other
+tools to use the architecture-specific settings of the target architecture:
+</p>
+
+<pre caption="Copying over the header files">
+$ <i>mkdir -p ~/cd/usr/include</i>
+$ <i>cp -a /usr/include/asm* /usr/include/linux ~/cd/usr/include</i>
+</pre>
+
+<p>
+The next step is to build the <c>binutils</c> package suitable for
+cross-compiling. It is recommended that you read the documentation of
+<c>binutils</c> for precise instructions how to do this (just like you should
+for the next packages, <c>gcc</c>, <c>glibc</c> and the Linux kernel). 
+</p>
+
+<pre caption="Building the binutils package">
+$ <i>cd ~/cd/src/binutils-*</i>
+$ <i>./configure --prefix=/usr --target=&lt;target&gt; --with-sysroot=~/cd</i>
+$ <i>make all &amp;&amp; make install</i>
+</pre>
+
+<p>
+Now that the <c>binutils</c> are available in the cross-compilation 
environment,
+we install the <c>glibc</c> headers (the function &amp; constant definitions of
+the c library). Lucky for us, the fine folks at GNU have made this step easier
+by adding a <c>install-headers</c> directive for <c>make</c>:
+</p>
+
+<pre caption="Installing the glibc headers">
+$ <i>cd ~/cd/src/glibc*</i>
+$ <i>./configure --prefix=/usr --build=&lt;build&gt; --host=&lt;target&gt; \
+  --with-headers=~/cd/usr/include --without-cvs --disable-profile \
+  --disable-debug --without-gd --enable-add-ons=nptl --with-tls \
+  --without-__thread --enable-kernel=2.6</i>
+$ <i>make cross-compiling=yes install-headers install_root=~/cd</i>
+$ <i>cp -r include/* ~/cd/usr/include</i>
+</pre>
+
+<p>
+Our next step is to build the cross-compiler:
+</p>
+
+<pre caption="Installing the cross-compiler">
+$ <i>cd ~/cd/src/gcc*</i>
+$ <i>./configure --prefix=/usr --target=&lt;target&gt; --with-sysroot=~/cd \
+  --with-headers=~/cd/usr/include --disable-threads --disable-shared \
+  --enable-language=c</i>
+$ <i>make &amp;&amp; make install</i>
+</pre>
+
+<p>
+Our almost-final step is to build the <c>glibc</c> package (previously, we just
+used the header files):
+</p>
+
+<pre caption="Building the glibc package">
+$ <i>cd ~/cd/src/glibc*</i>
+$ <i>./configure --prefix=/usr --libdir=/usr/lib --build=&lt;build&gt; \
+  --host=&lt;target&gt; --with-headers=/usr/include --without-cvs \
+  --disable-profile --disable-debug --without-gd \
+  --enable-add-ons=nptl --with-tls --without-__thread --enable-kernel=2.6</i>
+$ <i>make &amp;&amp; make install install_root=~/cd</i>
+</pre>
+
+<p>
+In our final step, we build the <c>gcc</c> package again, but now we enable
+support for C++ and shared libraries (which wasn't possible at first):
+</p>
+
+<pre caption="Building gcc">
+$ <i>cd ~/cd/src/gcc*</i>
+$ <i>./configure --prefix=/usr --target=&lt;target&gt; --with-sysroot=~/cd \
+  --with-headers=/usr/include --enable-threads=posix 
--enable-languages=c,++</i>
+$ <i>make &amp;&amp; make install</i>
+</pre>
+
 </body>
 </section>
 <section>
 <title>Filling the Environment</title>
 <body>
 
+<p>
+The <path>~/cd</path> location now contains a minimal environment with the
+cross-compiling toolchain. The next step is to build the core system packages 
so
+that you are able to boot into the minimal environment later on.
+</p>
+
+<p>
+Our first task is to build a Linux kernel. 
+</p>
+
+<pre caption="Building the Linux kernel">
+$ <i>cd ~/cd/src/linux-*</i>
+$ <i>make menuconfig</i>
+$ <i>make dep boot CROSS_COMPILE=&lt;target&gt;</i>
+</pre>
+
 </body>
 </section>
 <section>



-- 
[email protected] mailing list

Reply via email to