scons: Put all config variables in an env['CONF'] sub-dict.

This makes what are configuration and what are internal SCons variables
explicit and separate, and makes it unnecessary to call out what
variables to export to C++.

These variables will also be plumbed into and out of kconfiglib in later
changes.

Change-Id: Iaf5e098d7404af06285c421dbdf8ef4171b3f001
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/56892
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Gabe Black
2022-02-15 22:23:43 -08:00
parent caa5f12e21
commit e6c0ba97db
87 changed files with 211 additions and 233 deletions

View File

@@ -85,13 +85,12 @@ Source('pc_event.cc')
SimObject('FuncUnit.py', sim_objects=['OpDesc', 'FUDesc'], enums=['OpClass'])
SimObject('StaticInstFlags.py', enums=['StaticInstFlags'])
if env['TARGET_ISA'] == 'null':
if env['CONF']['TARGET_ISA'] == 'null':
Return()
# Only build the protobuf instructions tracer if we have protobuf support.
if env['HAVE_PROTOBUF']:
SimObject('InstPBTrace.py', sim_objects=['InstPBTrace'])
Source('inst_pb_trace.cc')
SimObject('InstPBTrace.py', sim_objects=['InstPBTrace'], tags='protobuf')
Source('inst_pb_trace.cc', tags='protobuf')
SimObject('CheckerCPU.py', sim_objects=['CheckerCPU'])

View File

@@ -37,7 +37,8 @@
Import('*')
if not env['USE_KVM'] or env['TARGET_ISA'] != env['KVM_ISA']:
if not env['CONF']['USE_KVM'] or \
env['CONF']['TARGET_ISA'] != env['CONF']['KVM_ISA']:
Return()
SimObject('KvmVM.py', sim_objects=['KvmVM'])

View File

