Difference between revisions of "Compiling M5"

From gem5
Jump to: navigation, search
(Required Software)
(Possible Targets)
Line 15: Line 15:
  
 
=== Possible Targets ===
 
=== Possible Targets ===
M5 can build many binaries each for a different guest architecture, simulation mode, and use. The currently available architectures are: '''ALPHA''', '''SPARC''', and '''MIPS''', which are self explanatory.  
+
M5 can build many binaries each for a different guest architecture, simulation mode, and use. The currently available architectures are '''ALPHA''', '''SPARC''', and '''MIPS'''.  
  
 
Each of these can built in two simulation modes:  
 
Each of these can built in two simulation modes:  
*'''FS''' - Full System mode. In this mode a complete system is simulated including a kernel, I/O devices, etc. It currently only works with the '''ALPHA''' architecture.
+
*'''FS''' - Full System mode. This mode simulates a complete system including a kernel, I/O devices, etc. This mode currently only works with the '''ALPHA''' architecture.
*'''SE''' - Syscall Emulation mode. This mode simulates statically compiled binaries by functionally emulating any syscall they make. .  
+
*'''SE''' - Syscall Emulation mode. This mode simulates statically compiled binaries by functionally emulating any syscall they make.
  
 
Possible Binaries
 
Possible Binaries
Line 25: Line 25:
 
*'''m5.opt'''  - A binary with debugging and optimization. This binary executes much faster than the debug binary and still provides all the debugging facility of the debug version. However when debugging source code it can be more difficult to use that the debug target. (-g -O3)
 
*'''m5.opt'''  - A binary with debugging and optimization. This binary executes much faster than the debug binary and still provides all the debugging facility of the debug version. However when debugging source code it can be more difficult to use that the debug target. (-g -O3)
 
*'''m5.prof''' - This binary is like the opt target, however it also includes profiling support suitable for use with gprof. (-O3 -g -pg).
 
*'''m5.prof''' - This binary is like the opt target, however it also includes profiling support suitable for use with gprof. (-O3 -g -pg).
*'''m5.fast''' - This binary is the fastest binary and all debugging support is removed from the binary (trace flags for example).  (-O3 -DNDEBUG)
+
*'''m5.fast''' - This binary is the fastest binary and all debugging support is removed from the binary (including trace support).  (-O3 -DNDEBUG)
  
 
=== Source Tree ===
 
=== Source Tree ===

Revision as of 22:08, 17 June 2006

M5 runs on Linux, Mac OS X 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.


Required Software

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 to download SCons. If you do not have administrator privileges on the machine you are trying to compile on, you can use the "scons-local" package to install scons in your m5 directory, or install SCons in your home directory using the '--prefix=' option.

There a few utility scripts written in Perl, but Perl is not necessary to build or run the simulator.

Possible Targets

M5 can build many binaries each for a different guest architecture, simulation mode, and use. The currently available architectures are ALPHA, SPARC, and MIPS.

Each of these can built in two simulation modes:

  • FS - Full System mode. This mode simulates a complete system including a kernel, I/O devices, etc. This mode currently only works with the ALPHA architecture.
  • SE - Syscall Emulation mode. This mode simulates statically compiled binaries by functionally emulating any syscall they make.

Possible Binaries

  • m5.debug - A binary used for debugging without any optimizations. Since no optimizations are done this binary is compiled the fastest, however since no optimizations are done it executes very slowly. (-g3 -gdwarf-2 -O0).
  • m5.opt - A binary with debugging and optimization. This binary executes much faster than the debug binary and still provides all the debugging facility of the debug version. However when debugging source code it can be more difficult to use that the debug target. (-g -O3)
  • m5.prof - This binary is like the opt target, however it also includes profiling support suitable for use with gprof. (-O3 -g -pg).
  • m5.fast - This binary is the fastest binary and all debugging support is removed from the binary (including trace support). (-O3 -DNDEBUG)

Source Tree

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

  • configs - This directory contains sample script files that can be used to run M5 and as a starting place for your own configurations.
  • docs - This directory has the doxygen output in it and any other interesting bits documentation we have
  • ext - This directory contains external packages used by M5 that are not commonly installed on systems.
  • src - The source for the simulation itself
    • arch - Architecture specific files as well as the ISA parsing code
      • alpha' - Files specific to the Alpha architecture
        • freebsd - Files specific to the Alpha architecture and to the FreeBSD operating system
        • isa - ISA description files for the Alpha architecture
        • linux - Files specific to the Alpha architecture and to the Linux operating system
        • tru64 - Files specific to the Alpha architecture and to the Tru64 operating system
      • mips - Files specific to the MIPS architecture
        • isa - ISA description files for the MIPS architecture
        • linux - Files specific to the MIPS
      • sparc - Files specific to the SPARC architecture
        • isa - ISA description files for the SPARC architecture
        • linux - Files specific to the SPARC architecture and to the Linux operating system
        • solaris - Files specific to the SPARC architecture and to the Linux operating system
    • base - General data structures and facilities that could be useful for another project
      • loader - Code for loading binaries and reading symbol tables
      • stats - Code for keeping statistics and writing the data to a file or a database
    • cpu - CPU models for the simulator
    • dev - I/O device models for the simulator
    • encumbered - Code that has a different license than M5s,.
    • kern - Operating system but architecture independent code (e.g. types of data structures).
      • linux - Linux specific architecture independent code
      • solaris -Solaris specific architecture independent code
      • tru64 - Tru64 specific architecture independent code
    • mem - Models for the memory system
    • python - Python code for configuration and higher level functions
    • sim - Simulator specific base functionality
  • system - This directory contains platform dependent code such as BIOS, hypervisor, that someone using M5 may want to modify.
    • alpha - Alpha console and palcode
    • mips - none yet
    • sparc - none yet
  • util - This directory has random programs that are used in conjunction with M5 such as Python scripts to process data in an DB, submit jobs to a batch processing system, etc.

Compiling

Starting in the root of this tree, you can build M5 and test your build using the following commands. Where the items between <> are the architectures, types and targets listed above.

% 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 complied M5!

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_FS/m5.debug. You can build other binaries by specifying them on the scons command line, e.g. 'scons build/ALPHA_SE/m5.opt' or 'scons build/ALPHA_FS/m5.debug'.