Just remembered I had all kind of issues with newer Ubuntu versions, I had switched so Debian, much faster and way less buggy.
However setting up Debian is a little messy, so I made a backup in ready state and uploaded to Drive have a backup, you can also use it!
It has arm-linux-gnueabi-gcc installed, but it's irrelevant, that was for a different hardware, different project, doesn't affect Openwrt at all.
Turned out to be a great building machine for it, I might have compiled Openwrt 22.03 no less than 50 times in it!
Otherwise try an older Ubuntu x64 version, like 16.04, which has older kernel, and install these packages:
# Install stuff
sudo apt update && sudo apt install -y wget unzip build-essential rsync git bc swig libncurses-dev libacl1-dev libpython3-dev libssl-dev python3-distutils git cmake autoconf u-boot-tools bison flex
# Optional if you're using Virtualbox and want to install Guest Additions
sudo apt install linux-headers-$(uname -r)
git clone https://github.com/openwrt/openwrt --recursive -b openwrt-22.03 openwrt-22.03
scripts/feeds update -a
scripts/feeds install -a
# Select your targets etc, save config..
# Replace number with CPU cores+1,
# Ex. for 8 cores:
# This will take a while!
With any decent quadcore CPU with <10 years which has virtualization and at least 8GB RAM, VM should work great.
In the end it's almost the same thing as a real machine, but much easier and safer to handle, backup and maintain.
Remember to enable Virtualization in the Bios or It work extremely slow, if using Windows disable Hyper-V or Virtualbox won't stop crashing, freezing and displaying all kind of strange errors.
I already gave you everything to start compiling, couldn't be easier, now is up to you what to do!