Of course that doesn't work. Why would anyone expect it to? Install your baseline distro version in a chroot and set GCC's --sysroot, alternatively use a container, alternatively use a Flatpak SDK, problem solved.
The main problem with this is knowing which libraries have stable ABIs and which don't, which is only documented in a convenient way for enterprise distros (RHEL/SLES).
The main problem with this is knowing which libraries have stable ABIs and which don't, which is only documented in a convenient way for enterprise distros (RHEL/SLES).