Hi, I'm using ccache with an absolute BASEDIR. The project is compiled out-of-source. The produced elf contains relative paths, but they seem to be relative to the build directory, not the provided BASEDIR. Moreover, the compiled object contains the (absolute) build directory, even if it is inside the BASEDIR. example: mkdir -p ~/test/nest ~/test/build/foo echo 'int main() { return 0; }' > ~/test/nest/hello.c export CCACHE_BASEDIR=~/test cd ~/test/build/foo ccache g++ -c -g ~/test/nest/hello.c Inspect hello.o file. It contains: ../../nest/hello.c\0/home/user/test/build/foo This should have been "nest/hello.c\0build/foo" (not sure about the build directory though)
That's even worse. If you have 2 libraries. One is compiled with relative path ../../libs/libraryA and the other with ../../../libs/libraryB/Internal The debugger can never get it right, no matter where you run it...
Thanks for the bug report. > The project is compiled out-of-source. The produced elf contains relative > paths, but they seem to be relative to the build directory, not the provided > BASEDIR. Yes, that's by design. If paths would be rewritten to be relative to the base directory, then ccache would have to change to the base directory before running the compiler. That wouldn't work since other relative paths then can't found. > Moreover, the compiled object contains the (absolute) build directory, even > if it is inside the BASEDIR. That's a known limitation - see the documentation of the CCACHE_HASHDIR variable. Setting CCACHE_HASHDIR fixes the problem at the expense of not being able to reuse results in different build directories. > If you have 2 libraries. One is compiled with relative path ../../libs/libraryA > and the other with ../../../libs/libraryB/Internal The debugger can never get > it right, no matter where you run it... That's true. In summary: If you want to use ccache, you have to choose either "100% correct object files" (set CCACHE_HASHDIR, don't use CCACHE_BASEDIR) or "cache hits in different build directories" (use CCACHE_BASEDIR, don't set CCACHE_HASHDIR) - you can't have both.
Thanks. You may reject the bug.
OK, closing the bug.