Fixes #356.
* Fixed an issue when printing very large log messages to the debug log.
+* Fixed a bug where ccache did not turn on `hash_dir` correctly when using
+ `-gsplit-dwarf`, leading to potentially incorrect file links in debug
+ information when compiling in different directories.
+
ccache 3.6
----------
continue;
}
- if (str_eq(argv[i], "-gsplit-dwarf")) {
- cc_log("Enabling caching of dwarf files since -gsplit-dwarf is used");
- using_split_dwarf = true;
- args_add(stripped_args, argv[i]);
- continue;
- }
if (str_startswith(argv[i], "-fdebug-prefix-map=")
|| str_startswith(argv[i], "-ffile-prefix-map=")) {
debug_prefix_maps = x_realloc(
if (str_startswith(argv[i], "-g")) {
generating_debuginfo = true;
args_add(stripped_args, argv[i]);
+ if (str_eq(argv[i], "-gsplit-dwarf")) {
+ using_split_dwarf = true;
+ }
if (conf->unify && !str_eq(argv[i], "-g0")) {
cc_log("%s used; disabling unify mode", argv[i]);
conf->unify = false;
expect_stat 'cache hit (preprocessed)' 2
expect_stat 'cache miss' 1
+ # -------------------------------------------------------------------------
+ TEST "Directory is hashed if using -gsplit-dwarf"
+
+ mkdir dir1 dir2
+ cp test1.c dir1
+ cp test1.c dir2
+
+ export CCACHE_DEBUG=1
+
+ cd dir1
+ $CCACHE_COMPILE -c test1.c -gsplit-dwarf
+ expect_stat 'cache hit (preprocessed)' 0
+ expect_stat 'cache miss' 1
+ $CCACHE_COMPILE -c test1.c -gsplit-dwarf
+ expect_stat 'cache hit (preprocessed)' 1
+ expect_stat 'cache miss' 1
+
+ cd ../dir2
+ $CCACHE_COMPILE -c test1.c -gsplit-dwarf
+ expect_stat 'cache hit (preprocessed)' 1
+ expect_stat 'cache miss' 2
+ $CCACHE_COMPILE -c test1.c -gsplit-dwarf
+ expect_stat 'cache hit (preprocessed)' 2
+ expect_stat 'cache miss' 2
+
# -------------------------------------------------------------------------
TEST "CCACHE_NOHASHDIR"
if objdump_cmd test.o | grep_cmd "`pwd`" >/dev/null 2>&1; then
test_failed "Source dir (`pwd`) found in test.o"
fi
+
+ # -------------------------------------------------------------------------
+ TEST "-fdebug-prefix-map and -gsplit-dwarf"
+
+ cd dir1
+ CCACHE_BASEDIR=`pwd` $CCACHE_COMPILE -I`pwd`/include -gsplit-dwarf -fdebug-prefix-map=`pwd`=dir -c `pwd`/src/test.c -o `pwd`/test.o
+ expect_stat 'cache hit (direct)' 0
+ expect_stat 'cache hit (preprocessed)' 0
+ expect_stat 'cache miss' 1
+ expect_stat 'files in cache' 3
+ if objdump_cmd test.o | grep_cmd "`pwd`" >/dev/null 2>&1; then
+ test_failed "Source dir (`pwd`) found in test.o"
+ fi
+
+ cd ../dir2
+ CCACHE_BASEDIR=`pwd` $CCACHE_COMPILE -I`pwd`/include -gsplit-dwarf -fdebug-prefix-map=`pwd`=dir -c `pwd`/src/test.c -o `pwd`/test.o
+ expect_stat 'cache hit (direct)' 1
+ expect_stat 'cache hit (preprocessed)' 0
+ expect_stat 'cache miss' 1
+ expect_stat 'files in cache' 3
+ if objdump_cmd test.o | grep_cmd "`pwd`" >/dev/null 2>&1; then
+ test_failed "Source dir (`pwd`) found in test.o"
+ fi
}