]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Remove the hard link mode
authorJoel Rosdahl <joel@rosdahl.net>
Thu, 6 Jun 2019 18:10:10 +0000 (20:10 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 6 Jun 2019 18:10:10 +0000 (20:10 +0200)
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.

doc/MANUAL.adoc
misc/performance
src/ccache.c
src/conf.c
src/conf.h
src/confitems.gperf
src/envtoconfitems.gperf
test/run
test/suites/hardlink.bash [deleted file]
unittest/test_conf.c

index 20f048b17cb0ef553b24997b62fcf31b74e82d2b..600d3c0dfc13572006a393cbb34884356e710547 100644 (file)
@@ -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.
 
index 7c57be7ffbf4271f5eb99c870f03fd45b484ee4f..8281f90ab0b5cdaef95a5dd975079748d92e4af0 100755 (executable)
@@ -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())
index e0288d9529795d216fa61f82a4e79d118e6386f7..d4d1e5ffae0a37eb051f77439e9469af5d12333b 100644 (file)
@@ -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);
index 30aa4a40fcb161bf642a56bc1a9b8f43f024ad1a..93f62a9f31ae84d07fc1a7ce4d4c2c8bd1059431 100644 (file)
@@ -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);
index 52a48c8e796ae046ed2af3071dc0752f10315724..6e6b4d8ccd2949389cb51a240b59a8302c73daaf 100644 (file)
@@ -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;
index 828e62eb3f4a566e6ff8a756735137060aeba8c4..d229d2ca1256137b499a9bc991934a13d4219067 100644 (file)
@@ -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)
index 374d19c5d3f16653b9bdbb799d594dda6a19f959..086cae6818823f68b3bd83637a1d6722d02bb1fd 100644 (file)
@@ -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"
index f81040932faa5b5d6a98c9a201f630ccd140858f..2e1347e3ad1d95f47875574da8c9e214ce8f7918 100755 (executable)
--- 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 (file)
index 388bd1f..0000000
+++ /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"
-
-}
index 9ef6708574256294e625b8d2f1260f73b12c4c3d..393246b15e3b21928b1feba50bc9a9f82f6e9568 100644 (file)
@@ -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);