scons: Fix linker flags for prof/perf builds.

SCons does not use a variable called LDFLAGS, it uses one called
LINKFLAGS. Switch some errant uses to the correct name.

Also, adjust all the other variable names to use LINK, for consistency
and to avoid confusion and avoid mistakes in the future.

Change-Id: I38d40f5231afdf62bcfba04478d403d65e9b1e26
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/51987
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Gabe Black
2021-10-24 23:30:58 -07:00
parent 45cfd99ce9
commit e1de4abdb0
2 changed files with 12 additions and 12 deletions

View File

@@ -248,8 +248,8 @@ global_vars.AddVariables(
('CXX', 'C++ compiler', environ.get('CXX', main['CXX'])),
('CCFLAGS_EXTRA', 'Extra C and C++ compiler flags', ''),
('GEM5PY_CCFLAGS_EXTRA', 'Extra C and C++ gem5py compiler flags', ''),
('GEM5PY_LDFLAGS_EXTRA', 'Extra marshal gem5py flags', ''),
('LDFLAGS_EXTRA', 'Extra linker flags', ''),
('GEM5PY_LINKFLAGS_EXTRA', 'Extra marshal gem5py flags', ''),
('LINKFLAGS_EXTRA', 'Extra linker flags', ''),
('PYTHON_CONFIG', 'Python config binary to use',
[ 'python3-config', 'python-config']
),
@@ -304,7 +304,7 @@ main.Prepend(CPPPATH=Dir('include'))
# Initialize the Link-Time Optimization (LTO) flags
main['LTO_CCFLAGS'] = []
main['LTO_LDFLAGS'] = []
main['LTO_LINKFLAGS'] = []
# According to the readme, tcmalloc works best if the compiler doesn't
# assume that we're using the builtin malloc and friends. These flags
@@ -386,7 +386,7 @@ if main['GCC']:
warning('"make" not found, link time optimization will be '
'single threaded.')
for var in 'LTO_CCFLAGS', 'LTO_LDFLAGS':
for var in 'LTO_CCFLAGS', 'LTO_LINKFLAGS':
# Use the same amount of jobs for LTO as we are running scons with.
main[var] = ['-flto%s' % parallelism]
@@ -400,7 +400,7 @@ elif main['CLANG']:
# Set the Link-Time Optimization (LTO) flags if enabled.
if GetOption('with_lto'):
for var in 'LTO_CCFLAGS', 'LTO_LDFLAGS':
for var in 'LTO_CCFLAGS', 'LTO_LINKFLAGS':
main[var] = ['-flto']
# clang has a few additional warnings that we disable.
@@ -537,7 +537,7 @@ gem5py_env = main.Clone()
# Bare minimum environment that only includes python
gem5py_env.Append(CCFLAGS=['${GEM5PY_CCFLAGS_EXTRA}'])
gem5py_env.Append(LINKFLAGS=['${GEM5PY_LDFLAGS_EXTRA}'])
gem5py_env.Append(LINKFLAGS=['${GEM5PY_LINKFLAGS_EXTRA}'])
main['HAVE_PKG_CONFIG'] = main.Detect('pkg-config')
@@ -709,7 +709,7 @@ Build variables for {dir}:
sticky_vars.Save(current_vars_file, env)
env.Append(CCFLAGS='$CCFLAGS_EXTRA')
env.Append(LINKFLAGS='$LDFLAGS_EXTRA')
env.Append(LINKFLAGS='$LINKFLAGS_EXTRA')
exports=['env', 'gem5py_env']

View File

@@ -830,10 +830,10 @@ envs = {
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'], LDFLAGS=['-pg'],
envs['prof'].Append(CCFLAGS=['-g', '-pg'], LINKFLAGS=['-pg'],
CPPDEFINES=['NDEBUG', 'TRACING_ON=0'])
envs['perf'].Append(CCFLAGS=['-g'], CPPDEFINES=['NDEBUG', 'TRACING_ON=0'],
LDFLAGS=['-Wl,--no-as-needed', '-lprofiler', '-Wl,--as-needed'])
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
@@ -844,13 +844,13 @@ if env['GCC']:
envs['debug'].Append(CCFLAGS=['-gstabs+'])
else:
envs['debug'].Append(CCFLAGS=['-ggdb3'])
envs['debug'].Append(LDFLAGS=['-O0'])
envs['debug'].Append(LINKFLAGS=['-O0'])
# opt, fast, prof and perf all share the same cc flags, also add
# the optimization to the ldflags as LTO defers the optimization
# the optimization to the linkflags as LTO defers the optimization
# to link time
for target in ['opt', 'fast', 'prof', 'perf']:
envs[target].Append(CCFLAGS=['-O3', '${LTO_CCFLAGS}'])
envs[target].Append(LDFLAGS=['-O3', '${LTO_LDFLAGS}'])
envs[target].Append(LINKFLAGS=['-O3', '${LTO_LINKFLAGS}'])
elif env['CLANG']:
envs['debug'].Append(CCFLAGS=['-g', '-O0'])