MacOSX: cache losing clang/llvm debug symbols with separate compilation…

Apparently, ccache loses debug symbols on Mavericks with clang/lldb. Here is a session illustrating the problem. I spent quite a bit of time figuring out that ccache was the culprit, so I thought I'd share also on the clang and LLVM mailing lists in case someone else runs into this.

Here is a session illustrating the issue (same issue with C and C++ source files):

% cat glop.cpp
#include <iostream>

int main()
{
    std::cerr << "Hello World\n";
}
% c++ -g glop.cpp -o glop
% lldb glop
Current executable set to 'glop' (x86_64).
(lldb) b glop.cpp:5
Breakpoint 1: where = glop`main + 22 at glop.cpp:5, address = 0x00000001000011e6
(lldb) exit

# So far so good. But with separate compilation, it breaks:

% c++ -g -c glop.cpp -o glop.o
% c++ -g glop.o -o glop
% lldb glop
Current executable set to 'glop' (x86_64).
(lldb) b main.cpp:5
Breakpoint 1: no locations (pending).
WARNING: Unable to resolve breakpoint to any actual locations.
(lldb) exit

% c++ --version
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.3.0
Thread model: posix
% uname -a
Darwin somemachine.local 13.3.0 Darwin Kernel Version 13.3.0: Tue Jun 3 21:27:35 PDT 2014; root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64
% ccache --version
ccache version 3.1.9

My ccache is from MacPorts. It seems to be the latest as of today.

Thanks for your help.
Christophe

Christophe de Dinechin <christophe.de.dinechin@gmail.com> writes:

Apparently, ccache loses debug symbols on Mavericks with clang/lldb. Here is a session illustrating the problem. I spent quite a bit of time figuring out that ccache was the culprit, so I thought I'd share also on the clang and LLVM mailing lists in case someone else runs into this.

FWIW, ccache and lldb seem to play together nicely for me, so I guess
there's some other contributing factor in your case. I'm using:

OSX 10.9.4
lldb 310.2.37 (from Xcode 5.1.1)
self-compiled ccache 3.1.9

      regards, tom lane