[ccache] [PATCH] Potentially produce better relative pathnames when symlinks are
joel at rosdahl.net
Sun Mar 13 16:20:07 MDT 2011
On 2011-02-28 13:30, Mike Crowe wrote:
> When making relative pathnames try and do so both before and after
> calling realpath and pick the version that is the shortest. This helps
> if the build starts from a path that contains a symlink and a Makefile
> somewhere decides to use realpath to generate absolute paths.
(Sorry for the delayed reply.)
First I thought that your use case is this: There's a file named
/dir1/src/file.c, /dir2 is a symlink to /dir1 and CCACHE_BASEDIR=/dir2.
The Makefile in /dir1/src runs "gcc -c $(realdir file.c) -o file.o", so
when invoked in /dir2/src, make will execute "gcc -c /dir1/src/file.c -o
file.o", and ccache will thus not detect that /dir1/src/file.c should be
rewritten since it doesn't match CCACHE_BASEDIR.
But your patch doesn't address that problem, so that's not the use case.
Let's try again. There's a file named /dir/1/src/file.c, /dir/2 is a
symlink to /dir/1 and CCACHE_BASEDIR=/dir. The Makefile in /dir/1/src
runs "gcc -c $(realdir file.c) -o file.o", so when invoked in
/dir/2/src, make will execute "gcc -c /dir/1/src/file.c -o file.o" and
ccache will rewrite /dir/1/src/file.c to ../../2/src/file.c. With your
patch, /dir/1/src/file.c will instead be rewritten to file.c, thus in a
sense normalizing the path so that there will be a cache hit if you
later build in /dir/1/src. Is that the use case?
More information about the ccache