Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/44389 )

Change subject: scons: Convert gem5_scons.Configure to a context manager.
......................................................................

scons: Convert gem5_scons.Configure to a context manager.

This has two purposes. First, SCons assumes that once you call
Configure, you won't set up the environment the Configure is based on
until after you get the environment back from it again with
conf.Finish(). We get away with this when the cache mode for config
tests is not "force", since Configure just reuses the environment we
pass in, and any changes we make are immediately communicated between
the two.

If the cache mode *is* "force" though, SCons modifies the decider so
that everything the conf environment goes to build looks like it's out
of date. It does that by cloning the original environment, and then
using that clone to do its tests. That causes a problem because we have
a long lived "conf" object and make further changes to main, and since
the two environments are now separate the one in conf doesn't see those
updates.

Second, and more subtly, we export our "main" and "env" environments so
that other SConsopts and SConscript files can use them and define things
in them. The way Configure is designed, if the config caching mode is
"force", then it will create a new environment, and then that
environment will replace what the, for instance, "main" variable points
to when "main = conf.Finish()" is executed.

Unfortunately, if we've already Export()-ed main, we've exported what
the "main" variable pointed to at that time. Our view of "main" will
track with the value that conf.Finish() returned, but since that
construction environment is mearly derived from the main we Exported and
not actually the same thing, they have diverged at that point and will
behave independently.

To solve both of these problems, this change modifies the
gem5_scons.Configure() method so that it's a context manager instead of
a regular function. As before, it will call Configure for us and create
a configuration context, which it will yield as the "with" value. When
the context exits, all the variables in the context Finish() returns
will be shoved back into the original context with Replace(). This isn't
perfect since variables which were deleted in the environment (probably
very rare in practice) will not exist and so will not overwrite the
still existent variable in the original dict.

This has several advantages. The environment never splits into two
copies which continue on independently. It makes the lifetime of a
configuration context short, which is good because behavior during that
time is tricky and unintuitive. It also makes the scope of the context
very clear, so that you won't miss the fact that you're in a special
setting and need to pay attention to what environment you're modifying.

Also, this keeps the conceptual overhead of configuration localized to
where the configuration is happening. In parts of the SConscripts which
are not doing anything with conf, etc, they don't have to modify their
behavior since no configuration context is active.

This change is based on this change from Hanhwi Jang who identified this
problem and proposed an initial solution:

https://gem5-review.googlesource.com/c/public/gem5/+/44265

Change-Id: Iae0a292d6b375c5da98619f31392ca1de6216fcd
---
M SConstruct
M ext/systemc/SConscript
M site_scons/gem5_scons/configure.py
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
A src/test.txt
10 files changed, 176 insertions(+), 178 deletions(-)



diff --git a/SConstruct b/SConstruct
index b99ecdb..021883b 100755
--- a/SConstruct
+++ b/SConstruct
@@ -289,10 +289,6 @@
 # compiler we're using.
 main['TCMALLOC_CCFLAGS'] = []

-# Platform-specific configuration.  Note again that we assume that all
-# builds under a given build root run on the same host platform.
-conf = gem5_scons.Configure(main)
-
 CXX_version = readCommand([main['CXX'], '--version'], exception=False)

 main['GCC'] = CXX_version and CXX_version.find('g++') >= 0
@@ -320,7 +316,8 @@
         # On FreeBSD we need libthr.
         main.Append(LIBS=['thr'])

-    conf.CheckLinkFlag('-Wl,--as-needed')
+    with gem5_scons.Configure(main) as conf:
+        conf.CheckLinkFlag('-Wl,--as-needed')
     if GetOption('gold_linker'):
         main.Append(LINKFLAGS='-fuse-ld=gold')

@@ -379,8 +376,9 @@
             main[var] = ['-flto']

     # clang has a few additional warnings that we disable.
-    conf.CheckCxxFlag('-Wno-c99-designator')
-    conf.CheckCxxFlag('-Wno-defaulted-function-deleted')
+    with gem5_scons.Configure(main) as conf:
+        conf.CheckCxxFlag('-Wno-c99-designator')
+        conf.CheckCxxFlag('-Wno-defaulted-function-deleted')

     main.Append(TCMALLOC_CCFLAGS=['-fno-builtin'])

@@ -442,10 +440,11 @@
     CacheDir(main['M5_BUILD_CACHE'])

 if not GetOption('no_compress_debug'):
