]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Optimize when to rewrite absolute paths into relative in .d file
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 31 Mar 2019 11:22:17 +0000 (13:22 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 31 Mar 2019 11:22:17 +0000 (13:22 +0200)
As discussed in PR #366.

doc/NEWS.adoc
src/ccache.c

index 46f618dc9842e623eb808a7308245f73be6a28c6..5da73720f7b5f655a247bfae4028a446bd202db7 100644 (file)
@@ -31,6 +31,9 @@ Changes
   cache cleanup would incorrectly remove them eventually. This has now been
   fixed.
 
+* The rewriting of absolute paths into relative paths in the dependency file is
+  now enabled in the depend mode as well.
+
 
 ccache 3.6
 ----------
index afc10f86fc5da24fc5c962743d9850c0dd923b0d..c33db9c8e8215a906bf472895b489f421b38f1a2 100644 (file)
@@ -1040,7 +1040,7 @@ use_relative_paths_in_depfile(const char *depfile)
                cc_log("Base dir not set, skip using relative paths");
                return; // nothing to do
        }
-       if (!has_absolute_include_headers && !conf->depend_mode) {
+       if (!has_absolute_include_headers) {
                cc_log("No absolute path for included files found, skip using relative"
                       " paths");
                return; // nothing to do
@@ -1135,7 +1135,11 @@ object_hash_from_depfile(const char *depfile, struct hash *hash)
                        if (str_endswith(token, ":") || str_eq(token, "\\")) {
                                continue;
                        }
-                       remember_include_file(x_strdup(token), hash, false, hash);
+                       if (!has_absolute_include_headers) {
+                               has_absolute_include_headers = is_absolute_path(token);
+                       }
+                       char *path = make_relative_path(x_strdup(token));
+                       remember_include_file(path, hash, false, hash);
                }
        }
 
@@ -1467,10 +1471,6 @@ to_cache(struct args *args, struct hash *depend_mode_hash)
                failed();
        }
 
-       if (generating_dependencies) {
-               use_relative_paths_in_depfile(output_dep);
-       }
-
        if (conf->depend_mode) {
                struct file_hash *object_hash =
                        object_hash_from_depfile(output_dep, depend_mode_hash);
@@ -1480,6 +1480,10 @@ to_cache(struct args *args, struct hash *depend_mode_hash)
                update_cached_result_globals(object_hash);
        }
 
+       if (generating_dependencies) {
+               use_relative_paths_in_depfile(output_dep);
+       }
+
        if (stat(output_obj, &st) != 0) {
                cc_log("Compiler didn't produce an object file");
                stats_update(STATS_NOOUTPUT);