Mercurial > hg > aboriginal
annotate www/build-process.html @ 45:fd937c731cac
Add g++ to package list.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sun, 17 Dec 2006 17:32:24 -0500 |
parents | f8c588578fa1 |
children |
rev | line source |
---|---|
5
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
1 <html> |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
2 <title>The Firmware Linux build process</title> |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
3 |
7
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
4 <h1>Executive summary</h1> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
5 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
6 <p>FWL builds a cross-compiler and then uses it to build a minimal system |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
7 containing a native compiler, BusyBox and uClibc. Then it runs this minimal |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
8 system under an emulator (QEMU) to natively build the final system. Finally it |
5
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
9 packages the resulting system (kernel, initramfs, and root filesystem) into |
7
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
10 a single file that can boot and run (on x86 by using a modified version of LILO).</p> |
5
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
11 |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
12 <p>Firmware Linux builds in stages:</p> |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
13 |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
14 <h2>Stage 1: Build a cross-compiler.</h2> |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
15 |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
16 <p>The first stage builds a cross-compiler, |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
17 which runs on the host system and produces binaries that run on the target |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
18 system. (See my <a href=/writing/docs/cross-compiling.html>Introduction to |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
19 cross compiling</a> if you're unfamiliar with this.)</p> |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
20 |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
21 <p>We have to cross-compile even if the host and target system are both |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
22 x86, because the host probably use different C libraries. If the host has |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
23 glibc and the target uses uClibc, then the (dynamically linked) target binaries |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
24 we produce won't run on the host. This is what distinguishes cross-compiling |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
25 from native compiling: different processors are just one reason the binaries |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
26 might not run. Of course, as long as we've got the cross-compiling support |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
27 anyway, we might as well support building for x86_64, arm, mips, or ppc |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
28 targets...</p> |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
29 |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
30 <p>Building a cross-compiler toolchain requires four packages. The bulk of |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
31 it is binutils, gcc, and uClibc, but building those requires header files from |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
32 the Linux kernel which describe the target system.</p> |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
33 |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
34 <h2>Stage 2: Use the cross-compiler to build a native build environment |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
35 for the target.</h2> |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
36 |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
37 <p>Because cross-compiling is persnickety and difficult, we do as little of |
7
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
38 it as possible. Instead we use the cross-compiler to generate the smallest |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
39 possible native build environment for the target, and then run the rest of the |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
40 build in that environment, under an emulator.</p> |
5
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
41 |
7
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
42 <p>The emulator we use is QEMU. The minimal build environment powerful enough |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
43 to boot and compile a complete Linux system requires seven packages: the Linux |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
44 kernel, binutils, gcc, uClibc, BusyBox, make, and bash.</p> |
5
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
45 |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
46 <h2>Stage 3: Run the target's native build environment under an emulator to |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
47 build the final system.</h2> |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
48 |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
49 <p>Running a native build under QEMU is about 1/3 the speed of cross-compiling, |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
50 but it's a lot easier and more reliable.</p> |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
51 |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
52 <p>A trick to accelerate the build is to use distcc to call out to the |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
53 cross-compiler, feeding the results back into the emulator through the virtual |
7
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
54 network. (This is still a TODO item.)</p> |
5
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
55 |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
56 <p>Stage 3 is a fairly straightforward |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
57 <a href=http://www.linuxfromscratch.org>Linux From Scratch</a> approach, |
7
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
58 except that we use BusyBox and uClibc instead of the gnu packages.</p> |
5
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
59 |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
60 <h2>Stage 4: Package the system into a firmware file.</h2> |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
61 |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
62 <p>The reason for the name Firmware Linux is that the entire operating system |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
63 (kernel, initramfs, and read-only squashfs root filesystem) are glued together |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
64 into a single file. A modified version of LILO is included which can boot and |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
65 run this file on x86.</p> |
2907d5193cf6
A real web page, and description of the build process.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
66 |
7
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
67 <hr> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
68 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
69 <h1>Evolution of the firmware Linux build process.</h1> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
70 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
71 <h2>The basic theory</h2> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
72 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
73 <p>The Linux From Scratch approach is to build a minimal intermediate system |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
74 with just enough packages to be able to compile stuff, chroot into that, and |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
75 build the final system from there. This isolates the host from the target, |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
76 which means you should be able to build under a wide variety of distributions. |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
77 It also means the final system is built with a known set of tools, so you get |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
78 a consistent result.</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
79 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
80 <p>A minimal build environment consists of a C library, a compiler, and BusyBox. |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
81 So in theory you just need three packages:</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
82 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
83 <ul> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
84 <li>A C library (uClibc)</li> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
85 <li>A toolchain (tcc)</li> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
86 <li>BusyBox</li> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
87 </ul> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
88 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
89 <p>Unfortunately, that doesn't work yet.</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
90 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
91 <h2>Some differences between theory and reality.</h2> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
92 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
93 <h3>Environmental dependencies.</h2> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
94 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
95 <p>Environmental dependencies are things that need to be installed before you |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
96 can build or run a given package. Lots of packages depend on things like zlib, |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
97 SDL, texinfo, and all sorts of other strange things. (The GnuCash project |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
98 stalled years ago after it released a version with so many environmental |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
99 dependencies it was impossible to build or install. Environmental dependencies |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
100 have a complexity cost, and are thus something to be minimized.)</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
101 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
102 <p>A good build system will scan its environment to figure out what it has |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
103 available, and disable functionality that depends on stuff that isn't |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
104 available. (This is generally done with autoconf, which is disgusting but |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
105 suffers from a lack of alternatives.) That way, the complexity cost is |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
106 optional: you can build a minimal version of the package if that's all you |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
107 need.</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
108 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
109 <p>A really good build system can be told that the environment |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
110 it's building in and the environment the result will run in are different, |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
111 so just because it finds zlib on the build system doesn't mean that the |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
112 target system will have zlib installed on it. (And even if it does, it may not |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
113 be the same version. This is one of the big things that makes cross-compiling |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
114 such a pain. One big reason for statically linking programs is to eliminate |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
115 this kind of environmental dependency.)</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
116 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
117 <p>The Firmware Linux build process is structured the way it is to eliminate |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
118 as many environmental dependencies as possible. Some are unavoidable (such as |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
119 C libraries needing kernel headers or gcc needing binutils), but the |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
120 intermediate system is the minimal fully functional Linux development |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
121 environment I currently know how to build, and then we switch into that and |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
122 work our way back up from there by building more packages in the new |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
123 environment.</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
124 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
125 <h3>Resolving environmental dependencies.</h2> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
126 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
127 <p><b>To build uClibc you need kernel headers</b> identifying the syscalls and |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
128 such it can make to the OS. Way back when you could use the kernel headers |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
129 straight out of the Linux kernel 2.4 tarball and they'd work fine, but sometime |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
130 during 2.5 the kernel developers decided that exporting a sane API to userspace |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
131 wasn't the kernel's job, and stopped doing it.</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
132 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
133 <p>The 0.8x series of Firmware Linux used |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
134 <a href=http://ep09.pld-linux.org/~mmazur/linux-libc-headers/>kernel |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
135 headers manually cleaned up by Mariusz Mazur</a>, but after the 2.6.12 kernel |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
136 he had an attack of real life and fell too far behind to catch up again.</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
137 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
138 <p>The current practice is to use the Linux kernel's "make headers_install" |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
139 target, created by David Woodhouse. This runs various scripts against the |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
140 kernel headers to sanitize them for use by userspace. This was merged in |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
141 2.6.18-rc1, and was more or less debugged by 2.6.19. So can use the Linux |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
142 Kernel tarball as a source of headers again.</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
143 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
144 <p>Another problem is that the busybox shell situation is a mess with four |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
145 implementations that share little or no code (depending on how they're |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
146 configured). The first question when trying to fix them is "which of the four |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
147 do you fix?", and I'm just not going there. So until bbsh goes in we |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
148 <b>substitute bash</b>.</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
149 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
150 <p>Finally, <b>most packages expect gcc</b>. The tcc project isn't a drop-in |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
151 gcc replacement yet, and doesn't include a "make" program. Most importantly, |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
152 tcc development appears stalled because Fabrice Bellard's other major project |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
153 (qemu) is taking up all his time these days. In 2004 Fabrice |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
154 <a href=http://fabrice.bellard.free.fr/tcc/tccboot.html>built a modified Linux |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
155 kernel with tcc</a>, and |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
156 <a href=http://fabrice.bellard.free.fr/tcc/tccboot_readme.html>listed</a> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
157 what needed to be upgraded in TCC to build an unmodified kernel, but |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
158 since then he hardly seems to have touched tcc. Hopefully, someday he'll get |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
159 back to it and put out a 1.0 release of tcc that's a drop-in gcc replacment. |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
160 (And if he does, I'll add a make implementation to toybox so we don't need |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
161 to use any of the gnu toolchain). But in the meantime the only open source |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
162 compiler that can build a complete Linux system is still the gnu compiler.</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
163 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
164 <p>The gnu compiler actually consists of three packages <b>(binutils, gcc, and |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
165 make)</b>, which is why it's generally called the gnu "toolchain". (The split |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
166 between binutils and gcc is for purely historical reasons, and you have |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
167 to match the right versions with each other or things break.)</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
168 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
169 <p>This means that to compile a minimal build environment, you need seven |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
170 packages, and to actually run the result we use an eighth package (QEMU).</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
171 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
172 <p>This can actually be made to work. The next question is how?</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
173 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
174 <h2>Additional complications</h2> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
175 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
176 <h3>Cross-compiling and avoiding root access</h2> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
177 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
178 <p>The first problem is that we're cross-compiling. We can't help it. |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
179 You're cross-compiling any time you create target binaries that won't run on |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
180 the host system. Even when both the host and target are on the same processor, |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
181 if they're sufficiently different that one can't run the other's binaries, then |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
182 you're cross-compiling. In our case, the host is usually running both a |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
183 different C library and an older kernel version than the target, even when |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
184 it's the same processor.</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
185 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
186 <p>The second problem is that we want to avoid requiring root access to build |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
187 Firmware Linux. If the build can run as a normal user, it's a lot more |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
188 portable and a lot less likely to muck up the host system if something goes |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
189 wrong. This means we can't modify the host's / directory (making anything |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
190 that requires absolute paths problematic). We also can't mknod, chown, chgrp, |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
191 mount (for --bind, loopback, tmpfs)...</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
192 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
193 <p>In addition, the gnu toolchain (gcc/binutils) is chock-full of hardwired |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
194 assumptions, such as what C library it's linking binaries against, where to look |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
195 for #included headers, where to look for libraries, the absolute path the |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
196 compiler is installed at... Silliest of all, it assumes that if the host and |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
197 target use the same processor, you're not cross-compiling (even if they have |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
198 a different C library and a different kernel, and even if you ./configure it |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
199 for cross-compiling it switches that back off because it knows better than |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
200 you do). This makes it very brittle, and it also tends to leak its assumptions |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
201 into the programs it builds. New versions may someday fix this, but for now we |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
202 have to hit it on the head repeatedly with a metal bar to get anything remotely |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
203 useful out of it, and run it in a separate filesystem (chroot environment) so |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
204 it can't reach out and grab the wrong headers or wrong libraries despite |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
205 everything we've told it.</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
206 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
207 <p>The absolute paths problem affects target binaries because all dynamically |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
208 linked apps expect their shared library loader to live at an absolute path |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
209 (in this case /lib/ld-uClibc.so.0). This directory is only writeable by root, |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
210 and even if we could install it there polluting the host like that is just |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
211 ugly.</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
212 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
213 <p>The Firmware Linux build has to assume it's cross-compiling because the host |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
214 is generally running glibc, and the target is running uClibc, so the libraries |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
215 the target binaries need aren't installed on the host. Even if they're |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
216 statically linked (which also mitigates the absolute paths problem somewhat), |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
217 the target often has a newer kernel than the host, so the set of syscalls |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
218 uClibc makes (thinking it's talking to the new kernel, since that's what the |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
219 ABI the kernel headers it was built against describe) may not be entirely |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
220 understood by the old kernel, leading to segfaults. (One of the reasons glibc |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
221 is larger than uClibc is it checks the kernel to see if it supports things |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
222 like long filenames or 32-bit device nodes before trying to use them. uClibc |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
223 should always work on a newer kernel than the one it was built to expect, but |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
224 not necessarily an older one.)</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
225 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
226 <h2>Ways to make it all work</h2> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
227 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
228 <h3>Cross compiling vs native compiling under emulation</h3> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
229 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
230 <p>Cross compiling is a pain. There are a lot of ways to get it to sort of |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
231 kinda work for certain versions of certain packages built on certain versions |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
232 of certain distributions. But making it reliable or generally applicable is |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
233 hard to do.</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
234 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
235 <p>I wrote an <a href=/writing/docs/cross-compiling.html>introduction |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
236 to cross-compiling</a> which explains the terminology, plusses and minuses, |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
237 and why you might want to do it. Keep in mind that I wrote that for a company |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
238 that specializes in cross-compiling. Personally, I consider cross-compiling |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
239 a necessary evil to be minimized, and that's how Firmware Linux is designed. |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
240 We cross-compile just enough stuff to get a working native build environment |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
241 for the new platform, which we then run under emulation.</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
242 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
243 <h3>Which emulator?</h3> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
244 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
245 <p>The emulator Firmware Linux 0.8x used was User Mode Linux (here's a |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
246 <a href=http://www.landley.net/writing/docs/UML.html>UML mini-howto</a> I wrote |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
247 while getting this to work). Since we already need the linux-kernel source |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
248 tarball anyway, building User Mode Linux from it was convenient and minimized |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
249 the number of packages we needed to build the minimal system.</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
250 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
251 <p>The first stage of the build compiled a UML kernel and ran the rest of the |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
252 build under that, using UML's hostfs to mount the parent's root filesystem as |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
253 the root filesystem for the new UML kernel. This solved both the kernel |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
254 version and the root access problems. The UML kernel was the new version, and |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
255 supported all the new syscalls and ioctls and such that the uClibc was built to |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
256 expect, translating them to calls to the host system's C library as necessary. |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
257 Processes running under User Mode Linux had root access (at least as far as UML |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
258 was concerned), and although they couldn't write to the hostfs mounted root |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
259 partition, they could create an ext2 image file, loopback mount it, --bind |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
260 mount in directories from the hostfs partition to get the apps they needed, |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
261 and chroot into it. Which is what the build did.</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
262 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
263 <p>Current Firmware Linux has switched to a different emulator, QEMU, because |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
264 as long as we're we're cross-compiling anyway we might as well have the |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
265 ability to cross-compile for non-x86 targets. We still build a new kernel |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
266 to run the uClibc binaries with the new kernel ABI, we just build a bootable |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
267 kernel and run it under QEMU.</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
268 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
269 <p>The main difference with QEMU is a sharper dividing line between the host |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
270 system and the emulated target. Under UML we could switch to the emulated |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
271 system early and still run host binaries (via the hostfs mount). This meant |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
272 we could be much more relaxed about cross compiling, because we had one |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
273 environment that ran both types of binaries. But this doesn't work if we're |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
274 building an ARM, PPC, or x86-64 system on an x86 host.</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
275 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
276 <p>Instead, we need to sequence more carefully. We build a cross-compiler, |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
277 use that to cross-compile a minimal intermediate system from the seven packages |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
278 listed earlier, and build a kernel and QEMU. Then we run the kernel under QEMU |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
279 with the new intermediate system, and have it build the rest natively.</p> |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
280 |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
281 <p>It's possible to use other emulators instead of QEMU, and I have a todo |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
282 item to look at armulator from uClinux. (I looked at another nommu system |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
283 simulator at Ottawa Linux Symposium, but after resolving the third unnecessary |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
284 environmental dependency and still not being able to get it to finish compiling |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
285 yet, I gave up. Armulator may be a patch against an obsolete version of gdb, |
f8c588578fa1
Finish shuffling old website material into new website.
Rob Landley <rob@landley.net>
parents:
5
diff
changeset
|
286 but I could at least get it to build.)</p> |