OS/161 Toolchain Setup

about OS/161 | about System/161 | project news | publications | license | credits
download | guides and resources | documentation | for instructors | bugs | mailing lists

To build yourself an OS/161 toolchain, and generally get ready to work on OS/161, you need to do the following. Note that if you're taking a course and your course provides the toolchain installed somewhere for you, you don't need to do any of this. (Unless you're the lucky guy on the course staff who gets to set it up.)

Toolchain components

There are five parts to the toolchain:

In general you will need to build and install all of these, even if you already have a compiler; the versions we'll be building and using with OS/161 are configured for cross-compiling to MIPS.

However, if you already have BSD make (it is the system make on most BSD-based operating systems, and comes with the pkgsrc package system often also used on MacOS and Solaris) you don't need to install another copy.

Note that you might be able to use a different compiler, such as clang, as long as it has been configured as a MIPS cross-compiler. This has not been tested, however, and you're on your own. (If you try, please report success or failure...)

Preliminaries

Prerequisites

There are some prerequisite packages for building the toolchain. You will need the following:

The best bet is to install these items (if you don't already have them) with your system's package manager. In most package systems where you don't already start out with a compiler, there's an umbrella package to install the things you need to compile; the best bet is to start off by installing this.

If you are using Linux, your system make (what you get if you just type make) is most likely GNU make.

For library packages, like gmp, mpfr, and mpc, be sure to install the "development" packages as well, if they're separate.

If you're using pkgsrc (e.g. on BSD, MacOS, or Solaris) the mpc package is called "mpcomplex". There's something else called mpc; installing it instead by accident won't help much.

If you cannot get a gmake package and need to compile it, you can download it from ftp.gnu.org. This is also true of gmp, mpfr, and mpc.

Installing binutils

You must install binutils first; gcc will not build properly without it.

Installing gcc 4.8

If your system make is GNU make (e.g. on Linux) you can just type 'make' instead of 'gmake' at the appropriate points.

If you or your package system has installed gmp, mpfr and/or mpc into a directory that the compiler doesn't find by default (such as /usr/pkg or /opt, pass one or more of these extra arguments to configure to help it find them, obviously substituting the right path prefix:

	--with-gmp=/usr/pkg
	--with-mpfr=/usr/pkg
	--with-mpc=/usr/pkg
On some platforms you may also need to stick the library path in the LDFLAGS environment variable before running configure:
   LDFLAGS=-R/usr/pkg/lib
   export LDFLAGS
or
   setenv LDFLAGS -R/usr/pkg/lib

I also had trouble with gcc's Chinese translation files failing to build; if you hit this, you can work around it by adding --without-nls to the configure arguments.

I've had a report that gcc 4.8 doesn't build on the latest Ubuntu (16.10) but I haven't had a chance to investigate.

Installing gcc 4.1

(Only install gcc 4.1 if you aren't installing gcc 4.8.)

If your system make is GNU make (e.g. on Linux) you can just type 'make' instead of 'gmake' at the appropriate points.

Installing gdb

Installing System/161

If you are using pkgsrc for packages (e.g. on BSD, MacOS, or Solaris) you can install the sys161 package (it is in emulators/sys161) to get System/161.

Installing bmake

If you already have bmake, you don't need another copy. You may have an adequate bmake if:

There is something floating around the Linux world called "pmake" that's an extremely old BSD make. It is known not to work. (If your distribution ships this, encourage them to get rid of it and ship bmake instead.)

You should be able to use any version of bmake shipped within the last ten or more years. However, be advised that the (dysfunctional) build procedure of the standalone bmake distribution changes periodically. The directions here work with the 2010 version posted in the download area but probably not with other arbitrarily chosen versions.

Finishing up

Because the tools installed under long GNU names (e.g. mips-harvard-os161-gcc) you probably want to create shorter names like os161-gcc. Do the following to make a family of symbolic links:

   cd ~/os161/tools
   sh -c 'for i in mips-*; do ln -s $i os161-`echo $i | cut -d- -f4-`; done'

Now, type rehash or log in again, and you should be ready to go.

If you have a multiprocessor/multicore machine, you can do parallel makes with bmake. Use the option -j N, where N is the maximum number of jobs to run at once. Twice the number of cores you have seems to be a good number nowadays.