Hanhwi Jang has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/44265 )
Change subject: scons: Rerun configuration tests with "config=force"
......................................................................
scons: Rerun configuration tests with "config=force"
Scons uses cached results for configuration tests, which leads to
compilation issues by the stale result use.
This patch allows users to rerun configuration tests using the
"config=force" option without deleting cache manually.
Change-Id: I61244c1daf963272a4b5a3d0e72101afefa82491
---
M SConstruct
M ext/systemc/SConscript
M src/base/SConsopts
M src/base/stats/SConsopts
M src/cpu/kvm/SConsopts
M src/dev/net/SConsopts
M src/proto/SConsopts
M src/sim/SConsopts
8 files changed, 88 insertions(+), 84 deletions(-)
diff --git a/SConstruct b/SConstruct
index b99ecdb..c5aa384 100755
--- a/SConstruct
+++ b/SConstruct
@@ -291,49 +291,53 @@
# Platform-specific configuration. Note again that we assume that all
# builds under a given build root run on the same host platform.
+# From this point, we use 'penv' instead of 'main' to isolate
+# the platform-specific environment updates.
+# main env. is updated at the end of this section with conf.Finish()
conf = gem5_scons.Configure(main)
+penv = conf.env
-CXX_version = readCommand([main['CXX'], '--version'], exception=False)
+CXX_version = readCommand([penv['CXX'], '--version'], exception=False)
-main['GCC'] = CXX_version and CXX_version.find('g++') >= 0
-main['CLANG'] = CXX_version and CXX_version.find('clang') >= 0
-if main['GCC'] + main['CLANG'] > 1:
+penv['GCC'] = CXX_version and CXX_version.find('g++') >= 0
+penv['CLANG'] = CXX_version and CXX_version.find('clang') >= 0
+if penv['GCC'] + penv['CLANG'] > 1:
error('Two compilers enabled at once?')
# Set up default C++ compiler flags
-if main['GCC'] or main['CLANG']:
+if penv['GCC'] or penv['CLANG']:
# As gcc and clang share many flags, do the common parts here
- main.Append(CCFLAGS=['-pipe'])
- main.Append(CCFLAGS=['-fno-strict-aliasing'])
+ penv.Append(CCFLAGS=['-pipe'])
+ penv.Append(CCFLAGS=['-fno-strict-aliasing'])
# Enable -Wall and -Wextra and then disable the few warnings that
# we consistently violate
- main.Append(CCFLAGS=['-Wall', '-Wundef', '-Wextra',
+ penv.Append(CCFLAGS=['-Wall', '-Wundef', '-Wextra',
'-Wno-sign-compare', '-Wno-unused-parameter'])
# We always compile using C++14
- main.Append(CXXFLAGS=['-std=c++14'])
+ penv.Append(CXXFLAGS=['-std=c++14'])
if sys.platform.startswith('freebsd'):
- main.Append(CCFLAGS=['-I/usr/local/include'])
- main.Append(CXXFLAGS=['-I/usr/local/include'])
+ penv.Append(CCFLAGS=['-I/usr/local/include'])
+ penv.Append(CXXFLAGS=['-I/usr/local/include'])
# On FreeBSD we need libthr.
- main.Append(LIBS=['thr'])
+ penv.Append(LIBS=['thr'])
conf.CheckLinkFlag('-Wl,--as-needed')
if GetOption('gold_linker'):
- main.Append(LINKFLAGS='-fuse-ld=gold')
+ penv.Append(LINKFLAGS='-fuse-ld=gold')
# Treat warnings as errors but white list some warnings that we
# want to allow (e.g., deprecation warnings).
- main.Append(CCFLAGS=['-Werror',
+ penv.Append(CCFLAGS=['-Werror',
'-Wno-error=deprecated-declarations',
'-Wno-error=deprecated',
])
else:
error('\n'.join((
"Don't know what compiler options to use for your compiler.",
- "compiler: " + main['CXX'],
+ "compiler: " + penv['CXX'],
"version: " + CXX_version.replace('\n', '<nl>') if
CXX_version else 'COMMAND NOT FOUND!',
"If you're trying to use a compiler other than GCC",
@@ -344,10 +348,10 @@
"above you will need to ease fix SConstruct and ",
"src/SConscript to support that compiler.")))
-if main['GCC']:
- if compareVersions(main['CXXVERSION'], "5") < 0:
+if penv['GCC']:
+ if compareVersions(penv['CXXVERSION'], "5") < 0:
error('gcc version 5 or newer required.\n'
- 'Installed version:', main['CXXVERSION'])
+ 'Installed version:', penv['CXXVERSION'])
# If not disabled, set the Link-Time Optimization (LTO) flags.
if not GetOption('no_lto'):
@@ -355,7 +359,7 @@
# the environment variable "MAKE", but we currently make no
attempt to
# plumb that variable through.
parallelism = ''
- if main.Detect('make'):
+ if penv.Detect('make'):
parallelism = '=%d' % GetOption('num_jobs')
else:
warning('"make" not found, link time optimization will be '
@@ -363,32 +367,32 @@
for var in 'LTO_CCFLAGS', 'LTO_LDFLAGS':
# Use the same amount of jobs for LTO as we are running scons
with.
- main[var] = ['-flto%s' % parallelism]
+ penv[var] = ['-flto%s' % parallelism]
-
main.Append(TCMALLOC_CCFLAGS=['-fno-builtin-malloc', '-fno-builtin-calloc',
+
penv.Append(TCMALLOC_CCFLAGS=['-fno-builtin-malloc', '-fno-builtin-calloc',
'-fno-builtin-realloc', '-fno-builtin-free'])
-elif main['CLANG']:
- if compareVersions(main['CXXVERSION'], "3.9") < 0:
+elif penv['CLANG']:
+ if compareVersions(penv['CXXVERSION'], "3.9") < 0:
error('clang version 3.9 or newer required.\n'
- 'Installed version:', main['CXXVERSION'])
+ 'Installed version:', penv['CXXVERSION'])
# If not disabled, set the Link-Time Optimization (LTO) flags.
if not GetOption('no_lto'):
for var in 'LTO_CCFLAGS', 'LTO_LDFLAGS':
- main[var] = ['-flto']
+ penv[var] = ['-flto']
# clang has a few additional warnings that we disable.
conf.CheckCxxFlag('-Wno-c99-designator')
conf.CheckCxxFlag('-Wno-defaulted-function-deleted')
- main.Append(TCMALLOC_CCFLAGS=['-fno-builtin'])
+ penv.Append(TCMALLOC_CCFLAGS=['-fno-builtin'])
# On Mac OS X/Darwin we need to also use libc++ (part of XCode) as
# opposed to libstdc++, as the later is dated.
if sys.platform == "darwin":
- main.Append(CXXFLAGS=['-stdlib=libc++'])
- main.Append(LIBS=['c++'])
+ penv.Append(CXXFLAGS=['-stdlib=libc++'])
+ penv.Append(LIBS=['c++'])
# Add sanitizers flags
sanitizers=[]
@@ -400,7 +404,7 @@
sanitizers.append('address')
suppressions_file = Dir('util').File('lsan-suppressions').get_abspath()
suppressions_opt = 'suppressions=%s' % suppressions_file
- main['ENV']['LSAN_OPTIONS'] = ':'.join([suppressions_opt,
+ penv['ENV']['LSAN_OPTIONS'] = ':'.join([suppressions_opt,
'print_suppressions=0'])
print()
warning('To suppress false positive leaks, set the LSAN_OPTIONS '
@@ -410,8 +414,8 @@
print()
if sanitizers:
sanitizers = ','.join(sanitizers)
- if main['GCC'] or main['CLANG']:
- main.Append(CCFLAGS=['-fsanitize=%s' % sanitizers,
+ if penv['GCC'] or penv['CLANG']:
+ penv.Append(CCFLAGS=['-fsanitize=%s' % sanitizers,
'-fno-omit-frame-pointer'],
LINKFLAGS='-fsanitize=%s' % sanitizers)
else:
@@ -420,26 +424,26 @@
# Do this after we save setting back, or else we'll tack on an
# extra 'qdo' every time we run scons.
-if main['BATCH']:
- main['CC'] = main['BATCH_CMD'] + ' ' + main['CC']
- main['CXX'] = main['BATCH_CMD'] + ' ' + main['CXX']
- main['AS'] = main['BATCH_CMD'] + ' ' + main['AS']
- main['AR'] = main['BATCH_CMD'] + ' ' + main['AR']
- main['RANLIB'] = main['BATCH_CMD'] + ' ' + main['RANLIB']
+if penv['BATCH']:
+ penv['CC'] = penv['BATCH_CMD'] + ' ' + penv['CC']
+ penv['CXX'] = penv['BATCH_CMD'] + ' ' + penv['CXX']
+ penv['AS'] = penv['BATCH_CMD'] + ' ' + penv['AS']
+ penv['AR'] = penv['BATCH_CMD'] + ' ' + penv['AR']
+ penv['RANLIB'] = penv['BATCH_CMD'] + ' ' + penv['RANLIB']
if sys.platform == 'cygwin':
# cygwin has some header file issues...
- main.Append(CCFLAGS=["-Wno-uninitialized"])
+ penv.Append(CCFLAGS=["-Wno-uninitialized"])
-main['HAVE_PKG_CONFIG'] = main.Detect('pkg-config')
+penv['HAVE_PKG_CONFIG'] = penv.Detect('pkg-config')
# Cache build files in the supplied directory.
-if main['M5_BUILD_CACHE']:
- print('Using build cache located at', main['M5_BUILD_CACHE'])
- CacheDir(main['M5_BUILD_CACHE'])
+if penv['M5_BUILD_CACHE']:
+ print('Using build cache located at', penv['M5_BUILD_CACHE'])
+ CacheDir(penv['M5_BUILD_CACHE'])
if not GetOption('no_compress_debug'):
if not conf.CheckCxxFlag('-gz'):
@@ -447,8 +451,8 @@
if not conf.CheckLinkFlag('-gz'):
warning("Can't enable executable debug section compression")
-main['USE_PYTHON'] = not GetOption('without_python')
-if main['USE_PYTHON']:
+penv['USE_PYTHON'] = not GetOption('without_python')
+if penv['USE_PYTHON']:
# Find Python include and library directories for embedding the
# interpreter. We rely on python-config to resolve the appropriate
# includes and linker flags. ParseConfig does not seem to understand
@@ -457,10 +461,10 @@
# version of python, see above for instructions on how to invoke
# scons with the appropriate PATH set.
- python_config = main.Detect(main['PYTHON_CONFIG'])
+ python_config = penv.Detect(penv['PYTHON_CONFIG'])
if python_config is None:
error("Can't find a suitable python-config, tried %s" % \
- main['PYTHON_CONFIG'])
+ penv['PYTHON_CONFIG'])
print("Info: Using Python config: %s" % (python_config, ))
@@ -472,7 +476,7 @@
# CPPPATH
py_includes = list(map(
lambda s: s[2:] if s.startswith('-I') else s, py_includes))
- main.Append(CPPPATH=py_includes)
+ penv.Append(CPPPATH=py_includes)
# Read the linker flags and split them into libraries and other link
# flags. The libraries are added later through the call the CheckLib.
@@ -494,7 +498,7 @@
py_libs = []
for lib in py_ld_flags:
if not lib.startswith('-l'):
- main.Append(LINKFLAGS=[lib])
+ penv.Append(LINKFLAGS=[lib])
else:
lib = lib[2:]
if lib not in py_libs:
@@ -509,15 +513,15 @@
"package python-dev on Ubuntu and RedHat)\n"
"2. SCons is using a wrong C compiler. This can happen if "
"CC has the wrong value.\n"
- "CC = %s" % main['CC'])
+ "CC = %s" % penv['CC'])
for lib in py_libs:
if not conf.CheckLib(lib):
error("Can't find library %s required by python." % lib)
- main.Prepend(CPPPATH=Dir('ext/pybind11/include/'))
+ penv.Prepend(CPPPATH=Dir('ext/pybind11/include/'))
- marshal_env = main.Clone()
+ marshal_env = penv.Clone()
# Bare minimum environment that only includes python
marshal_env.Append(CCFLAGS='$MARSHAL_CCFLAGS_EXTRA')
@@ -550,9 +554,9 @@
if not GetOption('without_tcmalloc'):
if conf.CheckLib('tcmalloc'):
- main.Append(CCFLAGS=main['TCMALLOC_CCFLAGS'])
+ penv.Append(CCFLAGS=penv['TCMALLOC_CCFLAGS'])
elif conf.CheckLib('tcmalloc_minimal'):
- main.Append(CCFLAGS=main['TCMALLOC_CCFLAGS'])
+ penv.Append(CCFLAGS=penv['TCMALLOC_CCFLAGS'])
else:
warning("You can get a 12% performance improvement by "
"installing tcmalloc (libgoogle-perftools-dev package "
@@ -563,7 +567,7 @@
#
# Finish the configuration
#
-main = conf.Finish()
+main.Replace(**conf.Finish().Dictionary()) # Update main env
######################################################################
#
diff --git a/ext/systemc/SConscript b/ext/systemc/SConscript
index 0b6fb0c..61302fd 100644
--- a/ext/systemc/SConscript
+++ b/ext/systemc/SConscript
@@ -42,25 +42,25 @@
conf_dir = os.path.join(build_root, '.scons_config'),
log_file = os.path.join(build_root, 'scons_config.log'))
-if systemc['PLATFORM'] == 'darwin':
- systemc.Append(LINKFLAGS=['-undefined', 'dynamic_lookup'])
+if conf.env['PLATFORM'] == 'darwin':
+ conf.env.Append(LINKFLAGS=['-undefined', 'dynamic_lookup'])
arch = None
-systemc['COROUTINE_LIB'] = ''
+conf.env['COROUTINE_LIB'] = ''
if conf.CheckDeclaration('__i386__'):
- systemc['COROUTINE_LIB'] = 'qt'
- systemc['QT_ARCH'] = 'i386'
+ conf.env['COROUTINE_LIB'] = 'qt'
+ conf.env['QT_ARCH'] = 'i386'
arch = 'i386'
elif conf.CheckDeclaration('__x86_64__'):
- systemc['COROUTINE_LIB'] = 'qt'
- systemc['QT_ARCH'] = 'iX86_64'
+ conf.env['COROUTINE_LIB'] = 'qt'
+ conf.env['QT_ARCH'] = 'iX86_64'
arch = 'x86_64'
else:
termcap = get_termcap(GetOption('use_colors'))
print(termcap.Yellow + termcap.Bold +
"Warning: Unrecognized architecture for systemc." +
termcap.Normal)
-conf.Finish()
+systemc = conf.Finish()
if systemc['COROUTINE_LIB'] == 'pthreads':
systemc.Prepend(CXXFLAGS=['-DSC_USE_PTHREADS'])
diff --git a/src/base/SConsopts b/src/base/SConsopts
index 424789d..f4b50a1 100644
--- a/src/base/SConsopts
+++ b/src/base/SConsopts
@@ -46,9 +46,9 @@
# Valgrind gets much less confused if you tell it when you're using
# alternative stacks.
-main['HAVE_VALGRIND'] = conf.CheckCHeader('valgrind/valgrind.h')
+conf.env['HAVE_VALGRIND'] = conf.CheckCHeader('valgrind/valgrind.h')
-main = conf.Finish()
+main.Replace(**conf.Finish().Dictionary())
if have_fenv:
diff --git a/src/base/stats/SConsopts b/src/base/stats/SConsopts
index 6e0fd8a..91371ce 100644
--- a/src/base/stats/SConsopts
+++ b/src/base/stats/SConsopts
@@ -35,7 +35,7 @@
# it, setup the environment to enable linking and header inclusion. We
# don't actually try to include any headers or link with hdf5 at this
# stage.
-if main['HAVE_PKG_CONFIG']:
+if conf.env['HAVE_PKG_CONFIG']:
conf.CheckPkgConfig(['hdf5-serial', 'hdf5'],
'--cflags-only-I', '--libs-only-L')
@@ -49,7 +49,7 @@
conf.CheckLibWithHeader('hdf5_cpp', 'H5Cpp.h', 'C++',
'H5::H5File("", 0);')
-main = conf.Finish()
+main.Replace(**conf.Finish().Dictionary())
if have_hdf5:
sticky_vars.Add(BoolVariable('USE_HDF5', 'Enable the HDF5 support',
True))
diff --git a/src/cpu/kvm/SConsopts b/src/cpu/kvm/SConsopts
index 2f64806..08637d5 100644
--- a/src/cpu/kvm/SConsopts
+++ b/src/cpu/kvm/SConsopts
@@ -41,7 +41,7 @@
# we rely on exists since version 2.6.36 of the kernel, but somehow
# the KVM_API_VERSION does not reflect the change. We test for one of
# the types as a fall back.
-main['KVM_ISA'] = None
+conf.env['KVM_ISA'] = None
if not conf.CheckHeader('linux/kvm.h', '<>'):
print("Info: Compatible header file <linux/kvm.h> not found, "
"disabling KVM support.")
@@ -50,28 +50,28 @@
warning("Cannot enable KVM, host seems to lack support for POSIX
timers")
elif host_isa == 'x86_64':
if conf.CheckTypeSize('struct kvm_xsave', '#include <linux/kvm.h>') !=
0:
- main['KVM_ISA'] = 'x86'
+ conf.env['KVM_ISA'] = 'x86'
else:
warning("KVM on x86 requires xsave support in kernel headers.")
elif host_isa in ('armv7l', 'aarch64'):
- main['KVM_ISA'] = 'arm'
+ conf.env['KVM_ISA'] = 'arm'
else:
warning("Failed to determine host ISA.")
-if main['KVM_ISA']:
+if conf.env['KVM_ISA']:
# Check if the exclude_host attribute is available. We want this to
# get accurate instruction counts in KVM.
- main['HAVE_PERF_ATTR_EXCLUDE_HOST'] = conf.CheckMember(
+ conf.env['HAVE_PERF_ATTR_EXCLUDE_HOST'] = conf.CheckMember(
'linux/perf_event.h', 'struct perf_event_attr', 'exclude_host')
# Warn about missing optional functionality
- if not main['HAVE_PERF_ATTR_EXCLUDE_HOST']:
+ if not conf.env['HAVE_PERF_ATTR_EXCLUDE_HOST']:
warning("perf_event headers lack support for the exclude_host "
"attribute. KVM instruction counts will be inaccurate.")
export_vars.append('HAVE_PERF_ATTR_EXCLUDE_HOST')
-main = conf.Finish()
+main.Replace(**conf.Finish().Dictionary())
if main['KVM_ISA']:
sticky_vars.Add(BoolVariable('USE_KVM',
diff --git a/src/dev/net/SConsopts b/src/dev/net/SConsopts
index ce8b168..398da3c 100644
--- a/src/dev/net/SConsopts
+++ b/src/dev/net/SConsopts
@@ -32,7 +32,7 @@
# Check if the TUN/TAP driver is available.
have_tuntap = conf.CheckHeader('linux/if_tun.h', '<>')
-main = conf.Finish()
+main.Replace(**conf.Finish().Dictionary())
if have_tuntap:
sticky_vars.Add(BoolVariable('USE_TUNTAP',
diff --git a/src/proto/SConsopts b/src/proto/SConsopts
index a7cb86f..f7029e6 100644
--- a/src/proto/SConsopts
+++ b/src/proto/SConsopts
@@ -33,10 +33,10 @@
conf = gem5_scons.Configure(main)
# Check for the protobuf compiler
-main['HAVE_PROTOC'] = False
+conf.env['HAVE_PROTOC'] = False
protoc_version = []
try:
- protoc_version = readCommand([main['PROTOC'], '--version']).split()
+ protoc_version = readCommand([conf.env['PROTOC'], '--version']).split()
except Exception as e:
warning('While checking protoc version:', str(e))
@@ -57,24 +57,24 @@
# protobuf without the involvement of pkg-config. Later on we
# check go a library config check and at that point the test
# will fail if libprotobuf cannot be found.
- if main['HAVE_PKG_CONFIG']:
+ if conf.env['HAVE_PKG_CONFIG']:
conf.CheckPkgConfig('protobuf', '--cflags', '--libs-only-L')
- main['HAVE_PROTOC'] = True
+ conf.env['HAVE_PROTOC'] = True
# If we have the protobuf compiler, also make sure we have the
# development libraries. If the check passes, libprotobuf will be
# automatically added to the LIBS environment variable. After
# this, we can use the HAVE_PROTOBUF flag to determine if we have
# got both protoc and libprotobuf available.
-main['HAVE_PROTOBUF'] = main['HAVE_PROTOC'] and \
+conf.env['HAVE_PROTOBUF'] = conf.env['HAVE_PROTOC'] and \
conf.CheckLibWithHeader('protobuf', 'google/protobuf/message.h',
'C++', 'GOOGLE_PROTOBUF_VERIFY_VERSION;')
# If we have the compiler but not the library, print another warning.
-if main['HAVE_PROTOC'] and not main['HAVE_PROTOBUF']:
+if conf.env['HAVE_PROTOC'] and not conf.env['HAVE_PROTOBUF']:
warning('Did not find protocol buffer library and/or headers.\n'
'Please install libprotobuf-dev for tracing support.')
-main = conf.Finish()
+main.Replace(**conf.Finish().Dictionary())
export_vars.append('HAVE_PROTOBUF')
diff --git a/src/sim/SConsopts b/src/sim/SConsopts
index e299071..1ec8c2b 100644
--- a/src/sim/SConsopts
+++ b/src/sim/SConsopts
@@ -33,9 +33,9 @@
if conf.CheckLibWithHeader([None, 'execinfo'], 'execinfo.h', 'C',
'char temp; backtrace_symbols_fd((void *)&temp, 0, 0);'):
- main['BACKTRACE_IMPL'] = 'glibc'
+ conf.env['BACKTRACE_IMPL'] = 'glibc'
else:
- main['BACKTRACE_IMPL'] = 'none'
+ conf.env['BACKTRACE_IMPL'] = 'none'
warning("No suitable back trace implementation found.")
-main = conf.Finish()
+main.Replace(**conf.Finish().Dictionary())
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/44265
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I61244c1daf963272a4b5a3d0e72101afefa82491
Gerrit-Change-Number: 44265
Gerrit-PatchSet: 1
Gerrit-Owner: Hanhwi Jang <jang.han...@gmail.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s