]> 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:15:42 +0000 (23:15 +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.

src/ccache.c
test/run

index 073efe16b3761fe1d636a5173b2bd4351d5d3447..0ac018d8facccce2a50409387a2c5bfd241fdf40 100644 (file)
@@ -914,7 +914,7 @@ process_preprocessed_file(struct hash *hash, const char *path, bool pump)
 
        init_included_files_table();
 
-       char *cwd = gnu_getcwd();
+       char *cwd = get_cwd();
 
        // Bytes between p and q are pending to be hashed.
        char *p = data;
@@ -1910,7 +1910,7 @@ calculate_common_hash(struct args *args, struct hash *hash)
 
        // Possibly hash the current working directory.
        if (generating_debuginfo && conf->hash_dir) {
-               char *cwd = gnu_getcwd();
+               char *cwd = get_cwd();
                for (size_t i = 0; i < debug_prefix_maps_len; i++) {
                        char *map = debug_prefix_maps[i];
                        char *sep = strchr(map, '=');
index f81040932faa5b5d6a98c9a201f630ccd140858f..d506c4657ee46219cc88c2a9dde9f99803cef32d 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
+# Copyright (C) 2009-2020 Joel Rosdahl
 #
 # This program is free software; you can redistribute it and/or modify it under
 # the terms of the GNU General Public License as published by the Free Software
@@ -262,8 +262,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