What you also could use is some container technology. Docker is very invasive. Charliecloud/singularity/apptainer maybe less so.
That way, you can have a rather new glibc inside the container, which is used by your program then, while your host system still has a rather old glibc.