-    if not conf.CheckCxxFlag('-gz'):
-        warning("Can't enable object file debug section compression")
-    if not conf.CheckLinkFlag('-gz'):
-        warning("Can't enable executable debug section compression")
+    with gem5_scons.Configure(main) as conf:
+        if not conf.CheckCxxFlag('-gz'):
+            warning("Can't enable object file debug section compression")
+        if not conf.CheckLinkFlag('-gz'):
+            warning("Can't enable executable debug section compression")

 main['USE_PYTHON'] = not GetOption('without_python')
 if main['USE_PYTHON']:
@@ -500,33 +499,34 @@
              if lib not in py_libs:
                  py_libs.append(lib)

-    # verify that this stuff works
-    if not conf.CheckHeader('Python.h', '<>'):
-        error("Check failed for Python.h header in",
-                ' '.join(py_includes), "\n"
-              "Two possible reasons:\n"
-              "1. Python headers are not installed (You can install the "
-              "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'])
-
-    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/'))

+    with gem5_scons.Configure(main) as conf:
+        # verify that this stuff works
+        if not conf.CheckHeader('Python.h', '<>'):
+            error("Check failed for Python.h header in",
+                    ' '.join(py_includes), "\n"
+                  "Two possible reasons:\n"
+ "1. Python headers are not installed (You can install the "
+                  "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'])
+
+        for lib in py_libs:
+            if not conf.CheckLib(lib):
+                error("Can't find library %s required by python." % lib)
+
+        py_version = conf.CheckPythonLib()
+        if not py_version:
+            error("Can't find a working Python installation")
+
     marshal_env = main.Clone()

     # Bare minimum environment that only includes python
     marshal_env.Append(CCFLAGS='$MARSHAL_CCFLAGS_EXTRA')
     marshal_env.Append(LINKFLAGS='$MARSHAL_LDFLAGS_EXTRA')

-    py_version = conf.CheckPythonLib()
-    if not py_version:
-        error("Can't find a working Python installation")
-
     # Found a working Python installation. Check if it meets minimum
     # requirements.
     if py_version[0] < 3 or \
@@ -535,38 +535,34 @@
     elif py_version[0] > 3:
         warning('Python version too new. Python 3 expected.')

-# On Solaris you need to use libsocket for socket ops
-if not conf.CheckLibWithHeader(
-        [None, 'socket'], 'sys/socket.h', 'C++', 'accept(0,0,0);'):
-   error("Can't find library with socket calls (e.g. accept()).")
+with gem5_scons.Configure(main) as conf:
+    # On Solaris you need to use libsocket for socket ops
+    if not conf.CheckLibWithHeader(
+            [None, 'socket'], 'sys/socket.h', 'C++', 'accept(0,0,0);'):
+       error("Can't find library with socket calls (e.g. accept()).")

-# Check for zlib.  If the check passes, libz will be automatically
-# added to the LIBS environment variable.
-if not conf.CheckLibWithHeader('z', 'zlib.h', 'C++','zlibVersion();'):
-    error('Did not find needed zlib compression library '
-          'and/or zlib.h header file.\n'
-          'Please install zlib and try again.')
+    # Check for zlib.  If the check passes, libz will be automatically
+    # added to the LIBS environment variable.
+    if not conf.CheckLibWithHeader('z', 'zlib.h', 'C++','zlibVersion();'):
+        error('Did not find needed zlib compression library '
+              'and/or zlib.h header file.\n'
+              'Please install zlib and try again.')


 if not GetOption('without_tcmalloc'):
-    if conf.CheckLib('tcmalloc'):
-        main.Append(CCFLAGS=main['TCMALLOC_CCFLAGS'])
-    elif conf.CheckLib('tcmalloc_minimal'):
-        main.Append(CCFLAGS=main['TCMALLOC_CCFLAGS'])
-    else:
-        warning("You can get a 12% performance improvement by "
-                "installing tcmalloc (libgoogle-perftools-dev package "
-                "on Ubuntu or RedHat).")
+    with gem5_scons.Configure(main) as conf:
+        if conf.CheckLib('tcmalloc'):
+            conf.env.Append(CCFLAGS=main['TCMALLOC_CCFLAGS'])
+        elif conf.CheckLib('tcmalloc_minimal'):
+            conf.env.Append(CCFLAGS=main['TCMALLOC_CCFLAGS'])
+        else:
+            warning("You can get a 12% performance improvement by "
+                    "installing tcmalloc (libgoogle-perftools-dev package "
+                    "on Ubuntu or RedHat).")


 ######################################################################
 #
-# Finish the configuration
-#
-main = conf.Finish()
-
-######################################################################
-#
 # Collect all non-global variables
 #

diff --git a/ext/systemc/SConscript b/ext/systemc/SConscript
index 0b6fb0c..d0cb6f8 100644
--- a/ext/systemc/SConscript
+++ b/ext/systemc/SConscript
@@ -41,6 +41,7 @@
 conf = Configure(systemc,
                  conf_dir = os.path.join(build_root, '.scons_config'),
                  log_file = os.path.join(build_root, 'scons_config.log'))
+systemc = conf.env

 if systemc['PLATFORM'] == 'darwin':
     systemc.Append(LINKFLAGS=['-undefined', 'dynamic_lookup'])
@@ -60,7 +61,7 @@
     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/site_scons/gem5_scons/configure.py b/site_scons/gem5_scons/configure.py
index 35aa1a9..3993686 100644
--- a/site_scons/gem5_scons/configure.py
+++ b/site_scons/gem5_scons/configure.py
@@ -38,6 +38,7 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+import contextlib
 import os

 import SCons.Script
@@ -134,6 +135,7 @@

     return ret

[email protected]
 def Configure(env, *args, **kwargs):
     kwargs.setdefault('conf_dir',
             os.path.join(env['BUILDROOT'], '.scons_config'))
@@ -168,4 +170,7 @@

         conf = NullConf(main)

-    return conf
+    try:
+        yield conf
+    finally:
+        env.Replace(**conf.Finish().Dictionary())
diff --git a/src/base/SConsopts b/src/base/SConsopts
index 424789d..e56e9ba 100644
--- a/src/base/SConsopts
+++ b/src/base/SConsopts
@@ -29,26 +29,24 @@

 import gem5_scons

-conf = gem5_scons.Configure(main)
+with gem5_scons.Configure(main) as conf:

-# Check for <fenv.h> (C99 FP environment control)
-have_fenv = conf.CheckHeader('fenv.h', '<>')
+    # Check for <fenv.h> (C99 FP environment control)
+    have_fenv = conf.CheckHeader('fenv.h', '<>')

-# Check for <png.h> (libpng library needed if wanting to dump
-# frame buffer image in png format)
-have_png = conf.CheckHeader('png.h', '<>')
+    # Check for <png.h> (libpng library needed if wanting to dump
+    # frame buffer image in png format)
+    have_png = conf.CheckHeader('png.h', '<>')

-have_posix_clock = \
-    conf.CheckLibWithHeader([None, 'rt'], 'time.h', 'C',
-                            'clock_nanosleep(0,0,NULL,NULL);')
-if not have_posix_clock:
-    warning("Can't find library for POSIX clocks.")
+    have_posix_clock = \
+        conf.CheckLibWithHeader([None, 'rt'], 'time.h', 'C',
+                                'clock_nanosleep(0,0,NULL,NULL);')
+    if not have_posix_clock:
+        warning("Can't find library for POSIX clocks.")

-# Valgrind gets much less confused if you tell it when you're using
-# alternative stacks.
-main['HAVE_VALGRIND'] = conf.CheckCHeader('valgrind/valgrind.h')
-
-main = conf.Finish()
+    # Valgrind gets much less confused if you tell it when you're using
+    # alternative stacks.
+    conf.env['HAVE_VALGRIND'] = conf.CheckCHeader('valgrind/valgrind.h')


 if have_fenv:
diff --git a/src/base/stats/SConsopts b/src/base/stats/SConsopts
index 6e0fd8a..6fc9f67 100644
--- a/src/base/stats/SConsopts
+++ b/src/base/stats/SConsopts
@@ -29,27 +29,25 @@

 import gem5_scons

-conf = gem5_scons.Configure(main)
+with gem5_scons.Configure(main) as conf:

-# Check if there is a pkg-config configuration for hdf5. If we find
-# 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']:
-    conf.CheckPkgConfig(['hdf5-serial', 'hdf5'],
-            '--cflags-only-I', '--libs-only-L')
+    # Check if there is a pkg-config configuration for hdf5. If we find
+    # 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 conf.env['HAVE_PKG_CONFIG']:
+        conf.CheckPkgConfig(['hdf5-serial', 'hdf5'],
+                '--cflags-only-I', '--libs-only-L')

-# Check if the HDF5 libraries can be found. This check respects the
-# include path and library path provided by pkg-config. We perform
-# this check even if there isn't a pkg-config configuration for hdf5
-# since some installations don't use pkg-config.
-have_hdf5 = \
-        conf.CheckLibWithHeader('hdf5', 'hdf5.h', 'C',
-                                'H5Fcreate("", 0, 0, 0);') and \
-        conf.CheckLibWithHeader('hdf5_cpp', 'H5Cpp.h', 'C++',
-                                'H5::H5File("", 0);')
-
-main = conf.Finish()
+    # Check if the HDF5 libraries can be found. This check respects the
+    # include path and library path provided by pkg-config. We perform
+    # this check even if there isn't a pkg-config configuration for hdf5
+    # since some installations don't use pkg-config.
+    have_hdf5 = \
+            conf.CheckLibWithHeader('hdf5', 'hdf5.h', 'C',
+                                    'H5Fcreate("", 0, 0, 0);') and \
+            conf.CheckLibWithHeader('hdf5_cpp', 'H5Cpp.h', 'C++',
+                                    'H5::H5File("", 0);')

 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..4117736 100644
--- a/src/cpu/kvm/SConsopts
+++ b/src/cpu/kvm/SConsopts
@@ -35,43 +35,41 @@
 except:
     pass

-conf = gem5_scons.Configure(main)
-
-# Check if we should enable KVM-based hardware virtualization. The API
-# 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
-if not conf.CheckHeader('linux/kvm.h', '<>'):
-    print("Info: Compatible header file <linux/kvm.h> not found, "
-          "disabling KVM support.")
-elif not conf.CheckLibWithHeader([None, 'rt'], [ 'time.h', 'signal.h' ], 'C', - 'timer_create(CLOCK_MONOTONIC, NULL, NULL);'): - 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'
+with gem5_scons.Configure(main) as conf:
+    # Check if we should enable KVM-based hardware virtualization. The API
+    # 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.
+    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.")
+ elif not conf.CheckLibWithHeader([None, 'rt'], [ 'time.h', 'signal.h' ],
+            'C', 'timer_create(CLOCK_MONOTONIC, NULL, NULL);'):
+        warning("Cannot enable KVM, host doesn't support POSIX timers")
+    elif host_isa == 'x86_64':
+        if conf.CheckTypeSize('struct kvm_xsave',
+                '#include <linux/kvm.h>') != 0:
+            conf.env['KVM_ISA'] = 'x86'
+        else:
+            warning("KVM on x86 requires xsave support in kernel headers.")
+    elif host_isa in ('armv7l', 'aarch64'):
+        conf.env['KVM_ISA'] = 'arm'
     else:
-        warning("KVM on x86 requires xsave support in kernel headers.")
-elif host_isa in ('armv7l', 'aarch64'):
-    main['KVM_ISA'] = 'arm'
-else:
-    warning("Failed to determine host ISA.")
+        warning("Failed to determine host ISA.")

-if main['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(
-        'linux/perf_event.h', 'struct perf_event_attr', 'exclude_host')
+    if conf.env['KVM_ISA']:
+        # Check if the exclude_host attribute is available. We want this to
+        # get accurate instruction counts in KVM.
+        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']:
-        warning("perf_event headers lack support for the exclude_host "
-                "attribute. KVM instruction counts will be inaccurate.")
+        # Warn about missing optional functionality
+        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()
+        export_vars.append('HAVE_PERF_ATTR_EXCLUDE_HOST')

 if main['KVM_ISA']:
     sticky_vars.Add(BoolVariable('USE_KVM',
diff --git a/src/dev/net/SConsopts b/src/dev/net/SConsopts
index ce8b168..1bb78da 100644
--- a/src/dev/net/SConsopts
+++ b/src/dev/net/SConsopts
@@ -27,12 +27,9 @@

 import gem5_scons

-conf = gem5_scons.Configure(main)
-
-# Check if the TUN/TAP driver is available.
-have_tuntap = conf.CheckHeader('linux/if_tun.h', '<>')
-
-main = conf.Finish()
+with gem5_scons.Configure(main) as conf:
+    # Check if the TUN/TAP driver is available.
+    have_tuntap = conf.CheckHeader('linux/if_tun.h', '<>')

 if have_tuntap:
     sticky_vars.Add(BoolVariable('USE_TUNTAP',
diff --git a/src/proto/SConsopts b/src/proto/SConsopts
index a7cb86f..f803fc1 100644
--- a/src/proto/SConsopts
+++ b/src/proto/SConsopts
@@ -30,51 +30,48 @@

 import gem5_scons

-conf = gem5_scons.Configure(main)
+with gem5_scons.Configure(main) as conf:
+    # Check for the protobuf compiler
+    conf.env['HAVE_PROTOC'] = False
+    protoc_version = []
+    try:
+        protoc_version = readCommand([main['PROTOC'], '--version']).split()
+    except Exception as e:
+        warning('While checking protoc version:', str(e))

-# Check for the protobuf compiler
-main['HAVE_PROTOC'] = False
-protoc_version = []
-try:
-    protoc_version = readCommand([main['PROTOC'], '--version']).split()
-except Exception as e:
-    warning('While checking protoc version:', str(e))
+ # Based on the availability of the compress stream wrappers, require 2.1.0.
+    min_protoc_version = '2.1.0'

-# Based on the availability of the compress stream wrappers, require 2.1.0.
-min_protoc_version = '2.1.0'
+    # First two words should be "libprotoc x.y.z"
+    if len(protoc_version) < 2 or protoc_version[0] != 'libprotoc':
+        warning('Protocol buffer compiler (protoc) not found.\n'
+                'Please install protobuf-compiler for tracing support.')
+    elif compareVersions(protoc_version[1], min_protoc_version) < 0:
+ warning('protoc version', min_protoc_version, 'or newer required.\n'
+                'Installed version:', protoc_version[1])
+    else:
+        # Attempt to determine the appropriate include path and
+        # library path using pkg-config, that means we also need to
+        # check for pkg-config. Note that it is possible to use
+        # 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 conf.env['HAVE_PKG_CONFIG']:
+            conf.CheckPkgConfig('protobuf', '--cflags', '--libs-only-L')
+        conf.env['HAVE_PROTOC'] = True

-# First two words should be "libprotoc x.y.z"
-if len(protoc_version) < 2 or protoc_version[0] != 'libprotoc':
-    warning('Protocol buffer compiler (protoc) not found.\n'
-            'Please install protobuf-compiler for tracing support.')
-elif compareVersions(protoc_version[1], min_protoc_version) < 0:
-    warning('protoc version', min_protoc_version, 'or newer required.\n'
-            'Installed version:', protoc_version[1])
-else:
-    # Attempt to determine the appropriate include path and
-    # library path using pkg-config, that means we also need to
-    # check for pkg-config. Note that it is possible to use
-    # 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']:
-        conf.CheckPkgConfig('protobuf', '--cflags', '--libs-only-L')
-    main['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.CheckLibWithHeader('protobuf', 'google/protobuf/message.h',
-                            'C++', 'GOOGLE_PROTOBUF_VERIFY_VERSION;')
+    # 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.
+    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']:
     warning('Did not find protocol buffer library and/or headers.\n'
             'Please install libprotobuf-dev for tracing support.')

-main = conf.Finish()
-
 export_vars.append('HAVE_PROTOBUF')
diff --git a/src/sim/SConsopts b/src/sim/SConsopts
index e299071..07997c7 100644
--- a/src/sim/SConsopts
+++ b/src/sim/SConsopts
@@ -29,13 +29,10 @@

 import gem5_scons

-conf = gem5_scons.Configure(main)
-
-if conf.CheckLibWithHeader([None, 'execinfo'], 'execinfo.h', 'C',
-        'char temp; backtrace_symbols_fd((void *)&temp, 0, 0);'):
-    main['BACKTRACE_IMPL'] = 'glibc'
-else:
-    main['BACKTRACE_IMPL'] = 'none'
-    warning("No suitable back trace implementation found.")
-
-main = conf.Finish()
+with gem5_scons.Configure(main) as conf:
+    if conf.CheckLibWithHeader([None, 'execinfo'], 'execinfo.h', 'C',
+            'char temp; backtrace_symbols_fd((void *)&temp, 0, 0);'):
+        conf.env['BACKTRACE_IMPL'] = 'glibc'
+    else:
+        conf.env['BACKTRACE_IMPL'] = 'none'
+        warning("No suitable back trace implementation found.")
diff --git a/src/test.txt b/src/test.txt
new file mode 100644
index 0000000..b033488
--- /dev/null
+++ b/src/test.txt
@@ -0,0 +1,11 @@
+0
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/44389
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: Iae0a292d6b375c5da98619f31392ca1de6216fcd
Gerrit-Change-Number: 44389
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to