]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
handle -fprofile-use
authorChris AtLee <catlee@mozilla.com>
Wed, 20 Jul 2011 06:34:41 +0000 (02:34 -0400)
committerChris AtLee <catlee@mozilla.com>
Wed, 20 Jul 2011 06:34:41 +0000 (02:34 -0400)
ccache.c
compopt.c
test.sh

index 24820ac75cf0dcde2954104ce689df00be60cc64..a44d6b1c03a7c87aa9be85b9343ab7dfb2efff5d 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -973,6 +973,8 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
        struct stat st;
        int result;
        struct file_hash *object_hash = NULL;
+       char *gcda_name;
+       char *base_name;
 
        /* first the arguments */
        for (i = 1; i < args->argc; i++) {
@@ -1014,6 +1016,18 @@ 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 (str_eq(args->argv[i], "-fprofile-use")) {
+                       // Calculate gcda name
+                       base_name = remove_extension(output_obj);
+                       gcda_name = format("%s.gcda", base_name);
+                       free(base_name);
+                       // Add the gcda to our hash
+                       if (!hash_file(hash, gcda_name)) {
+                               // If it doesn't exist, add some null data
+                               hash_string(hash, "no data");
+                       }
+               }
        }
 
        if (direct_mode) {
index 3e63fba980c504c8135f1a6fa574b45aad464f7e..1e1500f7682597d75a6a2010df5cee124885fb2c 100644 (file)
--- a/compopt.c
+++ b/compopt.c
@@ -57,7 +57,7 @@ static const struct compopt compopts[] = {
        {"-fbranch-probabilities", TOO_HARD},
        {"-fprofile-arcs",  NEEDS_REALDIR},
        {"-fprofile-generate", NEEDS_REALDIR},
-       {"-fprofile-use",   TOO_HARD},
+       {"-fprofile-use",   NEEDS_REALDIR},
        {"-frepo",          TOO_HARD},
        {"-ftest-coverage", TOO_HARD}, /* generates a .gcno file at the same time */
        {"-idirafter",      AFFECTS_CPP | TAKES_ARG | TAKES_PATH},
diff --git a/test.sh b/test.sh
index 78e6af4cb2a50b21488c8f57d880dd5d8eb35b97..91646bc8b6beac0ab11ed6a4cc6daa5fde27031c 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -511,12 +511,12 @@ EOF
     testname="profile-use"
     $CCACHE_COMPILE -c -fprofile-use test1.c 2> /dev/null
     checkstat 'cache hit (preprocessed)' 2
-    checkstat 'cache miss' 2
-    checkstat 'files in cache' 2
+    checkstat 'cache miss' 3
+    checkstat 'files in cache' 4
     $CCACHE_COMPILE -c -fprofile-use test1.c 2> /dev/null
-    checkstat 'cache hit (preprocessed)' 2
-    checkstat 'cache miss' 2
-    checkstat 'files in cache' 2
+    checkstat 'cache hit (preprocessed)' 3
+    checkstat 'cache miss' 3
+    checkstat 'files in cache' 4
 
     rm -f test1.c
 }