scons: Build the marshal binary in a bare minimum environment

This change adds an additional bare minimum environment that includes
python only and changes the marshal binary to compile using it.

Change-Id: Id5d1ee6899796d746d8dc1a004cfe4795f040c55
Signed-off-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/28428
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Nikos Nikoleris
2020-04-30 17:33:13 +01:00
parent 63d57fd861
commit a0414b585b
2 changed files with 10 additions and 7 deletions

View File

@@ -709,6 +709,10 @@ if main['USE_PYTHON']:
if not conf.CheckLib(lib): if not conf.CheckLib(lib):
error("Can't find library %s required by python." % lib) error("Can't find library %s required by python." % lib)
main.Prepend(CPPPATH=Dir('ext/pybind11/include/'))
# Bare minimum environment that only includes python
base_py_env = main.Clone()
# On Solaris you need to use libsocket for socket ops # On Solaris you need to use libsocket for socket ops
if not conf.CheckLibWithHeader(None, 'sys/socket.h', 'C++', 'accept(0,0,0);'): if not conf.CheckLibWithHeader(None, 'sys/socket.h', 'C++', 'accept(0,0,0);'):
if not conf.CheckLibWithHeader('socket', 'sys/socket.h', if not conf.CheckLibWithHeader('socket', 'sys/socket.h',
@@ -1100,8 +1104,6 @@ for root, dirs, files in os.walk(ext_dir):
gdb_xml_dir = joinpath(ext_dir, 'gdb-xml') gdb_xml_dir = joinpath(ext_dir, 'gdb-xml')
Export('gdb_xml_dir') Export('gdb_xml_dir')
main.Prepend(CPPPATH=Dir('ext/pybind11/include/'))
################################################### ###################################################
# #
# This builder and wrapper method are used to set up a directory with # This builder and wrapper method are used to set up a directory with
@@ -1259,7 +1261,8 @@ for variant_path in variant_paths:
# The src/SConscript file sets up the build rules in 'env' according # The src/SConscript file sets up the build rules in 'env' according
# to the configured variables. It returns a list of environments, # to the configured variables. It returns a list of environments,
# one for each variant build (debug, opt, etc.) # one for each variant build (debug, opt, etc.)
SConscript('src/SConscript', variant_dir = variant_path, exports = 'env') SConscript('src/SConscript', variant_dir=variant_path,
exports=['env', 'base_py_env'])
# base help text # base help text
Help(''' Help('''

View File

@@ -1,6 +1,6 @@
# -*- mode:python -*- # -*- mode:python -*-
# Copyright (c) 2018 ARM Limited # Copyright (c) 2018, 2020 ARM Limited
# #
# The license below extends only to copyright in the software and shall # The license below extends only to copyright in the software and shall
# not be construed as granting a license to any other intellectual # not be construed as granting a license to any other intellectual
@@ -1140,7 +1140,7 @@ env.AlwaysBuild(tags)
# Build a small helper that marshals the Python code using the same # Build a small helper that marshals the Python code using the same
# version of Python as gem5. This is in an unorthodox location to # version of Python as gem5. This is in an unorthodox location to
# avoid building it for every variant. # avoid building it for every variant.
py_marshal = env.Program('marshal', 'python/marshal.cc')[0] py_marshal = base_py_env.Program('marshal', 'python/marshal.cc')[0]
# Embed python files. All .py files that have been indicated by a # Embed python files. All .py files that have been indicated by a
# PySource() call in a SConscript need to be embedded into the M5 # PySource() call in a SConscript need to be embedded into the M5
@@ -1196,8 +1196,8 @@ EmbeddedPython embedded_${sym}(
code.write(str(target[0])) code.write(str(target[0]))
for source in PySource.all: for source in PySource.all:
env.Command(source.cpp, [ py_marshal, source.tnode ], base_py_env.Command(source.cpp, [ py_marshal, source.tnode ],
MakeAction(embedPyFile, Transform("EMBED PY"))) MakeAction(embedPyFile, Transform("EMBED PY")))
Source(source.cpp, tags=source.tags, add_tags='python') Source(source.cpp, tags=source.tags, add_tags='python')
######################################################################## ########################################################################