summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Rosdahl <joel@rosdahl.net>2022-08-01 14:53:52 +0200
committerJoel Rosdahl <joel@rosdahl.net>2022-08-20 14:13:12 +0200
commitc089aa81533f01fcca2b421b44800479ec297729 (patch)
tree334ef613aacc62262fce7729e12cf45aff8e7736
parent711c418b18a8e2005b7ec015fa7dc0ca253f4112 (diff)
downloadccache-c089aa81533f01fcca2b421b44800479ec297729.tar.gz
fix: Always rewrite dependency file if base_dir is used
[1] added the has_absolute_include_headers variable as a performance optimization for base_dir/CCACHE_BASEDIR so that the dependency file only has to be parsed/rewritten when necessary. This is based on the assumption that if no include file has an absolute path then no rewrite is needed, but apparently Clang can insert other paths into the dependency file as well, for instance the asan_blacklist.txt file when using -fsanitize=address. Fix this by simply always parsing the dependency file when base_dir is active. Fixes #1128. [1]: 60178b7a8eb8d03b364afb2fb8bd6753924cd9b7 (cherry picked from commit 1ee5365507ff3dd3d071f9ccd9380ad5c661ee12)
-rw-r--r--src/Context.hpp3
-rw-r--r--src/Depfile.cpp6
-rw-r--r--src/ccache.cpp6
-rw-r--r--unittest/test_Depfile.cpp1
4 files changed, 0 insertions, 16 deletions
diff --git a/src/Context.hpp b/src/Context.hpp
index 241ad455..d701b973 100644
--- a/src/Context.hpp
+++ b/src/Context.hpp
@@ -71,9 +71,6 @@ public:
// Files included by the preprocessor and their hashes.
std::unordered_map<std::string, Digest> included_files;
- // Uses absolute path for some include files.
- bool has_absolute_include_headers = false;
-
// Have we tried and failed to get colored diagnostics?
bool diagnostics_color_failed = false;
diff --git a/src/Depfile.cpp b/src/Depfile.cpp
index 3fcc0bcd..49c7c063 100644
--- a/src/Depfile.cpp
+++ b/src/Depfile.cpp
@@ -61,7 +61,6 @@ nonstd::optional<std::string>
rewrite_paths(const Context& ctx, const std::string& file_content)
{
ASSERT(!ctx.config.base_dir().empty());
- ASSERT(ctx.has_absolute_include_headers);
// Fast path for the common case:
if (file_content.find(ctx.config.base_dir()) == std::string::npos) {
@@ -116,11 +115,6 @@ make_paths_relative_in_output_dep(const Context& ctx)
LOG_RAW("Base dir not set, skip using relative paths");
return; // nothing to do
}
- if (!ctx.has_absolute_include_headers) {
- LOG_RAW(
- "No absolute path for included files found, skip using relative paths");
- return; // nothing to do
- }
const std::string& output_dep = ctx.args_info.output_dep;
std::string file_content;
diff --git a/src/ccache.cpp b/src/ccache.cpp
index ec33db83..0bee98d8 100644
--- a/src/ccache.cpp
+++ b/src/ccache.cpp
@@ -553,9 +553,6 @@ process_preprocessed_file(Context& ctx, Hash& hash, const std::string& path)
}
// p and q span the include file path.
std::string inc_path(p, q - p);
- if (!ctx.has_absolute_include_headers) {
- ctx.has_absolute_include_headers = util::is_absolute_path(inc_path);
- }
inc_path = Util::normalize_concrete_absolute_path(inc_path);
inc_path = Util::make_relative_path(ctx, inc_path);
@@ -639,9 +636,6 @@ result_key_from_depfile(Context& ctx, Hash& hash)
if (token.ends_with(":")) {
continue;
}
- if (!ctx.has_absolute_include_headers) {
- ctx.has_absolute_include_headers = util::is_absolute_path(token);
- }
std::string path = Util::make_relative_path(ctx, token);
remember_include_file(ctx, path, hash, false, &hash);
}
diff --git a/unittest/test_Depfile.cpp b/unittest/test_Depfile.cpp
index c4f7e353..d00e3b1a 100644
--- a/unittest/test_Depfile.cpp
+++ b/unittest/test_Depfile.cpp
@@ -43,7 +43,6 @@ TEST_CASE("Depfile::rewrite_paths")
Context ctx;
const auto cwd = ctx.actual_cwd;
- ctx.has_absolute_include_headers = true;
const auto content =
FMT("foo.o: bar.c {0}/bar.h \\\n\n {1}/fie.h {0}/fum.h\n",