Bug 9731 - BASEDIR problem
BASEDIR problem
Status: RESOLVED INVALID
Product: ccache
Classification: Unclassified
Component: ccache
dev
All Linux
: P5 normal
: ---
Assigned To: Joel Rosdahl
Joel Rosdahl
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-03-21 09:13 UTC by Orgad Shaneh
Modified: 2013-05-09 12:58 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Orgad Shaneh 2013-03-21 09:13:22 UTC
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)
Comment 1 Orgad Shaneh 2013-03-21 14:43:56 UTC
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...
Comment 2 Joel Rosdahl 2013-03-24 10:49:22 UTC
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.
Comment 3 Orgad Shaneh 2013-05-09 06:25:36 UTC
Thanks. You may reject the bug.
Comment 4 Joel Rosdahl 2013-05-09 12:58:10 UTC
OK, closing the bug.