[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)
// 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;
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) {
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;
}
// 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);
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);
}
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",