]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Put "calculate preprocessor hash" code into "if" block
authorGeert Kloosterman <geert.kloosterman@brightcomputing.com>
Wed, 4 Apr 2018 20:49:14 +0000 (22:49 +0200)
committerGeert Kloosterman <geert.kloosterman@brightcomputing.com>
Wed, 4 Apr 2018 20:49:14 +0000 (22:49 +0200)
In a following commit we will execute this code conditionally.

Even though the change is simple, the diff looks rather ugly (unless
when ignoring whitespace differences).  Having this step as a separate
commit should make the following commit more clear.

Chose to not factor it out into a separate function because of the
amount of local variables referenced.

src/ccache.c

index 49f4c3c229d2ed5f0d9cc73afd2b58440b7f5692..3616df69750c3b67851172e587b486c8a732960a 100644 (file)
@@ -3376,38 +3376,40 @@ ccache(int argc, char *argv[])
                failed();
        }
 
-       // Find the hash using the preprocessed output. Also updates included_files.
-       struct mdfour cpp_hash = common_hash;
-       object_hash = calculate_object_hash(preprocessor_args, &cpp_hash, 0);
-       if (!object_hash) {
-               fatal("internal error: object hash from cpp returned NULL");
-       }
-       update_cached_result_globals(object_hash);
-
-       if (object_hash_from_manifest
-           && !file_hashes_equal(object_hash_from_manifest, object_hash)) {
-               // The hash from manifest differs from the hash of the preprocessor output.
-               // This could be because:
-               //
-               // - The preprocessor produces different output for the same input (not
-               //   likely).
-               // - There's a bug in ccache (maybe incorrect handling of compiler
-               //   arguments).
-               // - The user has used a different CCACHE_BASEDIR (most likely).
-               //
-               // The best thing here would probably be to remove the hash entry from the
-               // manifest. For now, we use a simpler method: just remove the manifest
-               // file.
-               cc_log("Hash from manifest doesn't match preprocessor output");
-               cc_log("Likely reason: different CCACHE_BASEDIRs used");
-               cc_log("Removing manifest as a safety measure");
-               x_unlink(manifest_path);
+       if (1) {
+               // Find the hash using the preprocessed output. Also updates included_files.
+               struct mdfour cpp_hash = common_hash;
+               object_hash = calculate_object_hash(preprocessor_args, &cpp_hash, 0);
+               if (!object_hash) {
+                       fatal("internal error: object hash from cpp returned NULL");
+               }
+               update_cached_result_globals(object_hash);
+
+               if (object_hash_from_manifest
+                   && !file_hashes_equal(object_hash_from_manifest, object_hash)) {
+                       // The hash from manifest differs from the hash of the preprocessor output.
+                       // This could be because:
+                       //
+                       // - The preprocessor produces different output for the same input (not
+                       //   likely).
+                       // - There's a bug in ccache (maybe incorrect handling of compiler
+                       //   arguments).
+                       // - The user has used a different CCACHE_BASEDIR (most likely).
+                       //
+                       // The best thing here would probably be to remove the hash entry from the
+                       // manifest. For now, we use a simpler method: just remove the manifest
+                       // file.
+                       cc_log("Hash from manifest doesn't match preprocessor output");
+                       cc_log("Likely reason: different CCACHE_BASEDIRs used");
+                       cc_log("Removing manifest as a safety measure");
+                       x_unlink(manifest_path);
 
-               put_object_in_manifest = true;
-       }
+                       put_object_in_manifest = true;
+               }
 
-       // If we can return from cache at this point then do.
-       from_cache(FROMCACHE_CPP_MODE, put_object_in_manifest);
+               // If we can return from cache at this point then do.
+               from_cache(FROMCACHE_CPP_MODE, put_object_in_manifest);
+       }
 
        if (conf->read_only) {
                cc_log("Read-only mode; running real compiler");