Compiling M5

From gem5
Revision as of 18:30, 16 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:

src 
contains the sources for the simulator itself.
ext 
contains external packages used by M5.
configs 
sample script files to run M5
docs 
documentation on M5
util 
random programs that are used in conjunction with M5
system 
platform dependent code such as BIOS, hypervisor, etc.


There are multiple architectures, modes and binaries that M5 can build.

  • Architectures
    ALPHA 
    Alpha ISA
    SPARC 
    SPARC ISA
    MIPS 
    MIPS ISA
  • Types
    FS 
    A binary for full system simulation. This currently only works with the ALPHA target.
    SE 
    A binary for syscall emulation.
  • Target
    debug 
    A binary with no optimization and all debugging features
    opt 
    A binary with optimization and all debugging features
    fast 
    A binary with optimization and no debugging features
    prof 
    A binary with optimization that generates profile output suitable to use with gprof

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

% cd m5
% scons build/<arch>_<type>/m5.<target>

scons: Reading SConscript files ...
Checking for C header file fenv.h... yes
Building in /tmp/newmem/build/ALPHA_FS
Options file /tmp/newmem/build/options/ALPHA_FS not found,
  using defaults in build_opts/ALPHA_FS
Compiling in ALPHA_FS with MySQL support.
scons: done reading SConscript files.
scons: Building targets ...
g++ -o build/ALPHA_FS/base/circlebuf.do -c -pipe -fno-strict-aliasing
    -Wall -Wno-sign-compare -Werror -Wundef -g3 -gdwarf-2 -O0
    -DTHE_ISA=ALPHA_ISA -DDEBUG -Iext/dnet -I/usr/include/python2.4
    -Ibuild/libelf/include -I/usr/include/mysql -Ibuild/ALPHA_FS
    build/ALPHA_FS/base/circlebuf.cc
...

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