Andreas Sandberg has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/16003
Change subject: RFC: scons: Add hackish support for Python 3.5
......................................................................
RFC: scons: Add hackish support for Python 3.5
Build gem5 with Python 3.5. This requires that code is marshalled
using a custom script that is executed using Python 3.5 rather than
Python 2.7 (as used by scons).
Proper support for Python 3.x would require:
* A build-time switch to build gem5 with Python 3 instead of
Python 2. Python 2 should be the default for the time being.
* Proper auto-detection of the Python 3 config to use. We should
probably use python3-config instead of python3.5-config. We also
need to ensure that we are using at least version 3.5 since we
depend on the wide char conversion routines introduced in 3.5.
* A custom binary to marshal code. This hack uses a Python script
that uses python3.5 as the interpreter. We need to make sure that
we use the same version as the gem5 binary. The best way to
accomplish this is to build a separate helper that links with the
right Python library.
Change-Id: I1f4c00d66f85a9c99f50fe4d746b69dd82b60b4b
Signed-off-by: Andreas Sandberg <[email protected]>
---
M SConstruct
M src/SConscript
A src/marshall.py
3 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/SConstruct b/SConstruct
index 5c8f649..5836d08 100755
--- a/SConstruct
+++ b/SConstruct
@@ -704,7 +704,7 @@
# scons with the appropriate PATH set.
#
# First we check if python2-config exists, else we use python-config
- python_config = readCommand(['which', 'python2-config'],
+ python_config = readCommand(['which', 'python3.5-config'],
exception='').strip()
if not os.path.exists(python_config):
python_config = readCommand(['which', 'python-config'],
diff --git a/src/SConscript b/src/SConscript
index 987cc37..7cf6ccb 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -1136,15 +1136,14 @@
return "0"
return '"%s"' % string
+ from m5.util import compareVersions, readCommand
+
'''Action function to compile a .py into a code object, marshal
it, compress it, and stick it into an asm file so the code appears
as just bytes with a label in the data section'''
- src = file(str(source[0]), 'r').read()
-
pysource = PySource.tnodes[source[0]]
- compiled = compile(src, pysource.abspath, 'exec')
- marshalled = marshal.dumps(compiled)
+ marshalled = readCommand(['./src/marshall.py', str(source[0])])
compressed = zlib.compress(marshalled)
data = compressed
sym = pysource.symname
diff --git a/src/marshall.py b/src/marshall.py
new file mode 100755
index 0000000..dae4430
--- /dev/null
+++ b/src/marshall.py
@@ -0,0 +1,14 @@
+#!/usr/bin/env python3.5
+
+import marshal
+import sys
+
+source = sys.argv[1]
+
+with open(source, 'r') as f:
+ src = f.read()
+
+compiled = compile(src, source, 'exec')
+marshalled = marshal.dumps(compiled)
+
+sys.stdout.buffer.write(marshal.dumps(compiled))
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/16003
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I1f4c00d66f85a9c99f50fe4d746b69dd82b60b4b
Gerrit-Change-Number: 16003
Gerrit-PatchSet: 1
Gerrit-Owner: Andreas Sandberg <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev