https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93865
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 49204 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49204&action=edit gcc11-pr93865-wip.patch Untested WIP patch which seems to fix the problem. I have some problems with make_relative_prefix_ignore_links though, one is that it has way too many cases in which it just returns NULL, another one is that due to all the memory allocations it is quite expensive and lastly e.g. for "/", "/usr/src/gcc/obj/gcc/tt/b", "/usr/src/gcc/obj/gcc/tt" it returns "../../tt" rather than ".." I'd expect. So I'm considering writing a lighter version of that and have a fallback to using absolute path e.g. if the two paths have nothing in common (consider Windowsy C:\foo and D:\bar ).