[ccache] base_dir and symbolic links
Andreas Wettstein
wettstae at gmail.com
Wed Sep 13 18:49:17 UTC 2017
In function `make_relative_path` (file `ccache.c`), the given
path is made "canonic" before it is converted to a path relative
to the current working directory. In particular, "canonic" means
that symbolic links are removed. I understand that it makes
sense to make the current working directory canonic, but I do not
see why this done for the path given to `make_relative_path`. Is
it really necessary?
The reason why I am asking is that I have a usage scenario where
this reduces sharing a cache among different users.
Much simplified, assume that we have a source code repository that
manages a couple of directories. Individual users only check out the
directories they work on. For directories they do not work on, but
are required to build the sources they work on, they create a symbolic
link to a reference area in which only stuff required for building
resides. During compilation, the working directory is always one of
the source code directories.
For example, assume user1 is working in directory `lib` and
`src`, and user2 is working in `src` only. Then the setup will
look like this:
/reference/
lib/
lib.h
/user1/
lib/
lib.h
lib.c
src/
test.c
/user1/
lib -> /reference/lib
src/
test.c
Now, assume user1 sets `base_dir` to `/user1` and user2 sets
`base_dir` to `/user2`. The working directories when compiling
`test.c` are `/user1/src` and `/user2/src`, respectively. The paths
to the lib directory are `/user1/lib` and `/user2/lib`. However, the
latter canonically becomes `/reference/lib`. Therefore, the relative
paths become `../lib` and `../../referece/lib`, respectively. As the
relative paths are not equal, the cache cannot be shared, even if the
`lib.h` and `test.c` files are identical. With the original paths
(not resolving the symbolic links), the relative paths to lib would be
`../lib` in either case, and the cache could be shared.
Regards,
Andreas
More information about the ccache
mailing list