Compiling M5

From gem5
Revision as of 16:55, 11 June 2006 by Saidi (talk | contribs)
Jump to: navigation, search

M5 runs on Linux and OpenBSD, but should be easily portable to other Unix-like OSes. Cross-endian support has been mostly added, however this has not been extensively tested. All the syscall emulation (_SE) targets support running regardless of host/target endianess, however at present ALPHA_FS does not fully support big endian machines.

To build M5, you will need the following software:

  • g++ version 3.0 or newer. Once upon a time, M5 built with g++ 2.95, but it probably doesn't anymore.
  • Python, version 2.4 or newer.
  • SCons, version 0.96.91 or newer.
  • SWIG, version 1.3.28 or newer.

SCons is a powerful replacement for make. See here[1], to download SCons, and here for installation instructions. Note that you can install SCons in your home directory using the '--prefix=' option (see here for details) or use SCons Local if you do not have administrator privileges on the machine you are trying to compile on.

The regression tester and a few utility scripts are written in Perl, but Perl is not strictly necessary to build the simulator.

Once you have obtained and unpacked the M5 sources, the root of your of your M5 source tree should have three directories:

  • m5 contains the sources for the simulator itself.
  • ext contains external packages used by M5.
  • m5-test contains the M5 regression tests.

Starting in the root of this tree, you can build M5 and test your build using the following commands.

% cd m5/build
% scons
scons: Reading SConscript files ...
Configuring options for directory 'ALPHA_SE'.
scons: done reading SConscript files.
scons: Building targets ...
[...many many files go by...]
scons: done building targets.
% cd ../../m5-test
% ./do-tests.pl -D -B ALPHA_SE

Starting do-tests.pl.....

scons ALPHA_SE/m5.debug

**** Running test1 on /z/stever/bk/m5-test/../m5/build/ALPHA_SE/m5.debug ****
[...more tests go by...]
finished do-tests successfully!

If your output looked like the above, then congratulations, you've got M5 running! Be advised that the "scons ALPHA_SE/m5.debug" step can take a very long time, so if it looks like it's hanging, it's probably not. If you want to watch the make output go by, try adding a -v to the do-test.pl argument list.

At this point, you may want to go back and build some other versions of the M5 binary. There are three primary configurations:


  • ALPHA_SE - an application-level simulator that uses syscall emulation to execute statically linked Alpha binaries compiled for either Tru64 or Linux.
  • ALPHA_FS - a full-system simulator that models a Tsunami-based Alpha system faithfully enough to boot Linux.
  • ALPHA_FS_TL - a full-system simulator that models a Turbolaser-based Alpha system faithfully enough to boot Compaq Tru64 Unix.


For each configuration, several different flavors of M5 binary can be built. The two primary flavors are:

  • m5.debug - debugging version (g++ -g -O0 -DDEBUG)
  • m5.opt - optimized version (g++ -O5)


Each configuration is built in a separate subdirectory of m5/build. For each configuration, the various flavors of binaries are built in the same directory. The default binary that you built above is ALPHA_SE/m5.debug. You can build other binaries by specifying them on the scons command line, e.g. 'scons ALPHA_SE/m5.opt' or 'scons ALPHA_FS/m5.debug'.