From: Geert Kloosterman Date: Wed, 4 Apr 2018 20:49:14 +0000 (+0200) Subject: Put "calculate preprocessor hash" code into "if" block X-Git-Tag: v3.6~31^2~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b0e3ead43fafdc35eb99d16f33dd39ed6ac8048b;p=thirdparty%2Fccache.git Put "calculate preprocessor hash" code into "if" block 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. --- diff --git a/src/ccache.c b/src/ccache.c index 49f4c3c22..3616df697 100644 --- a/src/ccache.c +++ b/src/ccache.c @@ -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");