forked from PickXu/mit_6.828
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtools.html
More file actions
435 lines (353 loc) · 18.2 KB
/
tools.html
File metadata and controls
435 lines (353 loc) · 18.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
<HTML>
<HEAD>
<TITLE>
6.828 / Fall 2014
</TITLE>
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" href="css/labs.css" type="text/css" />
</HEAD>
<BODY BGCOLOR=#ffffff TEXT=#000000>
<!-- Fixed navbar -->
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">6.828: Operating System Engineering</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="schedule.html">Schedule</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Class<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="overview.html">Overview</a></li>
<li><a href="general.html">Administrivia</a></li>
<li><a href="classes.html">Related classes</a></li>
<li><a href="http://pdos.csail.mit.edu/6.828/2012">6.828 2012</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Labs<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="tools.html">Tools</a></li>
<li><a href="labguide.html">Lab guide</a></li>
<li><a href="labs/lab1">Lab 1</a></li>
<li><a href="labs/lab2">Lab 2</a></li>
<li><a href="labs/lab3">Lab 3</a></li>
<li><a href="labs/lab4">Lab 4</a></li>
<li><a href="labs/lab5">Lab 5</a></li>
<li><a href="labs/lab6">Lab 6</a></li>
<li><a href="labs/lab7">Lab 7</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">xv6<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="xv6.html">xv6</a></li>
<li><a href="readings/xv6-rev8.pdf">xv6 printout</a></li>
<li><a href="readings/book-rev8.pdf">xv6 book</a></li>
</ul>
</li>
<li><a href="reference.html">References</a></li>
<li><a href="https://piazza.com/class/hxbtuy99afz46m">Piazza</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<p class="navbar-text">2014</p>
</ul>
</div>
</div>
</div>
<div class="container">
<style type='text/css'>
.l {
margin-left: 4em;
}
</style>
<script type='text/javascript'>
function unfoldinstrux(unfold) {
var e = document.getElementById("installinstrux");
e.className = unfold ? "foldo" : "foldc";
}
</script>
<H1>
Tools Used in 6.828
</H1>
<p> You'll use two sets of tools in this class: an x86 emulator, <a href="#qemu">QEMU</a>, for
running your kernel; and a <a href="#chain">compiler toolchain</a>, including assembler, linker, C
compiler, and debugger, for compiling and testing your kernel. This page has the
information you'll need to download and install your own copies. This class
assumes familiarity with Unix commands throughout.
<p> We highly recommend using a Debathena machine, such as
athena.dialup.mit.edu, to work on the labs. If you use the MIT Athena machines
that run Linux, then all the software tools you will need for this course are
located in the 6.828 locker: just type '<samp>add -f 6.828</samp>' to get access
to them.
<p>If you don't have access to a Debathena machine, we recommend you use a
virtual machine with Linux. If you really want to, you can build and
install the tools on your own machine. We have instructions below for Unix and
MacOS computers.
<p>
It should be possible to get this development environment running
under windows with the help of
<a href="http://www.cygwin.com">Cygwin</a>. Install cygwin, and be
sure to install the <samp>flex</samp> and <samp>bison</samp> packages
(they are under the development header).
<p>
For an overview of useful commands in the tools used in 6.828, see the
<a href="labguide.html">lab tools guide</a>.
<h2 id="chain">Compiler Toolchain</h2>
<p>A "compiler toolchain" is the set of programs, including a C
compiler, assemblers, and linkers, that turn code into executable
binaries. You'll need a compiler toolchain that generates code for
32-bit Intel architectures ("x86" architectures) in the ELF
binary format.
<h3>Test Your Compiler Toolchain</h3>
<p>Modern Linux and BSD UNIX distributions already
provide a toolchain suitable for 6.828. To test your
distribution, try the following commands:</p>
<pre class='samp'>
% <span class='type'>objdump -i</span>
</pre>
<p>The second line should say <tt>elf32-i386</tt>.</p>
<pre class='samp'>
% <span class='type'>gcc -m32 -print-libgcc-file-name</span>
</pre>
<p>The command should print something like
<tt>/usr/lib/gcc/i486-linux-gnu/<i>version</i>/libgcc.a</tt> or
<tt>/usr/lib/gcc/x86_64-linux-gnu/<i>version</i>/32/libgcc.a</tt>
<p>If both these commands succeed, you're all set, and
don't need to compile your own toolchain.</p>
<div class='note'>
<p>If the <span class='type'>gcc</span> command fails, you may need to
install a development environment. On Ubuntu Linux, try this:</p>
<pre class='samp'>
% <span class='type'>sudo apt-get install -y build-essential gdb</span>
</pre>
<p>On 64-bit machines, you may need to install a 32-bit support
library. The symptom is that linking fails with error messages
like "<tt>__udivdi3</tt> not found" and "<tt>__muldi3</tt> not
found". On Ubuntu Linux, try this to fix the problem:</p>
<pre class='samp'>
% <span class='type'>sudo apt-get install gcc-multilib</span>
</pre>
<h3>Using a Virtual Machine</h3>
<p>Otherwise, the easiest way to get a compatible
toolchain is to install a modern Linux distribution on
your computer. With platform virtualization, Linux can
cohabitate with your normal computing environment. Installing a
Linux virtual machine is a two step process. First, you download
the virtualization platform.</p>
<ul><li><a href='http://www.oracle.com/us/technologies/virtualization/oraclevm/'><strong>VirtualBox</strong></a>
(free for Mac, Linux, Windows) — <a
href='http://www.oracle.com/us/technologies/virtualization/oraclevm/'>Download
page</a></li>
<li><a href='http://www.vmware.com/products/player/'>VMware
Player</a> (free for Linux and Windows, registration required)</li>
<li><a href='http://www.vmware.com/products/fusion/'>VMware
Fusion</a> (Downloadable from IS&T for free).
</ul>
<p>VirtualBox is a little slower and less flexible, but free!</p>
<p>Once the virtualization platform is installed, download a boot
disk image for the Linux distribution of your choice.</p>
<ul><li><a
href='http://www.ubuntu.com/desktop/get-ubuntu/download'>Ubuntu
Desktop</a> is what we use.</li>
</ul>
<p>This will download a file named something like
<tt>ubuntu-10.04.1-desktop-i386.iso</tt>. Start up your
virtualization platform and create a new (32-bit) virtual machine.
Use the downloaded Ubuntu image as a boot disk; the
procedure differs among VMs but is pretty simple. Type <tt
class='type'>objdump -i</tt>, as above, to verify that your
toolchain is now set up. You will do your work inside the VM.</p></div>
<h3>Building Your Own Compiler Toolchain</h3>
<p> This will take longer to set up, but give slightly better performance than a
virtual machine, and lets you work in your own familiar environment
(Unix/MacOS). (We believe the instructions work for MacOS too, but haven't
confirmed recently. If it works, let's us know.)
<p> You can use your own tool chain by adding the following line to
<tt>conf/env.mk</tt>:
<pre>
GCCPREFIX=
</pre>
<p>We assume that you are installing the toolchain into
<tt>/usr/local</tt>. You will need a fair amount of disk space to compile
the tools (around 1GiB). If you don't have that much space, delete
each directory after its <tt class='type'>make install</tt> step.</p>
<p>Download the following packages:</p>
<ul><li><a href='ftp://ftp.gmplib.org/pub/gmp-5.0.2/gmp-5.0.2.tar.bz2'>ftp://ftp.gmplib.org/pub/gmp-5.0.2/gmp-5.0.2.tar.bz2</a></li>
<li><a href='http://www.mpfr.org/mpfr-current/mpfr-3.1.2.tar.bz2'>http://www.mpfr.org/mpfr-current/mpfr-3.1.2.tar.bz2</a></li>
<li><a href='http://www.multiprecision.org/mpc/download/mpc-0.9.tar.gz'>http://www.multiprecision.org/mpC/download/mpc-0.9.tar.gz</a></li>
<li><a href='http://ftpmirror.gnu.org/binutils/binutils-2.21.1.tar.bz2'>http://ftpmirror.gnu.org/binutils/binutils-2.21.1.tar.bz2</a></li>
<li><a href='http://ftpmirror.gnu.org/gcc/gcc-4.6.1/gcc-core-4.6.1.tar.bz2'>http://ftpmirror.gnu.org/gcc/gcc-4.6.1/gcc-core-4.6.1.tar.bz2</a></li>
<li><a href='http://ftpmirror.gnu.org/gdb/gdb-7.3.1.tar.bz2'>http://ftpmirror.gnu.org/gdb/gdb-7.3.1.tar.bz2</a></li></ul>
<div id='installinstrux' class='foldc'>
<p>(You may also use newer versions of these packages.)
Unpack and build the packages. The <tt class='type'>green bold</tt>
text shows you how to install into <code>/usr/local</code>, which is what
we recommend. To install into a different directory,
<span class='type2'>$PFX</span>, <a class='fn' href='javascript:unfoldinstrux(1)'>click here</a><span class='fx'>note the differences in <span class='type2'>lighter type</span> (<a href='javascript:unfoldinstrux(0)'>hide</a>)</span>. If you have problems, see below.</p>
<pre class='samp'>
<div class='fx'><span class='type2'>export PATH=$PFX/bin:$PATH</span>
<span class='type2'>export LD_LIBRARY_PATH=$PFX/lib:$LD_LIBRARY_PATH</span> # On Mac OS X, use DYLD_LIBRARY_PATH
</div><span class='type'>tar xjf gmp-5.0.2.tar.bz2</span>
<span class='type'>cd gmp-5.0.2</span>
<span class='type'>./configure <span class='fn'>--prefix=/usr/local</span><span class='fx type2'>--prefix=$PFX</span></span>
<span class='type'>make</span>
<span class='type'>make install</span> # This step may require privilege (<span class='type'>sudo make install</span>)
<span class='type'>cd ..</span>
<span class='type'>tar xjf mpfr-3.0.1.tar.bz2</span>
<span class='type'>cd mpfr-3.0.1</span>
<span class='type'>./configure <span class='fn'>--prefix=/usr/local</span><span class='fx type2'>--prefix=$PFX --with-gmp=$PFX</span></span>
<span class='type'>make</span>
<span class='type'>make install</span> # This step may require privilege (<span class='type'>sudo make install</span>)
<span class='type'>cd ..</span>
<span class='type'>tar xzf mpc-0.9.tar.gz</span>
<span class='type'>cd mpc-0.9</span>
<span class='type'>./configure <span class='fn'>--prefix=/usr/local</span><span class='fx type2'>--prefix=$PFX --with-gmp=$PFX --with-mpfr=$PFX</span></span>
<span class='type'>make</span>
<span class='type'>make install</span> # This step may require privilege (<span class='type'>sudo make install</span>)
<span class='type'>cd ..</span>
<span class='type'>tar xjf binutils-2.21.1.tar.bz2</span>
<span class='type'>cd binutils-2.21.1</span>
<span class='type'>./configure <span class='fn'>--prefix=/usr/local</span><span class='fx type2'>--prefix=$PFX</span> --target=i386-jos-elf --disable-werror</span>
<span class='type'>make</span>
<span class='type'>make install</span> # This step may require privilege (<span class='type'>sudo make install</span>)
<span class='type'>cd ..</span>
<span class='type'>i386-jos-elf-objdump -i</span>
# Should produce output like:
# BFD header file version (GNU Binutils) 2.21.1
# elf32-i386
# (header little endian, data little endian)
# i386...
<span class='type'>tar xjf gcc-core-4.6.1.tar.bz2</span>
<span class='type'>cd gcc-4.6.1</span>
<span class='type'>mkdir build</span> # GCC will not compile correctly unless you build in a separate directory
<span class='type'>cd build</span>
<span class='type'>../configure <span class='fn'>--prefix=/usr/local</span><span class='fx type2'>--prefix=$PFX --with-gmp=$PFX --with-mpfr=$PFX --with-mpc=$PFX</span> \</span>
<span class='type'> --target=i386-jos-elf --disable-werror \</span>
<span class='type'> --disable-libssp --disable-libmudflap --with-newlib \</span>
<span class='type'> --without-headers --enable-languages=c</span>
<div class='further'>MAC OS X 10.7 "LION" NOTE: The default clang compiler on Mac OS X 10.7
cannot build a working version of GCC. Use the following configure
line to work around the problem (this has reported to work with OS X 10.9.4 withXCode 5.1.1 and its Command Line Tools package (for gcc):
<span class='type'>../configure <span class='fn'>--prefix=/usr/local</span><span class='fx type2'>--prefix=$PFX --with-gmp=$PFX --with-mpfr=$PFX --with-mpc=$PFX</span> \</span>
<span class='type'> --target=i386-jos-elf --disable-werror \</span>
<span class='type'> --disable-libssp --disable-libmudflap --with-newlib \</span>
<span class='type'> --without-headers --enable-languages=c \</span>
<span class='type'> CC=/usr/bin/gcc-4.2 \</span>
<span class='type'>make all-gcc</span>
<span class='type'>make install-gcc</span> # This step may require privilege (<span class='type'>sudo make install-gcc</span>)
<span class='type'>make all-target-libgcc</span>
<span class='type'>make install-target-libgcc</span> # This step may require privilege (<span class='type'>sudo make install-target-libgcc</span>)
<span class='type'>cd ../..</span>
<span class='type'>i386-jos-elf-gcc -v</span>
# Should produce output like:
# Using built-in specs.
# COLLECT_GCC=i386-jos-elf-gcc
# COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/i386-jos-elf/4.6.1/lto-wrapper
# Target: i386-jos-elf
<span class='type'>tar xjf gdb-7.3.1.tar.bz2</span>
<span class='type'>cd gdb-7.3.1</span>
<span class='type'>./configure <span class='fn'>--prefix=/usr/local</span><span class='fx type2'>--prefix=$PFX</span> --target=i386-jos-elf --program-prefix=i386-jos-elf- \</span>
<span class='type'> --disable-werror</span>
<span class='type'>make all</span>
<span class='type'>make install</span> # This step may require privilege (<span class='type'>sudo make install</span>)
<span class='type'>cd ..</span>
</pre></div>
<h4>Troubleshooting</h4>
<dl>
<dt>Q. I can't run <tt class='type'>make install</tt> because I don't
have root permission on this machine.</dt>
<dd>A. Our instructions assume you are installing into the
<tt>/usr/local</tt> directory. However, this may not be allowed in
your environment. If you can only install code into your home
directory, that's OK. In the instructions above, replace
<tt>--prefix=/usr/local</tt> with <tt>--prefix=$HOME</tt> (and
<a href='javascript:unfoldinstrux(1)'>click here</a> to update the
instructions further). You will also need to change your <tt>PATH</tt>
and <tt>LD_LIBRARY_PATH</tt> (Linux) or <tt>DYLD_LIBRARY_PATH</tt> (Mac
OS X) environment variables, to inform your shell where to find the
tools. For example:
<pre class='samp'>
export PATH=$HOME/bin:$PATH
export LD_LIBRARY_PATH=$HOME/lib:$LD_LIBRARY_PATH
</pre>
Enter these lines in your <tt>~/.bashrc</tt> file so you don't need
to type them every time you log in.</dd>
</dl>
<dl>
<dt>Q. My build fails with an inscrutable message about "library not
found".</dt>
<dd>A. You need to set your <tt>LD_LIBRARY_PATH</tt> (Linux) or
<tt>DYLD_LIBRARY_PATH</tt> (Mac OS X) environment variable to
include the libraries you built; see above. The environment
variable must include the <tt>PREFIX/lib</tt> directory (for
instance, <tt>/usr/local/lib</tt>).</dd>
</dl>
<h2 id="qemu">QEMU Emulator</h2>
<p><a href="http://www.nongnu.org/qemu/">QEMU</a> is a modern and fast
PC emulator. QEMU version 1.7.0 is set up on Athena for x86 machines
in the 6.828 locker (<tt>add -f 6.828</tt>)</p>
<p>Unfortunately, QEMU's debugging facilities, while powerful, are
somewhat immature, so we highly recommend you use our patched version
of QEMU instead of the stock version that may come with your
distribution. The version installed on Athena is already patched.
To build your own patched version of QEMU:</p>
<!-- Note to staff:
Some of the QEMU patches were applied upstream and should appear
in releases post-0.15.
-->
<ol>
<li> Clone the IAP 6.828 QEMU git repository
<code>git clone https://github.com/geofft/qemu.git -b 6.828-1.7.0</code></li>
<li> On Linux, you may need to install the SDL development libraries to
get a graphical VGA window. On Debian/Ubuntu, this is the
libsdl1.2-dev package.</li>
<li> Configure the source code
<ol>
<li>Linux:
<code>./configure --disable-kvm [--prefix=PFX] [--target-list="i386-softmmu x86_64-softmmu"]</code></li>
<li>OS X:
<code>./configure --disable-kvm --disable-sdl [--prefix=PFX] [--target-list="i386-softmmu x86_64-softmmu"]</code>
The <code>prefix</code> argument specifies where to install QEMU; without it
QEMU will install to <code>/usr/local</code> by default. The <code>target-list</code>
argument simply slims down the architectures QEMU will build support
for.</li>
</ol></li>
<li> Run <code>make && make install</code></li>
</ol>
<!-- End Page Content -->
<hr>
<font style="font-size: 12px;">
<p>Questions or comments regarding 6.828? Send e-mail to the TAs at
<A
<p><a rel="license" href="http://creativecommons.org/licenses/by/3.0/us/"><img
alt="Creative Commons License" style="border-width:0"
src="http://i.creativecommons.org/l/by/3.0/us/88x31.png" ></a> <B><A HREF="#top">Top</A></B> //
<B><A HREF="index.html">6.828 home</A></B> //
<i>Last updated Monday, 15-Sep-2014 07:40:33 EDT</i>
</font>
</div>
<script src="js/jquery-1.10.2.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</BODY>
</HTML>
<!-- LocalWords: Cygwin cygwin Toolchain Linuxes BSDs toolchain gcc ld jos cd
-->
<!-- LocalWords: objdump conf GCCPREFIX linux binutils libstdc GNUmakefile sh
-->
<!-- LocalWords: Bochs athena scp username bochs prebuilt wget xzvf
-->
<!-- LocalWords: disasm
-->