Search code examples
sconsgem5

gem5 scons build fails with "TypeError: argument should be integer or bytes-like object, not 'str'"


I am trying to install gem5 on a fresh installation of Ubuntu 20.04 and using commit 9fc9c67b4242c03f165951775be5cd0812f2a705. I have used http://learning.gem5.org/book/part1/building.html and https://www.gem5.org/documentation/general_docs/building as my guide. As near as I can tell, I have installed all the required dependencies using (some dependencies are repeated in these two lines)

sudo apt install build-essential git m4 scons zlib1g zlib1g-dev libprotobuf-dev protobuf-compiler libprotoc-dev libgoogle-perftools-dev python-dev python

sudo apt install build-essential git m4 scons zlib1g zlib1g-dev \
    libprotobuf-dev protobuf-compiler libprotoc-dev libgoogle-perftools-dev \
    python-dev python libboost-all-dev

Then, when I try to build gem5 using

git clone https://gem5.googlesource.com/public/gem5
cd gem5    
scons build/X86/gem5.opt -j8

I get the following output after executing the 'scons' line:

scons: Reading SConscript files ...
Warning: Failed to find git repo directory: a bytes-like object is required, not 'str'
TypeError: argument should be integer or bytes-like object, not 'str':
  File "/home/john/gem5/SConstruct", line 355:
    main['GCC'] = CXX_version and CXX_version.find('g++') >= 0

I am not sure how to fix this error or even why this error is occurring; I don't even really know what this error is saying. Any help would be appreciated.


Solution

  • Yes. That's the result of running a build system implemented in scons expecting only python2.

    If you're stuck here's what you can do to be able to compile until the gem project pushes their Python 3 + SCons changes.

    sudo apt-get install virtualenv
    # create a virtualenv which uses python 2.7
    virtualenv -p python2.7 venv27
    # activate the virtualenv
    . venv27/bin/activate
    # Install SCons in the python 2.7 virtualenv
    pip install scons
    # This will now use the scons installed in a python 2.7 virtualenv.
    scons build/X86/gem5.opt -j8
    

    This worked for me on an Ubuntu 20.04 system.