From 5a55014f0c208bff61b8fe0eb1533c210553dd13 Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Wed, 6 Apr 2022 21:37:04 +0200 Subject: [PATCH] fix: Fix process_preprocessed_file bug for distcc marker MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 2044fea84b86001b2976ecde946d3d6d0e88ec0a (included in ccache 4.6) removed the special-casing of distcc’s pump in process_preprocessed_file. That in turn revealed a bug that has been present since 432d1ca6a6aa51f708124172169073c399fb68d2 (included in ccache 3.4) but previously only affected compilations with distcc-pump as the “compiler”: the detection and handling of distcc-pump’s “__________” messages is broken in two ways: 1. It throws away everything between the last preprocessor directive and the “__________” marker. Thus, changes to such sections will not be included in the hash. 2. It detects “__________” markers in the middle of lines, not only at the beginning of lines. --- src/ccache.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ccache.cpp b/src/ccache.cpp index 2598d02be..bf6698daf 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -590,11 +590,13 @@ process_preprocessed_file(Context& ctx, Hash& hash, const std::string& path) "bin directive in source code"); return nonstd::make_unexpected( Failure(Statistic::unsupported_code_directive)); - } else if (strncmp(q, "___________", 10) == 0) { + } else if (strncmp(q, "___________", 10) + && (q == data.data() || q[-1] == '\n') == 0) { // Unfortunately the distcc-pump wrapper outputs standard output lines: // __________Using distcc-pump from /usr/bin // __________Using # distcc servers in pump mode // __________Shutting down distcc-pump include server + hash.hash(p, q - p); while (q < end && *q != '\n') { q++; } -- 2.47.2