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