Building System/161 and the OS/161 Toolchain
If you want to work on your own machine, you can follow the
instructions given here to build the MIPS compiler tool chain (used to
compile the kernel and OS/161 user programs), and System/161.
The commands given here only build the MIPS toolchain
and System/161 — the tools needed to build and run the OS. It
doesn't include the OS source code. You'll need to check out the
OS/161 source using Subversion.
We can't easily troubleshoot problems you may have with your dorm
machines, so if these steps don't work out for you, we suggest you
just use the provided infrastructure and develop your code on
Knuth.
Setup
On your system, you'll need all the usual development tools. On an
Ubuntu system, you may also have to run
sudo apt-get install texinfo
(it is already there on Macs and many other Linux distros).
Instructions for zsh
/ bash
users
Assuming you want to put the tool chain in
~/os161-support
, you should run.
installdir=$HOME/os161-support
export PATH=$installdir/tools/bin:$PATH
mkdir -p $installdir/src
Building GNU Binutils for OS/161
The first thing you'll need is GNU Binutils:
cd $installdir/src
curl -O http://www.cs.hmc.edu/courses/2010/spring/cs134/os161/binutils-2.17+os161-2.0.tar.gz
tar xzf binutils-2.17+os161-2.0.tar.gz
cd binutils-2.17+os161-2.0
./configure --nfp --target=mips-harvard-os161 --disable-werror --prefix=$installdir/tools
make MAKEINFO=makeinfo && make MAKEINFO=makeinfo install
cd ..
(When compiling on knuth
and Ubuntu machines, you may
have to use make MAKEINFO=makeinfo
rather than
make
to work around a bug in the Makefile.)
Optionally, you can reclaim space by running
rm -rf binutils-2.17+os161-2.0
rm binutils-2.17+os161-2.0.tar.gz
Building GNU GCC for OS/161
cd $installdir/src
curl -O http://www.cs.hmc.edu/courses/2010/spring/cs134/os161/gcc-4.1.2+os161-2.0.tar.gz
tar xzf gcc-4.1.2+os161-2.0.tar.gz
cd gcc-4.1.2+os161-2.0
./configure --nfp --disable-shared --disable-threads --disable-libmudflap --disable-libssp --target=mips-harvard-os161 --disable-werror --prefix=$installdir/tools
make MAKEINFO=makeinfo && make MAKEINFO=makeinfo install
cd ..
(Again, you may have to use make MAKEINFO=makeinfo
rather than make
.)
Optionally, you can reclaim space by running
rm -rf gcc-4.1.2+os161-2.0
rm gcc-4.1.2+os161-2.0.tar.gz
Building GNU GDB for OS/161
cd $installdir/src
curl -O http://www.cs.hmc.edu/courses/2010/spring/cs134/os161/gdb-6.6+os161-2.0.tar.gz
tar xzf gdb-6.6+os161-2.0.tar.gz
cd gdb-6.6+os161-2.0
./configure --target=mips-harvard-os161 --disable-werror --prefix=$installdir/tools
make MAKEINFO=makeinfo && make MAKEINFO=makeinfo install
cd ..
Optionally, you can reclaim space by running
rm -rf gdb-6.6+os161-2.0
rm gdb-6.6+os161-2.0.tar.gz
Creating Symlinks for the Toolchain
By default, the toolchain is installed with fairly long and ugly
names. We'd like to use shorter, more managable names. Symbolic
links (symlinks) will do that for us:
mkdir $installdir/bin
cd $installdir/bin
ln -s ../tools/bin/mips-harvard-os161-addr2line os161-addr2line
ln -s ../tools/bin/mips-harvard-os161-ar os161-ar
ln -s ../tools/bin/mips-harvard-os161-as os161-as
ln -s ../tools/bin/mips-harvard-os161-c++filt os161-c++filt
ln -s ../tools/bin/mips-harvard-os161-cpp os161-cpp
ln -s ../tools/bin/mips-harvard-os161-gcc os161-gcc
ln -s ../tools/bin/mips-harvard-os161-gcc-4.1.2 os161-gcc-4.1.2
ln -s ../tools/bin/mips-harvard-os161-gccbug os161-gccbug
ln -s ../tools/bin/mips-harvard-os161-gcov os161-gcov
ln -s ../tools/bin/mips-harvard-os161-gdb os161-gdb
ln -s ../tools/bin/mips-harvard-os161-gdbtui os161-gdbtui
ln -s ../tools/bin/mips-harvard-os161-ld os161-ld
ln -s ../tools/bin/mips-harvard-os161-nm os161-nm
ln -s ../tools/bin/mips-harvard-os161-objcopy os161-objcopy
ln -s ../tools/bin/mips-harvard-os161-objdump os161-objdump
ln -s ../tools/bin/mips-harvard-os161-ranlib os161-ranlib
ln -s ../tools/bin/mips-harvard-os161-readelf os161-readelf
ln -s ../tools/bin/mips-harvard-os161-run os161-run
ln -s ../tools/bin/mips-harvard-os161-size os161-size
ln -s ../tools/bin/mips-harvard-os161-strings os161-strings
ln -s ../tools/bin/mips-harvard-os161-strip os161-strip
cd -
Building System/161
The work you did above provided you with versions of
gcc
, gdb
, and other tools that can
cross-compile (and cross-debug) code for a MIPS processor. Now we
need System/161, which is a MIPS emulator that will run on your
machine:
cd $installdir/src
curl -O http://www.cs.hmc.edu/twiki/bin/view/CS134Spring2010/sys161-1.99.04.tar.gz
tar xzf sys161-1.99.04.tar.gz
cd sys161-1.99.04
./configure --prefix=$installdir mipseb
make && make install
cd ..
Optionally, you can reclaim space by running
rm -rf sys161-1.99.04
rm sys161-1.99.04.tar.gz
You're Done!
Run
echo Make sure that $installdir/bin is on your path
(and edit your .bashrc
, .zshrc
, .login
, or whatever, to make it so)
But I Run Windows!
If you feel very brave, you can try to install System/161 and its
toolchain under Cygwin, the Unix emulator that runs under Windows.
The old CS134 Wiki has
obsolete
instructions on the old Wiki page that might help you succeed in
that endeavor. But if it doesn't work, I'm not in a good position to
help out.