This is probably going to be irrelevant when Ubuntu 24.04 goes out next month, but as a quick reference for anyone who really wants this there is a handy build script out there on github.
It can also install other versions of gcc.
https://github.com/slyfox1186/script-repo?tab=readme-ov-file#install-gcc-versions-latest