To develop the Pintos projects, you’ll need two essential sets of tools:
The CS department’s lab machines
already have these tools available under
/usr/local/data/cs318/x86_64. You just
need to modify your PATH setting to include it. For Bash, that is to put the following
at the end of your
$ export PATH=/usr/local/data/cs318/x86_64/bin:$PATH
For tcsh (the default login shell in ugrad lab machines in the CS department),
the syntax is different: add
set path = (/usr/local/data/cs318/x86_64/bin $path)
to the end of your
~/.tcshrc. Log out and re-login to let it take effect.
Besides the lab machines, you may want to work on the projects on your own machines to be more productive. This page contains instructions to help you with the setup of the core development environment needed for Pintos on your own machines. They are intended for Unix and Mac OS machines. If you are running Windows, we recommend you to run a virtual machine with Linux or you will have to setup Cygwin first. This guide, and the course in general, assumes you are familiar with Unix commands.
The best Pintos development environment is your laptop/desktop. For Linux distributions, Ubuntu 16.04 is what we use. But it is fine to use others like Ubuntu 18.04 or Fedora. Mac computers work, too. If you are using a Windows machine, we recommend you to install a virtual machine.
8b0d51c02fc17082f545f07c9fa373f4. The initial login password is
The compiler toolchain is a collection of tools that turns source code into binary
executables for a target architecture. Pintos is written in C and
x86 assembly, and runs on 32-bit x86 machines. So we will need the appropriate
C compiler (
gcc), assembler (
as), linker (
ld) and debugger (
If you are using a Linux machine, it is likely equipped with the compiler toolchain already.
But it should support 32-bit x86 architecture. A quick test of the support is to run
objdump -i | grep elf32-i386 in the terminal. If it returns matching lines, your
system’s default tool chain supports the target, then you can skip Section 2.2.
Otherwise, you will need to build the toolchain from source.
objdump -itest won't work.
objdump -itest. However, you will likely encounter an issue later presumably due to a gcc 7 toolchain bug (see discussion). It is recommended that you build the toolchain from source according to Section 2.2.
sudo apt-get install build-essential gdb gcc-multilib. The
objdump -itest should pass.
When you are building the toolchain from source, to distinguish the new toolchain
from your system’s default one, you should add a
i386-elf- prefix to the build
$ sudo apt-get install build-essential automake git $ sudo apt-get install libncurses5-dev texinfo
pintos/src/misc/toolchain-build.sh) that automates the building instructions. So you can just run the script and modify your PATH setting after the build finishes. The script has been tested on recent version of Ubuntu, Mac OS and Fedora.
$ SWD=/path/to/setup $ mkdir -p $SWD $ cd /path/to/pintos/src $ misc/toolchain-build.sh $SWD
SWD in the above commands with a real path to store the toolchain source and build,
/home/ryan/318/toolchain. If the above commands succeeded,
add the toolchain path to your PATH environment variable settings in the
.zshrc if you are using zsh) file in your home directory.
$ export PATH=$SWD/x86_64/bin:$PATH
Don’t forget to replace the
$SWD above with the real path, e.g.,
If you are curious to build the toolchain manually, below are the detailed instructions.
~/318/toolchain) and subdirectories that look like this:
/path/to/setup ├── build ├── x86_64 └── src
/path/to/setupwith the full path to the actual setup directory you’ve created, e.g.,
$ SWD=/path/to/setup $ PREFIX=$SWD/x86_64 $ export PATH=$PREFIX/bin:$PATH $ export LD_LIBRARY_PATH=$PREFIX/lib:$LD_LIBRARY_PATH
For Mac users, the last command is
export DYLD_LIBRARY_PATH=$PREFIX/lib:$DYLD_LIBRARY_PATH instead.
$ cd $SWD/src $ wget https://ftp.gnu.org/gnu/binutils/binutils-2.27.tar.gz && tar xzf binutils-2.27.tar.gz
$ mkdir -p $SWD/build/binutils && cd $SWD/build/binutils $ ../../src/binutils-2.27/configure --prefix=$PREFIX --target=i386-elf \ --disable-multilib --disable-nls --disable-werror $ make -j8 $ make install
$ cd $SWD/src $ wget https://ftp.gnu.org/gnu/gcc/gcc-6.2.0/gcc-6.2.0.tar.bz2 && tar xjf gcc-6.2.0.tar.bz2 $ cd $SWD/src/gcc-6.2.0 && contrib/download_prerequisites
$ mkdir -p $SWD/build/gcc && cd $SWD/build/gcc $ ../../src/gcc-6.2.0/configure --prefix=$PREFIX --target=i386-elf \ --disable-multilib --disable-nls --disable-werror --disable-libssp \ --disable-libmudflap --with-newlib --without-headers --enable-languages=c,c++ $ make -j8 all-gcc $ make install-gcc $ make all-target-libgcc $ make install-target-libgcc
$ cd $SWD/src $ wget https://ftp.gnu.org/gnu/gdb/gdb-7.9.1.tar.xz && tar xJf gdb-7.9.1.tar.xz
$ mkdir -p $SWD/build/gdb && cd $SWD/build/gdb $ ../../src/gdb-7.9.1/configure --prefix=$PREFIX --target=i386-elf --disable-werror $ make -j8 $ make install
Now check if the toolchain has been installed to the proper place and the version is
$ which i386-elf-gcc $ i386-elf-gcc --version
If you see the command not found error message, check if you have added
.zshrc (depending on your shell
If so, you may need to restart your terminal for the new
PATH to take effect.
You may also want to delete the source and build directories in
to save space.
Besides the cross-compiler toolchain, we also need an x86 emulator to run Pintos OS. We will use two popular emulators QEMU and Bochs.
sudo apt-get install qemu libvirt-bin.
brew install qemu.
pintos/src/misc/bochs*.patch. We will build two versions of Bochs: one, simply named
bochs, with the GDB stub enabled, and the other, named
bochs-dbg, with the built-in debugger enabled.
pintos/src/misc/bochs-2.6.2-build.shthat will download, patch and build two versions of the Bochs for you.
$ pintos/src/misc/bochs-2.6.2-build.sh /path/to/swd/x86_64
/path/to/swd/x86_64 with the actual directory path, e.g.,
bochs-dbare in PATH. You can verify the install with
bochs --version. The output should contain
The Pintos source distribution comes with a few handy scripts that you will be
using frequently. They are located within
src/utils/. The most important one is
pintos Perl script, which you will be using to start and run tests
in pintos. You need to make sure it can be found in your PATH environment
variable. In addition, the
src/misc/gdb-macros is provided with a number of
GDB macros that you will find useful when you are debugging Pintos. The
is a wrapper around the
i386-elf-gdb that reads this macro file at start.
It assumes the macro file resides in
The example commands to do the above setup for the Pintos utilities are:
/path/to/swd/x86_64 with the actual directory path)
$ cd pintos/src/utils && make $ cp backtrace pintos Pintos.pm pintos-gdb pintos-set-cmdline pintos-mkdisk setitimer-helper squish-pty squish-unix /path/to/swd/x86_64/bin $ mkdir /path/to/swd/x86_64/misc $ cp ../misc/gdb-macros /path/to/swd/x86_64/misc