Added CFLAGS="-O2 -g0" before my pyenv install 3.10 before it worked in my WSL Ubuntu environment:
CFLAGS="-O2 -g0" pyenv install 3.10