Compiling M5

From gem5
Revision as of 20:27, 31 May 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. Because M5 simulates little-endian Alpha processors, the host it runs on must be little-endian as well (e.g., x86). The current release includes experimental support for big-endian hosts (e.g., PowerPC), but this has not been extensively tested. To build M5, you will need the following software:


SCons is a powerful replacement for make. See here 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).

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'.