if ((!should_rewrite_dependency_target(ctx.args_info)
&& ctx.args_info.generating_dependencies)
- || ctx.args_info.seen_split_dwarf) {
+ || ctx.args_info.seen_split_dwarf || ctx.args_info.profile_arcs) {
// If generating dependencies: The output object file name is part of the .d
// file, so include the path in the hash.
//
// corresponding .dwo file based on the target object filename, so hashing
// the object file path will do it, although just hashing the object file
// base name would be enough.
+ //
+ // When using -fprofile-arcs (including implicitly via --coverage), the
+ // object file contains a .gcda path based on the object file path.
hash.hash_delimiter("object file");
hash.hash(ctx.args_info.output_obj);
}
rm "$gcno_name"
done
done
+
+ # -------------------------------------------------------------------------
+ TEST "-fprofile-arcs for different object file paths"
+
+ mkdir obj1 obj2
+
+ $CCACHE_COMPILE -fprofile-arcs -c test.c -o obj1/test.o
+ expect_stat 'cache hit (direct)' 0
+ expect_stat 'cache miss' 1
+
+ $CCACHE_COMPILE -fprofile-arcs -c test.c -o obj1/test.o
+ expect_stat 'cache hit (direct)' 1
+ expect_stat 'cache miss' 1
+
+ $CCACHE_COMPILE -fprofile-arcs -c test.c -o obj2/test.o
+ expect_different_content obj1/test.o obj2/test.o # different paths to .gcda file
+ expect_stat 'cache hit (direct)' 1
+ expect_stat 'cache miss' 2
+
+ $CCACHE_COMPILE -fprofile-arcs -c test.c -o obj2/test.o
+ expect_different_content obj1/test.o obj2/test.o # different paths to .gcda file
+ expect_stat 'cache hit (direct)' 2
+ expect_stat 'cache miss' 2
}
merge_profiling_data() {