[compat] Introduce compat_realpath (refs #23991)