]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Handle bug where clang doesn't unlink output file (#335)
authorAnders Björklund <anders.f.bjorklund@gmail.com>
Mon, 3 Dec 2018 20:04:35 +0000 (21:04 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 3 Dec 2018 20:04:35 +0000 (21:04 +0100)
When using assembler, clang doesn't unlink output.

On the other hand, gcc seems to handle this fine.

Closes #331

src/ccache.c
test/suites/hardlink.bash

index bed4e3c65f42da59cefff8e2320cfcf40b59a4b8..5eff8474c911278432cb6b754e230f0a67e51c72 100644 (file)
@@ -1245,6 +1245,9 @@ to_cache(struct args *args)
        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 f4f969e3cfdeb74f023230adb55950e945cc9e0a..bc93018572520a40c92b782d7edc721c7cb248c7 100644 (file)
@@ -30,4 +30,34 @@ SUITE_hardlink() {
     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
 }