This results in a better out-of-the-box experience.
Closes #117.
*hash_dir* (*CCACHE_HASHDIR* or *CCACHE_NOHASHDIR*, see <<_boolean_values,Boolean values>> above)::
- If true, ccache will include the current working directory in the hash that
- is used to distinguish two compilations. This prevents a problem with the
- storage of the current working directory in the debug info of an object
- file, which can lead ccache to give a cached object file that has the
- working directory in the debug info set incorrectly. This option is off by
- default as the incorrect setting of this debug info rarely causes problems.
- If you strike problems with GDB not using the correct directory then enable
- this option. The option only applies when generating debug info (*-g*).
+ If true (which is the default), ccache will include the current working
+ directory (CWD) in the hash that is used to distinguish two compilations
+ when generating debug info (compiler option *-g* with variations).
+ Exception: The CWD will not be included in the hash if *base_dir* is set
+ (and matches the CWD) and the compiler option *-fdebug-prefix-map* is used.
+
+ The reason for including the CWD in the hash by default is to prevent a
+ problem with the storage of the current working directory in the debug info
+ of an object file, which can lead ccache to return a cached object file
+ that has the working directory in the debug info set incorrectly.
+
+ You can disable this setting to get cache hits when compiling the same
+ source code in different directories if you don't mind that CWD in the
+ debug info might be incorrect.
*ignore_headers_in_manifest* (*CCACHE_IGNOREHEADERS*)::
can't compile their own preprocessed output with the same outcome as if they
compiled the real source code directly, e.g. newer versions of GCC and Clang.
+- The configuration option `hash_dir` (`CCACHE_HASHDIR`) now defaults to true.
+
- Added support for cuda including the -optf/--options-file option.
- Added new sloppiness option `no_system_headers`, which tells ccache not to
conf->disable = false;
conf->extra_files_to_hash = x_strdup("");
conf->hard_link = false;
- conf->hash_dir = false;
+ conf->hash_dir = true;
conf->ignore_headers_in_manifest = x_strdup("");
conf->keep_comments_cpp = false;
conf->log_file = x_strdup("");
unset CCACHE_EXTENSION
unset CCACHE_EXTRAFILES
unset CCACHE_HARDLINK
- unset CCACHE_HASHDIR
unset CCACHE_IGNOREHEADERS
unset CCACHE_LOGFILE
unset CCACHE_NLEVELS
unset CCACHE_NOCPP2
+ unset CCACHE_NOHASHDIR
unset CCACHE_NOSTATS
unset CCACHE_PATH
unset CCACHE_PREFIX
expect_stat 'files in cache' 1
# -------------------------------------------------------------------------
- TEST "CCACHE_HASHDIR with -g"
+ TEST "Directory is hashed if using -g"
mkdir dir1 dir2
cp test1.c dir1
cp test1.c dir2
cd dir1
- CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c -g
+ $CCACHE_COMPILE -c test1.c -g
expect_stat 'cache hit (preprocessed)' 0
expect_stat 'cache miss' 1
- CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c -g
+ $CCACHE_COMPILE -c test1.c -g
expect_stat 'cache hit (preprocessed)' 1
expect_stat 'cache miss' 1
cd ../dir2
- CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c -g
+ $CCACHE_COMPILE -c test1.c -g
expect_stat 'cache hit (preprocessed)' 1
expect_stat 'cache miss' 2
- CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c -g
+ $CCACHE_COMPILE -c test1.c -g
expect_stat 'cache hit (preprocessed)' 2
expect_stat 'cache miss' 2
# -------------------------------------------------------------------------
- TEST "CCACHE_HASHDIR without -g"
+ TEST "Directory is not hashed if not using -g"
+
+ mkdir dir1 dir2
+ cp test1.c dir1
+ cp test1.c dir2
+
+ cd dir1
+ $CCACHE_COMPILE -c test1.c
+ expect_stat 'cache hit (preprocessed)' 0
+ expect_stat 'cache miss' 1
+ $CCACHE_COMPILE -c test1.c
+ expect_stat 'cache hit (preprocessed)' 1
+ expect_stat 'cache miss' 1
+
+ cd ../dir2
+ $CCACHE_COMPILE -c test1.c
+ expect_stat 'cache hit (preprocessed)' 2
+ expect_stat 'cache miss' 1
+
+ # -------------------------------------------------------------------------
+ TEST "CCACHE_NOHASHDIR"
mkdir dir1 dir2
cp test1.c dir1
cp test1.c dir2
cd dir1
- CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c
+ CCACHE_NOHASHDIR=1 $CCACHE_COMPILE -c test1.c -g
expect_stat 'cache hit (preprocessed)' 0
expect_stat 'cache miss' 1
- CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c
+ CCACHE_NOHASHDIR=1 $CCACHE_COMPILE -c test1.c -g
expect_stat 'cache hit (preprocessed)' 1
expect_stat 'cache miss' 1
cd ../dir2
- CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c
+ CCACHE_NOHASHDIR=1 $CCACHE_COMPILE -c test1.c -g
expect_stat 'cache hit (preprocessed)' 2
expect_stat 'cache miss' 1
TEST "Mapping of debug info CWD"
cd dir1
- CCACHE_HASHDIR=1 CCACHE_BASEDIR=`pwd` $CCACHE_COMPILE -I`pwd`/include -g -fdebug-prefix-map=`pwd`=dir -c `pwd`/src/test.c -o `pwd`/test.o
+ CCACHE_BASEDIR=`pwd` $CCACHE_COMPILE -I`pwd`/include -g -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
fi
cd ../dir2
- CCACHE_HASHDIR=1 CCACHE_BASEDIR=`pwd` $CCACHE_COMPILE -I`pwd`/include -g -fdebug-prefix-map=`pwd`=dir -c `pwd`/src/test.c -o `pwd`/test.o
+ CCACHE_BASEDIR=`pwd` $CCACHE_COMPILE -I`pwd`/include -g -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
CHECK(!conf->disable);
CHECK_STR_EQ("", conf->extra_files_to_hash);
CHECK(!conf->hard_link);
- CHECK(!conf->hash_dir);
+ CHECK(conf->hash_dir);
CHECK_STR_EQ("", conf->ignore_headers_in_manifest);
CHECK(!conf->keep_comments_cpp);
CHECK_STR_EQ("", conf->log_file);
"disable = true\n"
"extra_files_to_hash = a:b c:$USER\n"
"hard_link = true\n"
- "hash_dir = true\n"
+ "hash_dir = false\n"
"ignore_headers_in_manifest = a:b/c\n"
"keep_comments_cpp = true\n"
"log_file = $USER${USER} \n"
CHECK(conf->disable);
CHECK_STR_EQ_FREE1(format("a:b c:%s", user), conf->extra_files_to_hash);
CHECK(conf->hard_link);
- CHECK(conf->hash_dir);
+ CHECK(!conf->hash_dir);
CHECK_STR_EQ("a:b/c", conf->ignore_headers_in_manifest);
CHECK(conf->keep_comments_cpp);
CHECK_STR_EQ_FREE1(format("%s%s", user, user), conf->log_file);
true,
"efth",
true,
- true,
+ .hash_dir = false,
"ihim",
true,
"lf",
CHECK_STR_EQ("disable = true", received_conf_items[n++].descr);
CHECK_STR_EQ("extra_files_to_hash = efth", received_conf_items[n++].descr);
CHECK_STR_EQ("hard_link = true", received_conf_items[n++].descr);
- CHECK_STR_EQ("hash_dir = true", received_conf_items[n++].descr);
+ CHECK_STR_EQ("hash_dir = false", received_conf_items[n++].descr);
CHECK_STR_EQ("ignore_headers_in_manifest = ihim",
received_conf_items[n++].descr);
CHECK_STR_EQ("keep_comments_cpp = true", received_conf_items[n++].descr);