]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Use apparent CWD when checking for CWD in preprocessed output
authorJoel Rosdahl <joel@rosdahl.net>
Fri, 7 Feb 2020 22:15:42 +0000 (23:15 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Fri, 7 Feb 2020 22:18:32 +0000 (23:18 +0100)
Also when checking debug prefix maps.

This fixes a problem when $PWD includes a symlink part and the user has
set “hash_dir = false”.

Closes #531.

(cherry picked from commit 92145eb0762109b5f0114a6f4de2fea7d4ac016f)

src/ccache.cpp
test/run

index 969f0befcb4f91f112dc8b687ad38f9ef79be018..b54f74716496772a273fedfa038f3d29b66ab14d 100644 (file)
@@ -736,7 +736,7 @@ process_preprocessed_file(struct hash* hash, const char* path, bool pump)
     free(p);
   }
 
-  char* cwd = gnu_getcwd();
+  char* cwd = get_cwd();
 
   // Bytes between p and q are pending to be hashed.
   char* p = data;
@@ -1630,7 +1630,7 @@ hash_common_info(struct args* args,
 
   // Possibly hash the current working directory.
   if (args_info.generating_debuginfo && g_config.hash_dir()) {
-    char* cwd = gnu_getcwd();
+    char* cwd = get_cwd();
     for (size_t i = 0; i < args_info.debug_prefix_maps_len; i++) {
       char* map = args_info.debug_prefix_maps[i];
       char* sep = strchr(map, '=');
index 1b65770d9546f56d4dd7a54ebf4c729c9d4ffad3..c7fcbed0df8ccc2114df75696c188954e6f90ac5 100755 (executable)
--- a/test/run
+++ b/test/run
@@ -3,7 +3,7 @@
 # A simple test suite for ccache.
 #
 # Copyright (C) 2002-2007 Andrew Tridgell
-# Copyright (C) 2009-2019 Joel Rosdahl and other contributors
+# Copyright (C) 2009-2020 Joel Rosdahl and other contributors
 #
 # See doc/AUTHORS.adoc for a complete list of contributors.
 #
@@ -302,8 +302,12 @@ EOF
 
     cd /
     remove_cache
-    rm -rf $ABS_TESTDIR/run
-    mkdir $ABS_TESTDIR/run
+    rm -rf $ABS_TESTDIR/run $ABS_TESTDIR/run.real
+
+    # Verify that tests behave well when apparent CWD != actual CWD.
+    mkdir $ABS_TESTDIR/run.real
+    ln -s run.real $ABS_TESTDIR/run
+
     cd $ABS_TESTDIR/run
     if type SUITE_${suite_name}_SETUP >/dev/null 2>&1; then
         SUITE_${suite_name}_SETUP