Change CONFIG_RETPOLINE to n.
Run make menuconfig. Navigate to Processor type and features, and uncheck Avoid speculative indirect branches in kernel.
Note that your kernel can be exposed to kernel-to-user data leaks.
Open the terminal in Ubuntu and type:
sudo apt install g++-4.8
This command installs g++ version 4.8.5 in Ubuntu, the same version that is installed on your server.
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 40
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 60
sudo update-alternatives --config g++
I've had/am having the same problem. I think it's coming from gcc 9 throwing some warnings for stuff that wasn't throwing warnings before.
As a quick fix, find the SConstruct file in your gem5 directory, scroll down to where gcc flags are being set and add the warnings that pop up to the no-error list (or remove the error flag altogether):