scons: Make the perf and prof builds into options.
That makes it possible to add profiling options to debug or opt builds, and not just the fast build which the perf/prof builds were implicitly modeled after. Change-Id: Id8502825146b01b4869e18d1239e32ebe3303d87 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/51988 Maintainer: Gabe Black <gabe.black@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
This commit is contained in:
12
SConstruct
12
SConstruct
@@ -125,6 +125,10 @@ AddOption('--with-systemc-tests', action='store_true',
|
||||
help='Build systemc tests')
|
||||
AddOption('--install-hooks', action='store_true',
|
||||
help='Install revision control hooks non-interactively')
|
||||
AddOption('--gprof', action='store_true',
|
||||
help='Enable support for the gprof profiler')
|
||||
AddOption('--pprof', action='store_true',
|
||||
help='Enable support for the pprof profiler')
|
||||
|
||||
# Inject the built_tools directory into the python path.
|
||||
sys.path[1:1] = [ Dir('#build_tools').abspath ]
|
||||
@@ -539,6 +543,14 @@ gem5py_env = main.Clone()
|
||||
gem5py_env.Append(CCFLAGS=['${GEM5PY_CCFLAGS_EXTRA}'])
|
||||
gem5py_env.Append(LINKFLAGS=['${GEM5PY_LINKFLAGS_EXTRA}'])
|
||||
|
||||
if GetOption('gprof') and GetOption('pprof'):
|
||||
error('Only one type of profiling should be enabled at a time')
|
||||
if GetOption('gprof'):
|
||||
main.Append(CCFLAGS=['-g', '-pg'], LINKFLAGS=['-pg'])
|
||||
if GetOption('pprof'):
|
||||
main.Append(CCFLAGS=['-g'],
|
||||
LINKFLAGS=['-Wl,--no-as-needed', '-lprofiler', '-Wl,--as-needed'])
|
||||
|
||||
main['HAVE_PKG_CONFIG'] = main.Detect('pkg-config')
|
||||
|
||||
with gem5_scons.Configure(main) as conf:
|
||||
|
||||
@@ -823,17 +823,11 @@ envs = {
|
||||
'debug': env.Clone(ENV_LABEL='debug', OBJSUFFIX='.do'),
|
||||
'opt': env.Clone(ENV_LABEL='opt', OBJSUFFIX='.o'),
|
||||
'fast': env.Clone(ENV_LABEL='fast', OBJSUFFIX='.fo'),
|
||||
'prof': env.Clone(ENV_LABEL='prof', OBJSUFFIX='.po'),
|
||||
'perf': env.Clone(ENV_LABEL='perf', OBJSUFFIX='.gpo')
|
||||
}
|
||||
|
||||
envs['debug'].Append(CPPDEFINES=['DEBUG', 'TRACING_ON=1'])
|
||||
envs['opt'].Append(CCFLAGS=['-g'], CPPDEFINES=['TRACING_ON=1'])
|
||||
envs['fast'].Append(CPPDEFINES=['NDEBUG', 'TRACING_ON=0'])
|
||||
envs['prof'].Append(CCFLAGS=['-g', '-pg'], LINKFLAGS=['-pg'],
|
||||
CPPDEFINES=['NDEBUG', 'TRACING_ON=0'])
|
||||
envs['perf'].Append(CCFLAGS=['-g'], CPPDEFINES=['NDEBUG', 'TRACING_ON=0'],
|
||||
LINKFLAGS=['-Wl,--no-as-needed', '-lprofiler', '-Wl,--as-needed'])
|
||||
|
||||
# For Link Time Optimization, the optimisation flags used to compile
|
||||
# individual files are decoupled from those used at link time
|
||||
@@ -845,17 +839,16 @@ if env['GCC']:
|
||||
else:
|
||||
envs['debug'].Append(CCFLAGS=['-ggdb3'])
|
||||
envs['debug'].Append(LINKFLAGS=['-O0'])
|
||||
# opt, fast, prof and perf all share the same cc flags, also add
|
||||
# the optimization to the linkflags as LTO defers the optimization
|
||||
# to link time
|
||||
for target in ['opt', 'fast', 'prof', 'perf']:
|
||||
# opt and fast share the same cc flags, also add the optimization to the
|
||||
# linkflags as LTO defers the optimization to link time
|
||||
for target in ['opt', 'fast']:
|
||||
envs[target].Append(CCFLAGS=['-O3', '${LTO_CCFLAGS}'])
|
||||
envs[target].Append(LINKFLAGS=['-O3', '${LTO_LINKFLAGS}'])
|
||||
|
||||
elif env['CLANG']:
|
||||
envs['debug'].Append(CCFLAGS=['-g', '-O0'])
|
||||
# opt, fast, prof and perf all share the same cc flags
|
||||
for target in ['opt', 'fast', 'prof', 'perf']:
|
||||
# opt and fast share the same cc flags
|
||||
for target in ['opt', 'fast']:
|
||||
envs[target].Append(CCFLAGS=['-O3'])
|
||||
else:
|
||||
error('Unknown compiler, please fix compiler options')
|
||||
|
||||
Reference in New Issue
Block a user