Cross-Compiling User Programs on Instructional HP's, Solaris, and x86's

Follow these instructions to be able to compile user programs on HP's and Solaris x86's:
  1. Go to the nachos/test directory in your own copy of nachos.

  2. cd ~/nachos/test
  3. Copy the new Makefile to your test directory.

  4. cp ~cs162/nachos/test/Makefile .
  5. Then do the same to get the new Makefile for the bin directory.

  6. cd ../bin/
    cp ~cs162/nachos/bin/Makefile .
Now, you should be able to go into the your nachos/test directory, and type "gmake" to compile the sample user programs. Be sure to delete any old object files or programs that are in that directory before you recompile. Note, you do not need to run "gmake depend" to compile the user programs.

Remember, this will only work on the instructional HP's and Solaris x86's. We believe that's what the majority of you use to do your projects. If there are other types of instructional machines that you use, post to the newsgroup, and we'll see what we can do.

If you follow these directions, you will be able to compile all your nachos and user program code on the instructional machines, without the need of a MIPS machine. If you have trouble doing this, post to the course newsgroup.

For the advanced reader

If you really want to know how we were able to get the HP's and Solaris machines to compile to the MIPS architecture, we'll quickly explain it here. Basically, we created "cross-compilers" using the GNU tools. "Cross-compilers" are compilers that generate code for a different machine architecture other than the one running the compiler. In this case, our cross-compiler is compiling code to the MIPS eventhough it is running on a HP or Solaris x86 machine.

If you look closely, you can see where we have put the cross-compilers we created. Basically, they are in the master cs162 account's binary directory. The name of the executables are mips-gcc (the regular old gcc), the mips-as (the assembler), mips-ld (the linker), and mips-cpp (the preprocessor).

Creating cross-compilers on your own

If we get time, we might put up some more full directions on how to get the cross-compilers working on other systems (such as Linux machines). But, if you want to play with it on your own, here are some vague instructions:
  1. Get binutil-2.9.1 and gcc-2.8.1 from ftp://ftp.gnu.org
  2. Configure binutil-2.9.1 with the following line:

  3. ./configure --target=mips-dec-ultrix42
  4. Then do a "gmake" in the binutils. This should produce a "as-new" and "ld-new" in the gas and ld directories respectively. Grab those and name them "mips-as" and "mips-ld".
  5. Configure gcc-2.8.1 with the following command:

  6. ./configure --target=mips-dec-ultrix42 --program-prefix=mips- --with-gnu-as --with-gnu-ld
  7. The do a "gmake" in gcc. It will barf at some point when it tries to create the libgcc.a library, but that's ok, we don't need the libraries. You should have "xgcc" and "cpp". Grab those and name them "mips-gcc" and "mips-cpp". Also copy "cc1" and "cc1plus" into the same directory you put the above binaries.
  8. Now you should have all the tools you need. Set the "$ARCHDIR" variable to point to the directory where you put those binaries. (You can do that in test's Makefile).
  9. Remember to compile the "coff2noff" translation program in the bin directory. You might have to manually set the HOST_IS_BIG_ENDIAN flag yourself to get it to work right for your machine.
Ok, those directions are vague, and are not guaranteed to work. Try them at your own risk. We don't really want to try to support the linux or windows machines at this point, so you're on your own for now. But, maybe in the next couple of weeks we will put out better instructions.
CS162, cs162@cory, http://www-inst.eecs/~cs162/.