From: Joel Rosdahl Date: Sat, 16 Jul 2016 18:04:37 +0000 (+0200) Subject: Make calculate_object_hash handle argument-less -B etc. correctly X-Git-Tag: v3.3~67 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92a3ad68f1109bd6c97f27b4b85209e7c58b7e6f;p=thirdparty%2Fccache.git Make calculate_object_hash handle argument-less -B etc. correctly Fixes issue #112. --- diff --git a/ccache.c b/ccache.c index 2ccce62bc..21540b83d 100644 --- 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]); + } } /* diff --git a/compopt.c b/compopt.c index aef370de0..6cec29cef 100644 --- 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 d32dca3eb..ce3088814 100755 --- 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 <test.c +#include +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() {