diff options
author | Andreas Hansson <andreas.hansson@arm.com> | 2012-09-14 12:13:21 -0400 |
---|---|---|
committer | Andreas Hansson <andreas.hansson@arm.com> | 2012-09-14 12:13:21 -0400 |
commit | a57eda0843b886526e0fdd8364373ac49457d20c (patch) | |
tree | cabec39d3a6dad185ea17400d1dc2ef9a81db8ec /src/SConscript | |
parent | 224ea5fba659213a6cc9083a63cee1f6d98e8829 (diff) | |
download | gem5-a57eda0843b886526e0fdd8364373ac49457d20c.tar.xz |
scons: Add a target for google-perftools profiling
This patch adds a new target called 'perf' that facilitates profiling
using google perftools rather than gprof. The perftools CPU profiler
offers plenty useful information in addition to gprof, and the latter
is kept mostly to offer profiling also on non-Linux hosts.
Diffstat (limited to 'src/SConscript')
-rwxr-xr-x | src/SConscript | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/src/SConscript b/src/SConscript index e59e424c3..3e7c4c9e9 100755 --- a/src/SConscript +++ b/src/SConscript @@ -933,10 +933,15 @@ def makeEnv(label, objsfx, strip = False, **kwargs): # Start out with the compiler flags common to all compilers, # i.e. they all use -g for opt and -g -pg for prof -ccflags = {'debug' : [], 'opt' : ['-g'], 'fast' : [], 'prof' : ['-g', '-pg']} +ccflags = {'debug' : [], 'opt' : ['-g'], 'fast' : [], 'prof' : ['-g', '-pg'], + 'perf' : ['-g']} -# Start out with the linker flags common to all linkers, i.e. -pg for prof. -ldflags = {'debug' : [], 'opt' : [], 'fast' : [], 'prof' : ['-pg']} +# Start out with the linker flags common to all linkers, i.e. -pg for +# prof, and -lprofiler for perf. The -lprofile flag is surrounded by +# no-as-needed and as-needed as the binutils linker is too clever and +# simply doesn't link to the library otherwise. +ldflags = {'debug' : [], 'opt' : [], 'fast' : [], 'prof' : ['-pg'], + 'perf' : ['-Wl,--no-as-needed', '-lprofiler', '-Wl,--as-needed']} if env['GCC']: if sys.platform == 'sunos5': @@ -944,24 +949,24 @@ if env['GCC']: else: ccflags['debug'] += ['-ggdb3'] ldflags['debug'] += ['-O0'] - # opt, fast and prof all share the same cc flags - for target in ['opt', 'fast', 'prof']: + # opt, fast, prof and perf all share the same cc flags + for target in ['opt', 'fast', 'prof', 'perf']: ccflags[target] += ['-O3'] elif env['SUNCC']: ccflags['debug'] += ['-g0'] ccflags['opt'] += ['-O'] - ccflags['fast'] += ['-fast'] - ccflags['prof'] += ['-fast'] + for target in ['fast', 'prof', 'perf']: + ccflags[target] += ['-fast'] elif env['ICC']: ccflags['debug'] += ['-g', '-O0'] ccflags['opt'] += ['-O'] - ccflags['fast'] += ['-fast'] - ccflags['prof'] += ['-fast'] + for target in ['fast', 'prof', 'perf']: + ccflags[target] += ['-fast'] elif env['CLANG']: ccflags['debug'] += ['-g', '-O0'] - ccflags['opt'] += ['-O3'] - ccflags['fast'] += ['-O3'] - ccflags['prof'] += ['-O3'] + # opt, fast, prof and perf all share the same cc flags + for target in ['opt', 'fast', 'prof', 'perf']: + ccflags[target] += ['-O3'] else: print 'Unknown compiler, please fix compiler options' Exit(1) @@ -971,8 +976,9 @@ else: # need. We try to identify the needed environment for each target; if # we can't, we fall back on instantiating all the environments just to # be safe. -target_types = ['debug', 'opt', 'fast', 'prof'] -obj2target = {'do': 'debug', 'o': 'opt', 'fo': 'fast', 'po': 'prof'} +target_types = ['debug', 'opt', 'fast', 'prof', 'perf'] +obj2target = {'do': 'debug', 'o': 'opt', 'fo': 'fast', 'po': 'prof', + 'gpo' : 'perf'} def identifyTarget(t): ext = t.split('.')[-1] @@ -1010,11 +1016,18 @@ if 'fast' in needed_envs: CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], LINKFLAGS = Split(ldflags['fast'])) -# Profiled binary +# Profiled binary using gprof if 'prof' in needed_envs: makeEnv('prof', '.po', CCFLAGS = Split(ccflags['prof']), CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], LINKFLAGS = Split(ldflags['prof'])) +# Profiled binary using google-pprof +if 'perf' in needed_envs: + makeEnv('perf', '.gpo', + CCFLAGS = Split(ccflags['perf']), + CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'], + LINKFLAGS = Split(ldflags['perf'])) + Return('envList') |