/[gentoo]/xml/htdocs/doc/en/draft/bootstrapping-guide.xml
Gentoo

Diff of /xml/htdocs/doc/en/draft/bootstrapping-guide.xml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.2 Revision 1.3
1<?xml version='1.0' encoding="UTF-8"?> 1<?xml version='1.0' encoding="UTF-8"?>
2 2
3<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/draft/bootstrapping-guide.xml,v 1.2 2005/11/30 05:14:15 swift Exp $ --> 3<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/draft/bootstrapping-guide.xml,v 1.3 2005/12/01 18:46:28 swift Exp $ -->
4 4
5<!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> 5<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
6 6
7<guide link="/doc/en/draft/bootstrapping-guide.xml"> 7<guide link="/doc/en/draft/bootstrapping-guide.xml">
8<title>Gentoo Bootstrapping Guide</title> 8<title>Gentoo Bootstrapping Guide</title>
46 46
47<p> 47<p>
48In computer theory, bootstrapping has several meanings. All of them boil down to 48In computer theory, bootstrapping has several meanings. All of them boil down to
49building more complex systems from simple ones. This document will discuss 49building more complex systems from simple ones. This document will discuss
50bootstrapping a toolchain: building a full cross-compilation environment able to 50bootstrapping a toolchain: building a full cross-compilation environment able to
51build software for the target system. 51build software for the target system, followed by a rebuild of the system to the
52native environment.
52</p> 53</p>
53 54
54</body> 55</body>
55</section> 56</section>
56<section> 57<section>
57<title>Toolchain Bootstrapping</title> 58<title>Toolchain Bootstrapping</title>
58<body> 59<body>
59 60
60<p> 61<p>
61The process of bootstrapping a toolchain is two-fold. 62The process of bootstrapping a toolchain is three-fold.
62</p> 63</p>
63 64
64<p> 65<p>
65At first, you use an existing toolchain to create a cross-compilation 66At first, you use an existing toolchain to create a cross-compilation
66environment, a toolchain capable of running on one system but building software 67environment, a toolchain capable of running on one system but building software
67for a different one. The second step is to use the cross-compilation toolchain 68for a different one. The second step is to use the cross-compilation toolchain
68to rebuild itself so that it builds code native to the system it is booted on. 69to rebuild itself so that it builds code native to the system it is booted on.
70The third step uses the native compiler to (re)build all packages (including
71itself) so that every tool is built on the target system, for the target system.
69</p> 72</p>
70 73
71<p> 74<p>
72There are three important terms we use in this definition: 75There are three important terms we use in this definition:
73</p> 76</p>
82 the <e>target</e> system is the system for which the software generates 85 the <e>target</e> system is the system for which the software generates
83 output (like the compiler) 86 output (like the compiler)
84 </li> 87 </li>
85</ul> 88</ul>
86 89
87<p>
88After the toolchain is bootstrapped, the third stage is to build the rest of the
89system using the native toolchain.
90</p>
91
92</body> 90</body>
93</section> 91</section>
94</chapter> 92</chapter>
95 93
96<chapter> 94<chapter>
97<title>Installing Gentoo on an Unsupported Platform</title> 95<title>Installing Gentoo on an Unsupported Platform</title>
98<section> 96<section>
99<title>Creating the Cross-Compilation Environment</title> 97<title>Creating the Cross-Compilation Environment</title>
100<body> 98<body>
101 99
100<p>
101We first reserve some space in the home directory to install the
102cross-compilation environment in. We advise to perform the next steps as a
103regular, unprivileged user, so that you can not harm the current system. After
104all, we are going to rebuild core system packages on the system, ready for use
105on a different system, and we don't want to overwrite the ones on the current
106system ;)
107</p>
108
109<pre caption="Creating a destination for the cross-compilation environment">
110$ <i>mkdir ~/cd ~/cd/src</i>
111</pre>
112
113<p>
114We'll store all source code <e>and</e> binaries inside <path>~/cd</path> because
115we will need to use those files to boot the new system when the first two phases
116are complete.
117</p>
118
119<p>
120At first, extract the source code for the following packages (or similar ones,
121depending on your setup) inside the <path>~/cd/src</path> directory:
122</p>
123
124<dl>
125 <dt><c>gcc</c></dt>
126 <dd>The GNU Compiler Collection</dd>
127 <dt><c>glibc</c></dt>
128 <dd>The GNU C Library</dd>
129 <dt><c>binutils</c></dt>
130 <dd>The tools needed to build programs</dd>
131 <dt><c>vanilla-sources</c></dt>
132 <dd>The Linux kernel tree</dd>
133</dl>
134
135<p>
136These are just examples that are well known, but you can also try using the
137Intel compiler with the ucLibc library, etc.
138</p>
139
140<p>
141Copy over the header files from the kernel to the build root, allowing the other
142tools to use the architecture-specific settings of the target architecture:
143</p>
144
145<pre caption="Copying over the header files">
146$ <i>mkdir -p ~/cd/usr/include</i>
147$ <i>cp -a /usr/include/asm* /usr/include/linux ~/cd/usr/include</i>
148</pre>
149
150<p>
151The next step is to build the <c>binutils</c> package suitable for
152cross-compiling. It is recommended that you read the documentation of
153<c>binutils</c> for precise instructions how to do this (just like you should
154for the next packages, <c>gcc</c>, <c>glibc</c> and the Linux kernel).
155</p>
156
157<pre caption="Building the binutils package">
158$ <i>cd ~/cd/src/binutils-*</i>
159$ <i>./configure --prefix=/usr --target=&lt;target&gt; --with-sysroot=~/cd</i>
160$ <i>make all &amp;&amp; make install</i>
161</pre>
162
163<p>
164Now that the <c>binutils</c> are available in the cross-compilation environment,
165we install the <c>glibc</c> headers (the function &amp; constant definitions of
166the c library). Lucky for us, the fine folks at GNU have made this step easier
167by adding a <c>install-headers</c> directive for <c>make</c>:
168</p>
169
170<pre caption="Installing the glibc headers">
171$ <i>cd ~/cd/src/glibc*</i>
172$ <i>./configure --prefix=/usr --build=&lt;build&gt; --host=&lt;target&gt; \
173 --with-headers=~/cd/usr/include --without-cvs --disable-profile \
174 --disable-debug --without-gd --enable-add-ons=nptl --with-tls \
175 --without-__thread --enable-kernel=2.6</i>
176$ <i>make cross-compiling=yes install-headers install_root=~/cd</i>
177$ <i>cp -r include/* ~/cd/usr/include</i>
178</pre>
179
180<p>
181Our next step is to build the cross-compiler:
182</p>
183
184<pre caption="Installing the cross-compiler">
185$ <i>cd ~/cd/src/gcc*</i>
186$ <i>./configure --prefix=/usr --target=&lt;target&gt; --with-sysroot=~/cd \
187 --with-headers=~/cd/usr/include --disable-threads --disable-shared \
188 --enable-language=c</i>
189$ <i>make &amp;&amp; make install</i>
190</pre>
191
192<p>
193Our almost-final step is to build the <c>glibc</c> package (previously, we just
194used the header files):
195</p>
196
197<pre caption="Building the glibc package">
198$ <i>cd ~/cd/src/glibc*</i>
199$ <i>./configure --prefix=/usr --libdir=/usr/lib --build=&lt;build&gt; \
200 --host=&lt;target&gt; --with-headers=/usr/include --without-cvs \
201 --disable-profile --disable-debug --without-gd \
202 --enable-add-ons=nptl --with-tls --without-__thread --enable-kernel=2.6</i>
203$ <i>make &amp;&amp; make install install_root=~/cd</i>
204</pre>
205
206<p>
207In our final step, we build the <c>gcc</c> package again, but now we enable
208support for C++ and shared libraries (which wasn't possible at first):
209</p>
210
211<pre caption="Building gcc">
212$ <i>cd ~/cd/src/gcc*</i>
213$ <i>./configure --prefix=/usr --target=&lt;target&gt; --with-sysroot=~/cd \
214 --with-headers=/usr/include --enable-threads=posix --enable-languages=c,++</i>
215$ <i>make &amp;&amp; make install</i>
216</pre>
217
102</body> 218</body>
103</section> 219</section>
104<section> 220<section>
105<title>Filling the Environment</title> 221<title>Filling the Environment</title>
106<body> 222<body>
223
224<p>
225The <path>~/cd</path> location now contains a minimal environment with the
226cross-compiling toolchain. The next step is to build the core system packages so
227that you are able to boot into the minimal environment later on.
228</p>
229
230<p>
231Our first task is to build a Linux kernel.
232</p>
233
234<pre caption="Building the Linux kernel">
235$ <i>cd ~/cd/src/linux-*</i>
236$ <i>make menuconfig</i>
237$ <i>make dep boot CROSS_COMPILE=&lt;target&gt;</i>
238</pre>
107 239
108</body> 240</body>
109</section> 241</section>
110<section> 242<section>
111<title>Bootstrapping the Toolchain</title> 243<title>Bootstrapping the Toolchain</title>

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.20