@@ -42,7 +42,7 @@ with gem5_scons.Configure(main) as conf:
# the types as a fall back.
# The default value of KVM_ISA should serialize to a string in the
# C++ header and test False in Scons/Python.
conf.env['KVM_ISA'] = ''
conf.env['CONF']['KVM_ISA'] = ''
if not conf.CheckHeader('linux/kvm.h', '<>'):
print("Info: Compatible header file <linux/kvm.h> not found, "
"disabling KVM support.")
@@ -52,33 +52,28 @@ with gem5_scons.Configure(main) as conf:
elif host_isa == 'x86_64':
if conf.CheckTypeSize('struct kvm_xsave',
'#include <linux/kvm.h>') != 0:
conf.env['KVM_ISA'] = 'x86'
conf.env['CONF']['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'
conf.env['CONF']['KVM_ISA'] = 'arm'
else:
warning("Failed to determine host ISA.")
if conf.env['KVM_ISA']:
if conf.env['CONF']['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(
conf.env['CONF']['HAVE_PERF_ATTR_EXCLUDE_HOST'] = conf.CheckMember(
'linux/perf_event.h', 'struct perf_event_attr', 'exclude_host')
# Warn about missing optional functionality
if not conf.env['HAVE_PERF_ATTR_EXCLUDE_HOST']:
if not conf.env['CONF']['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')
if main['KVM_ISA']:
if main['CONF']['KVM_ISA']:
sticky_vars.Add(BoolVariable('USE_KVM',
'Enable hardware virtualized (KVM) CPU models', True))
else:
main['USE_KVM'] = False
export_vars.append('USE_KVM')
main['CONF']['USE_KVM'] = False
warning("Can not enable KVM, host seems to lack KVM support")
export_vars.append('KVM_ISA')

View File

@@ -40,7 +40,7 @@
Import('*')
if env['TARGET_ISA'] != 'null':
if env['CONF']['TARGET_ISA'] != 'null':
SimObject('BaseMinorCPU.py', sim_objects=[
'MinorOpClass', 'MinorOpClassSet', 'MinorFUTiming', 'MinorFU',
'MinorFUPool', 'BaseMinorCPU'],

View File

@@ -30,7 +30,7 @@ import sys
Import('*')
if env['TARGET_ISA'] != 'null':
if env['CONF']['TARGET_ISA'] != 'null':
SimObject('FUPool.py', sim_objects=['FUPool'])
SimObject('FuncUnitConfig.py', sim_objects=[])
SimObject('BaseO3CPU.py', sim_objects=['BaseO3CPU'], enums=[

View File

@@ -37,12 +37,11 @@
Import('*')
if env['TARGET_ISA'] != 'null':
if env['CONF']['TARGET_ISA'] != 'null':
SimObject('SimpleTrace.py', sim_objects=['SimpleTrace'])
Source('simple_trace.cc')
DebugFlag('SimpleTrace')
if env['HAVE_PROTOBUF']:
SimObject('ElasticTrace.py', sim_objects=['ElasticTrace'])
Source('elastic_trace.cc')
DebugFlag('ElasticTrace')
SimObject('ElasticTrace.py', sim_objects=['ElasticTrace'], tags='protobuf')
Source('elastic_trace.cc', tags='protobuf')
DebugFlag('ElasticTrace', tags='protobuf')

View File

@@ -28,7 +28,7 @@
Import('*')
if env['TARGET_ISA'] == 'null':
if env['CONF']['TARGET_ISA'] == 'null':
Return()
SimObject('BranchPredictor.py', sim_objects=[

View File

@@ -28,7 +28,7 @@
Import('*')
if env['TARGET_ISA'] != 'null':
if env['CONF']['TARGET_ISA'] != 'null':
SimObject('BaseAtomicSimpleCPU.py', sim_objects=['BaseAtomicSimpleCPU'])
Source('atomic.cc')

View File

@@ -28,6 +28,6 @@
Import('*')
if env['TARGET_ISA'] != 'null':
if env['CONF']['TARGET_ISA'] != 'null':
SimObject('SimPoint.py', sim_objects=['SimPoint'])
Source('simpoint.cc')

View File

@@ -35,7 +35,7 @@ Import('*')
# When this dependency is removed, the ruby tester should be compiled
# independently from Ruby
#
if env['PROTOCOL'] == 'None':
if env['CONF']['PROTOCOL'] == 'None':
Return()
SimObject('RubyDirectedTester.py', sim_objects=[

View File

@@ -28,7 +28,7 @@
Import('*')
if env['PROTOCOL'] == 'None':
if env['CONF']['PROTOCOL'] == 'None':
Return()
SimObject('GarnetSyntheticTraffic.py', sim_objects=['GarnetSyntheticTraffic'])

View File

@@ -31,10 +31,10 @@
Import('*')
if not env['BUILD_GPU']:
if not env['CONF']['BUILD_GPU']:
Return()
if env['PROTOCOL'] == 'None':
if env['CONF']['PROTOCOL'] == 'None':
Return()
SimObject('ProtocolTester.py', sim_objects=['ProtocolTester'])

View File

@@ -35,7 +35,7 @@ Import('*')
# When this dependency is removed, the ruby tester should be compiled
# independently from Ruby
#
if env['PROTOCOL'] == 'None':
if env['CONF']['PROTOCOL'] == 'None':
Return()
SimObject('RubyTester.py', sim_objects=['RubyTester'])

View File

@@ -65,8 +65,7 @@ if env['USE_PYTHON']:
# Only build the traffic generator if we have support for protobuf as the
# tracing relies on it
if env['HAVE_PROTOBUF']:
SimObject('TrafficGen.py', sim_objects=['TrafficGen'])
Source('trace_gen.cc')
Source('traffic_gen.cc')
SimObject('TrafficGen.py', sim_objects=['TrafficGen'], tags='protobuf')
Source('trace_gen.cc', tags='protobuf')
Source('traffic_gen.cc', tags='protobuf')

View File

@@ -1,12 +1,11 @@
Import('*')
if env['TARGET_ISA'] == 'null':
if env['CONF']['TARGET_ISA'] == 'null':
Return()
# Only build TraceCPU if we have support for protobuf as TraceCPU relies on it
if env['HAVE_PROTOBUF']:
SimObject('TraceCPU.py', sim_objects=['TraceCPU'])
Source('trace_cpu.cc')
SimObject('TraceCPU.py', sim_objects=['TraceCPU'], tags='protobuf')
Source('trace_cpu.cc', tags='protobuf')
DebugFlag('TraceCPUData')
DebugFlag('TraceCPUInst')