I have a machine with two gem5-repository instances: one that I keep up-to-date, and the other using an aged version that I cannot update yet.
I was using Ubuntu 16.04, and the current gem5 version has deprecated the use of python 2.7. I was postponing upgrading my OS, and using a few workarounds (Reverting the commit scons: Set the minimum scons version to 3.0
, and manually adding EM_RISCV
to src/base/loader/elf_object.cc
); however, recently things got messy, so I was forced to do it in order to use SCons 3 and python3.
After trying on both Ubuntu 18.04 and 20.04, I still could not compile due to the use of metaclasses in some python class.
The real issue is clear, though; even though I have python3 installed (in /usr/bin/
), python3-config could not be found:
Info: Using Python config: python2.7-config
How can I use both python 2.7 and 3 in the same machine to compile different versions of gem5?
If SCons can't find python3-config, manually override PYTHON_CONFIG with its location, and set the proper environment.
alias scons2="/usr/bin/env python2.7 $(which scons) PYTHON_CONFIG=$(which python2.7-config)"
alias scons3="/usr/bin/env python3 $(which scons) PYTHON_CONFIG=$(which python3-config)"
Then, to compile the updated repository:
scons3 -j5 ./build/ARM/gem5.opt
To compile the one that needs python 2.7:
scons2 -j5 ./build/ARM/gem5.opt