From 737bb19415504c51293d8f18781e1851749195bc Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Fri, 10 Aug 2018 13:25:17 +0200 Subject: =?UTF-8?q?Improve=20printing=20of=20=E2=80=9Cstats=20zeroed?= =?UTF-8?q?=E2=80=9D=20statistics?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Refactored how formatting functions work in “ccache -s” output. They now return a formatted string (or NULL for “don’t print statistics line at all”) instead of printing the value. * Added a new format_timestamp function. * Added STATS_ZEROTIMESTAMP to the common stats_info array instead of being a special case. * Let the STATS_ZEROTIMESTAMP value be 0 for new caches so that the “stats zeroed” statistics line only shows up when “ccache -z” actually has been called. Closes #285. --- src/ccache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ccache.c') diff --git a/src/ccache.c b/src/ccache.c index ed432ee5..4597ccdd 100644 --- a/src/ccache.c +++ b/src/ccache.c @@ -3568,7 +3568,7 @@ ccache_main_options(int argc, char *argv[]) case 'z': // --zero-stats initialize(); stats_zero(); - printf("Statistics cleared\n"); + printf("Statistics zeroed\n"); break; default: -- cgit v1.2.1 From 284e3a0c66193639171ff2a6ec4ff00a4a90dea9 Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Fri, 10 Aug 2018 21:13:03 +0200 Subject: =?UTF-8?q?Add=20missing=20delimiter=20when=20hashing=20=E2=80=9C-?= =?UTF-8?q?MF=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ccache.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/ccache.c') diff --git a/src/ccache.c b/src/ccache.c index 4597ccdd..1f1faa0c 100644 --- a/src/ccache.c +++ b/src/ccache.c @@ -1768,6 +1768,7 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode) } } else if (str_startswith(args->argv[i], "-MF")) { // In either case, hash the "-MF" part. + hash_delimiter(hash, "arg"); hash_string_length(hash, args->argv[i], 3); bool separate_argument = (strlen(args->argv[i]) == 3); -- cgit v1.2.1 From 7c8597121bee2e885e7cd740a18aeecd73504bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Tue, 12 Jun 2018 23:11:44 +0200 Subject: Compiler "cc" might still be the same as "clang" It migt also be "gcc", but try to play it safe. --- src/ccache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ccache.c') diff --git a/src/ccache.c b/src/ccache.c index 1f1faa0c..5cff0b77 100644 --- a/src/ccache.c +++ b/src/ccache.c @@ -1711,7 +1711,7 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode) // clang will emit warnings for unused linker flags, so we shouldn't skip // those arguments. - int is_clang = guessed_compiler == GUESSED_CLANG; + int is_clang = (guessed_compiler == GUESSED_CLANG || guessed_compiler == GUESSED_UNKNOWN); // First the arguments. for (int i = 1; i < args->argc; i++) { @@ -1970,7 +1970,7 @@ from_cache(enum fromcache_call_mode mode, bool put_object_in_manifest) // // file 'foo.h' has been modified since the precompiled header 'foo.pch' // was built - if (guessed_compiler == GUESSED_CLANG + if ((guessed_compiler == GUESSED_CLANG || guessed_compiler == GUESSED_UNKNOWN) && output_is_precompiled_header && mode == FROMCACHE_CPP_MODE) { cc_log("Not considering cached precompiled header in preprocessor mode"); -- cgit v1.2.1 From 42f125eb5215d3bcc2b0833a2e681670abcbf714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Tue, 3 Jul 2018 18:54:34 +0200 Subject: Add handling of separate -target parameter Otherwise you will get an error in the log: "x86_64-pc-linux-gnu is not a regular file, not considering as input file" The argument seems to be specific to clang. --- src/ccache.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/ccache.c') diff --git a/src/ccache.c b/src/ccache.c index 848eecbb..909a7419 100644 --- a/src/ccache.c +++ b/src/ccache.c @@ -2511,6 +2511,19 @@ cc_process_args(struct args *args, struct args **preprocessor_args, free(relpath); continue; } + // Alternate form of specifying target without = + if (str_eq(argv[i], "-target")) { + if (i == argc-1) { + cc_log("Missing argument to %s", argv[i]); + stats_update(STATS_ARGS); + result = false; + goto out; + } + args_add(stripped_args, argv[i]); + args_add(stripped_args, argv[i+1]); + i++; + continue; + } if (str_startswith(argv[i], "-Wp,")) { if (str_eq(argv[i], "-Wp,-P") || strstr(argv[i], ",-P,") -- cgit v1.2.1 From dde3543c6a556909c8c2092e6fbfcc14d9f5f5ac Mon Sep 17 00:00:00 2001 From: Mike Gulick Date: Tue, 24 Jul 2018 15:23:03 -0400 Subject: process_preprocessed_file: Move gnu_getcwd() out of tight loop Change process_preprocessed_file from calling getcwd() once per line in the preprocessed source file to once at the start of the function. The performance of getcwd() on Mac seems to be terrible compared to Linux. On a macOS 10.13 build machine, this change improves process_preprocessed_file runtime on a 10MB preprocessed file from 75 seconds to .75 seconds. --- src/ccache.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/ccache.c') diff --git a/src/ccache.c b/src/ccache.c index 7a094e95..e3b8886f 100644 --- a/src/ccache.c +++ b/src/ccache.c @@ -781,6 +781,11 @@ process_preprocessed_file(struct mdfour *hash, const char *path, bool pump) included_files = create_hashtable(1000, hash_from_string, strings_equal); } + char *cwd = NULL; + if (!conf->hash_dir) { + cwd = gnu_getcwd(); + } + // Bytes between p and q are pending to be hashed. char *p = data; char *q = data; @@ -880,7 +885,6 @@ process_preprocessed_file(struct mdfour *hash, const char *path, bool pump) bool should_hash_inc_path = true; if (!conf->hash_dir) { - char *cwd = gnu_getcwd(); if (str_startswith(inc_path, cwd) && str_endswith(inc_path, "//")) { // When compiling with -g or similar, GCC adds the absolute path to // CWD like this: @@ -891,7 +895,6 @@ process_preprocessed_file(struct mdfour *hash, const char *path, bool pump) // hash it. See also how debug_prefix_map is handled. should_hash_inc_path = false; } - free(cwd); } if (should_hash_inc_path) { hash_string(hash, inc_path); @@ -928,6 +931,7 @@ process_preprocessed_file(struct mdfour *hash, const char *path, bool pump) hash_buffer(hash, p, (end - p)); free(data); + free(cwd); // Explicitly check the .gch/.pch/.pth file, Clang does not include any // mention of it in the preprocessed output. -- cgit v1.2.1 From 6bf4382fefc32ee0c213a2e1671ea3fc6311c70a Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Sun, 19 Aug 2018 08:50:19 +0200 Subject: =?UTF-8?q?Fix=20=E2=80=9Cclang=20analyze=E2=80=9D=20false=20posit?= =?UTF-8?q?ive?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ccache.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/ccache.c') diff --git a/src/ccache.c b/src/ccache.c index e3b8886f..f363e948 100644 --- a/src/ccache.c +++ b/src/ccache.c @@ -781,10 +781,7 @@ process_preprocessed_file(struct mdfour *hash, const char *path, bool pump) included_files = create_hashtable(1000, hash_from_string, strings_equal); } - char *cwd = NULL; - if (!conf->hash_dir) { - cwd = gnu_getcwd(); - } + char *cwd = gnu_getcwd(); // Bytes between p and q are pending to be hashed. char *p = data; -- cgit v1.2.1 From 6f165666746cff8a8feb833a9686c45c9f8fc055 Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Sun, 19 Aug 2018 08:52:07 +0200 Subject: Fix minor memory leak introduced in dde3543c --- src/ccache.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/ccache.c') diff --git a/src/ccache.c b/src/ccache.c index f363e948..1fc04d3f 100644 --- a/src/ccache.c +++ b/src/ccache.c @@ -856,6 +856,7 @@ process_preprocessed_file(struct mdfour *hash, const char *path, bool pump) if (q >= end) { cc_log("Failed to parse included file path"); free(data); + free(cwd); return false; } // q points to the beginning of an include file path -- cgit v1.2.1