[ccache] Path rewriting in ccache make_relative_path - realpath conversion and its necessity

vkr venkatakrishnarao.ks at gmail.com
Tue Jan 12 09:35:32 UTC 2016

I've a question around the function `make_relative_path()' that rewrites
the given path to its relative path, and while doing so,
it converts the given path to the realpath, and then returns the relative
path for the realpath based on the current working directory.

I was wondering why it was necessary to use the realpath while rewriting
the path to relative, instead of the given path as-is?
i.e When the check for `x_realpath' on a given path passes, why not just
use the given path to rewrite it to relative?
like so:

                relpath = get_relative_path(get_current_working_dir(),
canon_path); // Current
                relpath = get_relative_path(get_current_working_dir(),
path); // proposed

The reason I'm asking this is, while technically there is nothing wrong in
first converting the given path to realpath, and then
rewriting it to relative, in a build system where there are external tools
that use the build system provided paths,
but miss out that "converting to that realpath" part, then it gets

Handling it at ccache itself is perhaps more faster, and convenient.

Your comments are appreciated.


More information about the ccache mailing list