cmake: gem5-related build system updates
The build system now allows incremental gem5 builds. Unfortunately, the current solution always requires re-linking the executable. Without the enforcement of re-linking, the fail code will be rebuilt but not linked into gem5. The number of cores for building gem5 is derived from /proc/cpuinfo. As before, only the gem5.debug configuration is supported. Change-Id: Ib13b15d1ecd62196eb251e0fd00953f4eb052feb
This commit is contained in:
1181
cmake/ExternalProjectGem5Specific.cmake
Normal file
1181
cmake/ExternalProjectGem5Specific.cmake
Normal file
File diff suppressed because it is too large
Load Diff
@ -6,13 +6,29 @@ if(BUILD_GEM5)
|
|||||||
set(gem5_src_dir ${PROJECT_SOURCE_DIR}/simulators/gem5)
|
set(gem5_src_dir ${PROJECT_SOURCE_DIR}/simulators/gem5)
|
||||||
set(gem5_wrapper ${PROJECT_SOURCE_DIR}/src/core/sal/gem5)
|
set(gem5_wrapper ${PROJECT_SOURCE_DIR}/src/core/sal/gem5)
|
||||||
set(gem5_build_config build/ARM/gem5.debug)
|
set(gem5_build_config build/ARM/gem5.debug)
|
||||||
set(core_count 9)
|
## Determine the number of cores:
|
||||||
|
set(core_count 0) # unknown
|
||||||
|
# Linux:
|
||||||
|
set(cpuinfo_file "/proc/cpuinfo")
|
||||||
|
if(EXISTS "${cpuinfo_file}")
|
||||||
|
file(STRINGS "${cpuinfo_file}" procs REGEX "^processor.: [0-9]+$")
|
||||||
|
list(LENGTH procs core_count)
|
||||||
|
endif()
|
||||||
|
# Mac:
|
||||||
|
if(APPLE)
|
||||||
|
find_program(cmd_sys_pro "system_profiler")
|
||||||
|
if(cmd_sys_pro)
|
||||||
|
execute_process(COMMAND ${cmd_sys_pro} OUTPUT_VARIABLE info)
|
||||||
|
string(REGEX REPLACE "^.*Total Number Of Cores: ([0-9]+).*$" "\\1"
|
||||||
|
core_count "${info}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
MATH(EXPR VAR "${core_count}+1") # CPU++
|
||||||
|
MESSAGE(STATUS "Using ${core_count} core(s) for compiling with scons ...")
|
||||||
|
|
||||||
# FIXMEs:
|
# FIXMEs:
|
||||||
# - incremental builds working?
|
# - ${core_count} should be derived from the parent make -jX parameter
|
||||||
# - dependency for modified .cc files not correctly checked
|
# - make ${gem5_build_config} configurable in CMake
|
||||||
# - core_count should be derived from the parent make -jX parameter
|
|
||||||
# - make gem5_build_config configurable in CMake
|
|
||||||
# (alternative: gem5_build_config is set based on the CMake build
|
# (alternative: gem5_build_config is set based on the CMake build
|
||||||
# config, e.g., "Debug" or "Release")
|
# config, e.g., "Debug" or "Release")
|
||||||
# - Ideally, there is no additional "gem5-clean" target. Instead,
|
# - Ideally, there is no additional "gem5-clean" target. Instead,
|
||||||
@ -20,29 +36,65 @@ if(BUILD_GEM5)
|
|||||||
# gem5 root dir. This seems easy for "make only" projects--things
|
# gem5 root dir. This seems easy for "make only" projects--things
|
||||||
# get shaky due to "scons".
|
# get shaky due to "scons".
|
||||||
|
|
||||||
# Enable ExternalProject CMake module
|
# Enable ExternalProject CMake module (located in $FAIL/cmake/)
|
||||||
include(ExternalProject)
|
include(ExternalProjectGem5Specific)
|
||||||
|
|
||||||
# Use cmake's external project feature to build gem5 (and link FailGem5)
|
add_custom_target(gem5-force-re-linking
|
||||||
ExternalProject_Add(
|
COMMAND @echo "Removing gem5 binary and CMake build stamp ..."
|
||||||
FailGem5_binary_external # the (unique) name of this custom target (= external project)
|
COMMAND rm "${gem5_src_dir}/${gem5_build_config}" -f
|
||||||
|
COMMAND rm "${PROJECT_BINARY_DIR}/FailGem5_binary_external-prefix/src/FailGem5_binary_external-stamp/FailGem5_binary_external-build" -f
|
||||||
|
)
|
||||||
|
# WARNING: This requires a known (and "fixed") implementation of
|
||||||
|
# ExternalProject_Add() because we enforce re-linking by deleting
|
||||||
|
# some internal CMake time-stamp files generated by the external
|
||||||
|
# project stuff. We therefore provide our own version
|
||||||
|
# ("ExternalProjectGem5Specific") using a different name.
|
||||||
|
|
||||||
|
# Generate gem5 headers using the scons build system (in our custom "dummy" mode):
|
||||||
|
# This effectivly calls the whole gem5 toolchain but replaces the compiler, the
|
||||||
|
# linker, ar and ranlib with usr/bin/true. It allows us to just generate the headers
|
||||||
|
# which, in turn, are required for fail compilation. This target has no dependencies.
|
||||||
|
ExternalProject_Add2_Gem5Specific(
|
||||||
|
FailGem5_generation # the (unique) name of this custom target (= external project)
|
||||||
# Disable update, patch and configure step:
|
# Disable update, patch and configure step:
|
||||||
UPDATE_COMMAND ""
|
UPDATE_COMMAND ""
|
||||||
PATCH_COMMAND ""
|
PATCH_COMMAND ""
|
||||||
CONFIGURE_COMMAND ""
|
CONFIGURE_COMMAND ""
|
||||||
SOURCE_DIR ${gem5_src_dir}
|
SOURCE_DIR ${gem5_src_dir}
|
||||||
BINARY_DIR ${gem5_src_dir}
|
BINARY_DIR ${gem5_src_dir}
|
||||||
|
BUILD_COMMAND scons ${gem5_build_config} --dummy
|
||||||
|
# Disable install step (for now)
|
||||||
|
INSTALL_COMMAND ""
|
||||||
|
)
|
||||||
|
|
||||||
|
# Use cmake's external project feature to build gem5 (and link FailGem5):
|
||||||
|
ExternalProject_Add2_Gem5Specific(
|
||||||
|
FailGem5_binary_external
|
||||||
|
DEPENDS FailGem5_generation
|
||||||
|
# Disable update, patch and configure step:
|
||||||
|
UPDATE_COMMAND ""
|
||||||
|
PATCH_COMMAND ""
|
||||||
|
SOURCE_DIR ${gem5_src_dir}
|
||||||
|
BINARY_DIR ${gem5_src_dir}
|
||||||
|
CONFIGURE_COMMAND ""
|
||||||
# Build gem5 using scons build system:
|
# Build gem5 using scons build system:
|
||||||
BUILD_COMMAND scons "CXX=${CMAKE_CXX_COMPILER} -p ${gem5_src_dir} --Xcompiler" EXTRAS=${gem5_wrapper} ${gem5_build_config} -j${core_count}
|
BUILD_COMMAND scons "CXX=${CMAKE_CXX_COMPILER} -p ${gem5_src_dir} --Xcompiler" EXTRAS=${gem5_wrapper} ${gem5_build_config} -j${core_count}
|
||||||
# Disable install step (for now)
|
# Disable install step (for now)
|
||||||
INSTALL_COMMAND ""
|
INSTALL_COMMAND ""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Cleans up everything (gem5 and Fail related):
|
||||||
add_custom_target(gem5-allclean
|
add_custom_target(gem5-allclean
|
||||||
COMMAND @echo "Cleaning Fail* and gem5 ..."
|
COMMAND @echo "Cleaning Fail* and gem5 ..."
|
||||||
COMMAND cd "${PROJECT_BINARY_DIR}/" && make clean
|
COMMAND cd "${PROJECT_BINARY_DIR}/" && make clean
|
||||||
COMMAND cd "${gem5_src_dir}/" && scons -c build/ARM
|
COMMAND cd "${gem5_src_dir}/" && scons -c build/ARM
|
||||||
|
COMMAND cd "${gem5_src_dir}/" && rm -rf build/
|
||||||
)
|
)
|
||||||
|
|
||||||
# Build "fail" library first (will be statically linked to gem5)
|
# Resolve header dependencies first (i.e., generate the header files):
|
||||||
|
add_dependencies(fail-sal FailGem5_generation)
|
||||||
|
# Always enforce re-linking (bugfix for cmake/scons):
|
||||||
|
add_dependencies(fail gem5-force-re-linking)
|
||||||
|
# Re-build/link gem5 if Fail code has changed:
|
||||||
add_dependencies(FailGem5_binary_external fail)
|
add_dependencies(FailGem5_binary_external fail)
|
||||||
endif(BUILD_GEM5)
|
endif(BUILD_GEM5)
|
||||||
|
|||||||
@ -199,12 +199,7 @@ For the first time (incl. selecting an experiment):
|
|||||||
$ ccmake .
|
$ ccmake .
|
||||||
At least, you should set an experiment and turn on the following
|
At least, you should set an experiment and turn on the following
|
||||||
flags: BUILD_GEM5 = BUILD_ARM = ON. Additionally, all config
|
flags: BUILD_GEM5 = BUILD_ARM = ON. Additionally, all config
|
||||||
options specific for other simulator should be turned OFF. Finally,
|
options specific for other simulator should be turned OFF.
|
||||||
edit ${FAIL_DIR}/src/core/sal/gem5/SConscript: search for a line
|
|
||||||
with "gStaticLibs" and ensure that this line lists all the various
|
|
||||||
target you want to include in the binary (especially your experiment
|
|
||||||
target and perhabs an additional plugin), i.e. change
|
|
||||||
-lfail-arch-test to -lfail-[EXPERIMENTNAME|PLUGINNAME].
|
|
||||||
5. Typing
|
5. Typing
|
||||||
$ make (or nice make -jN)
|
$ make (or nice make -jN)
|
||||||
will start the build process of Fail* and gem5. This automatically
|
will start the build process of Fail* and gem5. This automatically
|
||||||
@ -225,10 +220,8 @@ After changes to Fail*/gem5 code (incl. aspect headers):
|
|||||||
$ make gem5-allclean
|
$ make gem5-allclean
|
||||||
(in your build dir ${FAIL_DIR}/build). This cleans the current
|
(in your build dir ${FAIL_DIR}/build). This cleans the current
|
||||||
Fail* and gem5 build directories. Note that "make clean" only cleans
|
Fail* and gem5 build directories. Note that "make clean" only cleans
|
||||||
the Fail* build directory. Additionally note, that changing the
|
the Fail* build directory. Furthermore, all remaining CMake remnants
|
||||||
specified experiment target requires editing
|
should be deleted:
|
||||||
${FAIL_DIR}/src/core/sal/gem5/SConscript (see above). Furthermore, all
|
|
||||||
remaining CMake remnants should be deleted:
|
|
||||||
$ find -name CMakeCache.txt | xargs rm
|
$ find -name CMakeCache.txt | xargs rm
|
||||||
2. Rebuild by typing
|
2. Rebuild by typing
|
||||||
$ make (or nice make -jN)
|
$ make (or nice make -jN)
|
||||||
|
|||||||
@ -169,6 +169,9 @@ AddLocalOption('--update-ref', dest='update_ref', action='store_true',
|
|||||||
help='Update test reference outputs')
|
help='Update test reference outputs')
|
||||||
AddLocalOption('--verbose', dest='verbose', action='store_true',
|
AddLocalOption('--verbose', dest='verbose', action='store_true',
|
||||||
help='Print full tool command lines')
|
help='Print full tool command lines')
|
||||||
|
# DanceOS-specific:
|
||||||
|
AddLocalOption('--dummy', dest='dummy', action='store_true',
|
||||||
|
help='Only generate files (do not actually compile)')
|
||||||
|
|
||||||
termcap = get_termcap(GetOption('use_colors'))
|
termcap = get_termcap(GetOption('use_colors'))
|
||||||
|
|
||||||
@ -488,9 +491,19 @@ if main['GCC'] + main['SUNCC'] + main['ICC'] + main['CLANG'] > 1:
|
|||||||
print 'Error: How can we have two at the same time?'
|
print 'Error: How can we have two at the same time?'
|
||||||
Exit(1)
|
Exit(1)
|
||||||
|
|
||||||
|
# DanceOS-specific: BEGIN
|
||||||
main['GCC'] = True
|
main['GCC'] = True
|
||||||
main['GCC_VERSION'] = '4.4.5'
|
main['GCC_VERSION'] = '4.4.5'
|
||||||
|
|
||||||
|
if '--dummy' in sys.argv:
|
||||||
|
print 'Info: Compiling in dummy-mode (generate files only)!'
|
||||||
|
# Set the dummy build tools:
|
||||||
|
main['CXX'] = 'true'
|
||||||
|
main['AR'] = 'true'
|
||||||
|
main['RANLIB'] = 'true'
|
||||||
|
main['LINK'] = 'true'
|
||||||
|
# DanceOS-specific: END
|
||||||
|
|
||||||
# Set up default C++ compiler flags
|
# Set up default C++ compiler flags
|
||||||
if main['GCC']:
|
if main['GCC']:
|
||||||
main.Append(CCFLAGS=['-pipe'])
|
main.Append(CCFLAGS=['-pipe'])
|
||||||
@ -499,6 +512,7 @@ if main['GCC']:
|
|||||||
# Read the GCC version to check for versions with bugs
|
# Read the GCC version to check for versions with bugs
|
||||||
# Note CCVERSION doesn't work here because it is run with the CC
|
# Note CCVERSION doesn't work here because it is run with the CC
|
||||||
# before we override it from the command line
|
# before we override it from the command line
|
||||||
|
# DanceOS (commented out):
|
||||||
# gcc_version = readCommand([main['CXX'], '-dumpversion'], exception=False)
|
# gcc_version = readCommand([main['CXX'], '-dumpversion'], exception=False)
|
||||||
# main['GCC_VERSION'] = gcc_version
|
# main['GCC_VERSION'] = gcc_version
|
||||||
# if not compareVersions(gcc_version, '4.4.1') or \
|
# if not compareVersions(gcc_version, '4.4.1') or \
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
#include "Gem5Wrapper.hpp"
|
#include "Gem5Wrapper.hpp"
|
||||||
#include "../Listener.hpp"
|
#include "../Listener.hpp"
|
||||||
#include "base/trace.hh"
|
#include "base/trace.hh"
|
||||||
#include "debug/FailState.hh"
|
|
||||||
#include "sim/root.hh"
|
#include "sim/root.hh"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@ -38,8 +37,6 @@ Gem5Controller::~Gem5Controller()
|
|||||||
|
|
||||||
bool Gem5Controller::save(const std::string &path)
|
bool Gem5Controller::save(const std::string &path)
|
||||||
{
|
{
|
||||||
DPRINTF(FailState, "Saving state to %s.\n", path);
|
|
||||||
|
|
||||||
Serializable::serializeAll(path);
|
Serializable::serializeAll(path);
|
||||||
|
|
||||||
// Test if save was successful
|
// Test if save was successful
|
||||||
|
|||||||
Reference in New Issue
Block a user