From: Joel Rosdahl Date: Thu, 6 Jun 2019 18:10:10 +0000 (+0200) Subject: Remove the hard link mode X-Git-Tag: v4.0~950 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=a1dbb8a15e034e5a63eb6b4407c9e3ccac469162;p=thirdparty%2Fccache.git Remove the hard link mode Rationale: * The hard link feature is prone to errors: a) changes to files outside the cache will corrupt the cache, and b) the mtime field in the file's i-node is used for different purposes by ccache and build tools like make. * The upcoming enabling of LZ4 compression by default will make the hard link mode obsolete as a means of saving cache space. * Not supporting hard links will make a future backend storage API simpler. --- diff --git a/doc/MANUAL.adoc b/doc/MANUAL.adoc index 20f048b17..600d3c0df 100644 --- a/doc/MANUAL.adoc +++ b/doc/MANUAL.adoc @@ -400,27 +400,6 @@ WRAPPERS>>. the hash sum that identifies the build. The list separator is semicolon on Windows systems and colon on other systems. -*hard_link* (*CCACHE_HARDLINK* or *CCACHE_NOHARDLINK*, see <<_boolean_values,Boolean values>> above):: - - If true, ccache will attempt to use hard links from the cache directory - when creating the compiler output rather than using a file copy. Hard links - are never made for compressed cache files. This means that you should not - enable compression if you want to use hard links. The default is false. -+ -WARNING: Do not enable this option unless you are aware of the consequences. -Using hard links may be slightly faster in some situations, but there are -several pitfalls since the resulting object file will share i-node with the -cached object file: -+ -1. If the resulting object file is modified in any way, the cached object file - will be modified as well. For instance, if you run `strip object.o` or `echo - >object.o`, you will corrupt the cache. -2. Programs that rely on modification times (like ``make'') can be confused - since ccache updates the cached files' modification times as part of the - automatic cache size management. This will affect object files in the build - tree as well, which can retrigger the linking step even though nothing - really has changed. - *hash_dir* (*CCACHE_HASHDIR* or *CCACHE_NOHASHDIR*, see <<_boolean_values,Boolean values>> above):: If true (which is the default), ccache will include the current working @@ -1084,8 +1063,6 @@ directory. To share a cache without unpleasant side effects, the following conditions should to be met: * Use the same cache directory. -* Make sure that the configuration setting *hard_link* is false (which is the - default). * Make sure that all users are in the same group. * Set the configuration setting *umask* to 002. This ensures that cached files are accessible to everyone in the group. @@ -1101,13 +1078,6 @@ find $CCACHE_DIR -type d | xargs chmod g+s ---- -- -The reason to avoid the hard link mode is that the hard links cause unwanted -side effects, as all links to a cached file share the file's modification -timestamp. This results in false dependencies to be triggered by -timestamp-based build systems whenever another user links to an existing file. -Typically, users will see that their libraries and binaries are relinked -without reason. - You may also want to make sure that a base directory is set appropriately, as discussed in a previous section. diff --git a/misc/performance b/misc/performance index 7c57be7ff..8281f90ab 100755 --- a/misc/performance +++ b/misc/performance @@ -99,8 +99,6 @@ def test(tmp_dir, options, compiler_args, source_file): environment["CCACHE_COMPILERCHECK"] = options.compilercheck if options.compression: environment["CCACHE_COMPRESS"] = "1" - if options.hardlink: - environment["CCACHE_HARDLINK"] = "1" if options.nostats: environment["CCACHE_NOSTATS"] = "1" @@ -261,7 +259,6 @@ def main(argv): " files (default: %s)" % DEFAULT_DIRECTORY ), ) - op.add_option("--hardlink", help="use hard links", action="store_true") op.add_option( "--hit-factor", help=( @@ -317,7 +314,6 @@ def main(argv): ) print("Compilercheck:", options.compilercheck) print("Compression:", on_off(options.compression)) - print("Hardlink:", on_off(options.hardlink)) print("Nostats:", on_off(options.nostats)) tmp_dir = "%s/perfdir.%d" % (abspath(options.directory), getpid()) diff --git a/src/ccache.c b/src/ccache.c index e0288d952..d4d1e5ffa 100644 --- a/src/ccache.c +++ b/src/ccache.c @@ -1221,10 +1221,6 @@ to_cache(struct args *args, struct hash *depend_mode_hash) args_add(args, "-o"); args_add(args, output_obj); - if (conf->hard_link) { - x_unlink(output_obj); - } - if (generating_diagnostics) { args_add(args, "--serialize-diagnostics"); args_add(args, output_dia); diff --git a/src/conf.c b/src/conf.c index 30aa4a40f..93f62a9f3 100644 --- a/src/conf.c +++ b/src/conf.c @@ -140,7 +140,6 @@ conf_create(void) conf->direct_mode = true; conf->disable = false; conf->extra_files_to_hash = x_strdup(""); - conf->hard_link = false; conf->hash_dir = true; conf->ignore_headers_in_manifest = x_strdup(""); conf->keep_comments_cpp = false; @@ -403,7 +402,6 @@ conf_print_items(struct conf *conf, ok &= print_item(conf, "direct_mode", printer, context); ok &= print_item(conf, "disable", printer, context); ok &= print_item(conf, "extra_files_to_hash", printer, context); - ok &= print_item(conf, "hard_link", printer, context); ok &= print_item(conf, "hash_dir", printer, context); ok &= print_item(conf, "ignore_headers_in_manifest", printer, context); ok &= print_item(conf, "keep_comments_cpp", printer, context); diff --git a/src/conf.h b/src/conf.h index 52a48c8e7..6e6b4d8cc 100644 --- a/src/conf.h +++ b/src/conf.h @@ -17,7 +17,6 @@ struct conf { bool direct_mode; bool disable; char *extra_files_to_hash; - bool hard_link; bool hash_dir; char *ignore_headers_in_manifest; bool keep_comments_cpp; diff --git a/src/confitems.gperf b/src/confitems.gperf index 828e62eb3..d229d2ca1 100644 --- a/src/confitems.gperf +++ b/src/confitems.gperf @@ -33,7 +33,6 @@ depend_mode, ITEM(depend_mode, bool) direct_mode, ITEM(direct_mode, bool) disable, ITEM(disable, bool) extra_files_to_hash, ITEM(extra_files_to_hash, env_string) -hard_link, ITEM(hard_link, bool) hash_dir, ITEM(hash_dir, bool) ignore_headers_in_manifest, ITEM(ignore_headers_in_manifest, env_string) keep_comments_cpp, ITEM(keep_comments_cpp, bool) diff --git a/src/envtoconfitems.gperf b/src/envtoconfitems.gperf index 374d19c5d..086cae681 100644 --- a/src/envtoconfitems.gperf +++ b/src/envtoconfitems.gperf @@ -26,7 +26,6 @@ DIRECT, "direct_mode" DISABLE, "disable" EXTENSION, "cpp_extension" EXTRAFILES, "extra_files_to_hash" -HARDLINK, "hard_link" HASHDIR, "hash_dir" IGNOREHEADERS, "ignore_headers_in_manifest" LIMIT_MULTIPLE, "limit_multiple" diff --git a/test/run b/test/run index f81040932..2e1347e3a 100755 --- a/test/run +++ b/test/run @@ -392,7 +392,6 @@ sanitize_blacklist debug_prefix_map split_dwarf masquerading -hardlink direct direct_gcc depend diff --git a/test/suites/hardlink.bash b/test/suites/hardlink.bash deleted file mode 100644 index 388bd1f9d..000000000 --- a/test/suites/hardlink.bash +++ /dev/null @@ -1,79 +0,0 @@ -SUITE_hardlink_PROBE() { - touch file1 - if ! ln file1 file2 >/dev/null 2>&1; then - echo "file system doesn't support hardlinks" - fi -} - -SUITE_hardlink() { - # ------------------------------------------------------------------------- - TEST "CCACHE_HARDLINK" - - generate_code 1 test1.c - - $REAL_COMPILER -c -o reference_test1.o test1.c - - $CCACHE_COMPILE -c test1.c - expect_stat 'cache hit (preprocessed)' 0 - expect_stat 'cache miss' 1 - expect_stat 'files in cache' 1 - expect_equal_object_files reference_test1.o test1.o - - CCACHE_HARDLINK=1 $CCACHE_COMPILE -c test1.c - expect_stat 'cache hit (preprocessed)' 1 - expect_stat 'cache miss' 1 - expect_stat 'files in cache' 1 - expect_equal_object_files reference_test1.o test1.o - - local obj_in_cache - obj_in_cache=$(find $CCACHE_DIR -name '*.o') - if [ ! $obj_in_cache -ef test1.o ]; then - test_failed "Object file not hard-linked to cached object file" - fi - - # ------------------------------------------------------------------------- - TEST "Overwrite assembler" - - generate_code 1 test1.c - $REAL_COMPILER -S -o test1.s test1.c - - $REAL_COMPILER -c -o reference_test1.o test1.s - - CCACHE_HARDLINK=1 $CCACHE_COMPILE -c test1.s - expect_stat 'cache hit (preprocessed)' 0 - expect_stat 'cache miss' 1 - expect_stat 'files in cache' 1 - - generate_code 2 test1.c - $REAL_COMPILER -S -o test1.s test1.c - - CCACHE_HARDLINK=1 $CCACHE_COMPILE -c test1.s - expect_stat 'cache hit (preprocessed)' 0 - expect_stat 'cache miss' 2 - expect_stat 'files in cache' 2 - - generate_code 1 test1.c - $REAL_COMPILER -S -o test1.s test1.c - - CCACHE_HARDLINK=1 $CCACHE_COMPILE -c test1.s - expect_stat 'cache hit (preprocessed)' 1 - expect_stat 'cache miss' 2 - expect_stat 'files in cache' 2 - expect_equal_object_files reference_test1.o test1.o - - # ------------------------------------------------------------------------- - TEST "Automake depend move" - - unset CCACHE_NODIRECT - - generate_code 1 test1.c - - CCACHE_HARDLINK=1 CCACHE_DEPEND=1 $CCACHE_COMPILE -c -MMD -MF test1.d.tmp test1.c - expect_stat 'cache hit (direct)' 0 - mv test1.d.tmp test1.d || test_failed "first mv failed" - - CCACHE_HARDLINK=1 CCACHE_DEPEND=1 $CCACHE_COMPILE -c -MMD -MF test1.d.tmp test1.c - expect_stat 'cache hit (direct)' 1 - mv test1.d.tmp test1.d || test_failed "second mv failed" - -} diff --git a/unittest/test_conf.c b/unittest/test_conf.c index 9ef670857..393246b15 100644 --- a/unittest/test_conf.c +++ b/unittest/test_conf.c @@ -18,7 +18,7 @@ #include "framework.h" #include "util.h" -#define N_CONFIG_ITEMS 34 +#define N_CONFIG_ITEMS 33 static struct { char *descr; char *origin; @@ -63,7 +63,6 @@ TEST(conf_create) CHECK(conf->direct_mode); CHECK(!conf->disable); CHECK_STR_EQ("", conf->extra_files_to_hash); - CHECK(!conf->hard_link); CHECK(conf->hash_dir); CHECK_STR_EQ("", conf->ignore_headers_in_manifest); CHECK(!conf->keep_comments_cpp); @@ -116,7 +115,6 @@ TEST(conf_read_valid_config) "direct_mode = false\n" "disable = true\n" "extra_files_to_hash = a:b c:$USER\n" - "hard_link = true\n" "hash_dir = false\n" "ignore_headers_in_manifest = a:b/c\n" "keep_comments_cpp = true\n" @@ -156,7 +154,6 @@ TEST(conf_read_valid_config) CHECK(!conf->direct_mode); 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_STR_EQ("a:b/c", conf->ignore_headers_in_manifest); CHECK(conf->keep_comments_cpp); @@ -465,7 +462,6 @@ TEST(conf_print_items) false, true, "efth", - true, .hash_dir = false, "ihim", true, @@ -517,7 +513,6 @@ TEST(conf_print_items) CHECK_STR_EQ("direct_mode = false", received_conf_items[n++].descr); 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 = false", received_conf_items[n++].descr); CHECK_STR_EQ("ignore_headers_in_manifest = ihim", received_conf_items[n++].descr);