]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Make calculate_object_hash handle argument-less -B etc. correctly
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 16 Jul 2016 18:04:37 +0000 (20:04 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 16 Jul 2016 18:06:15 +0000 (20:06 +0200)
Fixes issue #112.

ccache.c
compopt.c
test.sh

index 2ccce62bcbec75a9612f71a30517dfcf0810dbed..21540b83decb44958545c4367054535d2cc9d879 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -1821,6 +1821,11 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
                /* All other arguments are included in the hash. */
                hash_delimiter(hash, "arg");
                hash_string(hash, args->argv[i]);
+               if (i + 1 < args->argc && compopt_takes_arg(args->argv[i])) {
+                       i++;
+                       hash_delimiter(hash, "arg");
+                       hash_string(hash, args->argv[i]);
+               }
        }
 
        /*
index aef370de06f2b2cd4d7262dd5e42344ad567c244..6cec29cefa195138c460c9b32f46d40bd1ba7dcc 100644 (file)
--- a/compopt.c
+++ b/compopt.c
@@ -36,6 +36,7 @@ static const struct compopt compopts[] = {
        {"--save-temps",    TOO_HARD},
        {"--serialize-diagnostics", TAKES_ARG | TAKES_PATH},
        {"-A",              TAKES_ARG},
+       {"-B",              TAKES_ARG | TAKES_CONCAT_ARG},
        {"-D",              AFFECTS_CPP | TAKES_ARG | TAKES_CONCAT_ARG},
        {"-E",              TOO_HARD},
        {"-F",              AFFECTS_CPP | TAKES_ARG | TAKES_CONCAT_ARG | TAKES_PATH},
diff --git a/test.sh b/test.sh
index d32dca3ebcadfd4857d854d2aaa0dc78cdc76806..ce30888143c823386d14b6b42c31c8c3dceb540b 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -1551,6 +1551,27 @@ EOF
     else
         test_failed "unexpected output of --dump-manifest"
     fi
+
+    ##################################################################
+    testname="argument-less -B and -L"
+    $CCACHE -Cz > /dev/null
+    cat <<EOF >test.c
+#include <stdio.h>
+int main(void)
+{
+#ifdef FOO
+    puts("FOO");
+#endif
+    return 0;
+}
+EOF
+
+    $CCACHE $COMPILER -A -L -DFOO -c test.c
+    checkstat 'cache hit (direct)' 0
+    checkstat 'cache miss' 1
+    $CCACHE $COMPILER -A -L -DBAR -c test.c
+    checkstat 'cache hit (direct)' 0
+    checkstat 'cache miss' 2
 }
 
 basedir_suite() {