From: Joel Rosdahl Date: Sun, 12 Dec 2021 19:41:36 +0000 (+0100) Subject: fix: Handle stdout from distcc-pump when used as a prefix X-Git-Tag: v4.6~64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2044fea84b86001b2976ecde946d3d6d0e88ec0a;p=thirdparty%2Fccache.git fix: Handle stdout from distcc-pump when used as a prefix The compiler guessing doesn’t work if pump is used as a prefix/CCACHE_PREFIX, so let’s just not depend on such guesswork. Also, since the distcc-pump wrapper isn’t really a compiler type, it actually makes sense not to treat it as such. --- diff --git a/src/Config.cpp b/src/Config.cpp index 2dd1e44be..bea38d920 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -247,8 +247,6 @@ parse_compiler_type(const std::string& value) return CompilerType::nvcc; } else if (value == "other") { return CompilerType::other; - } else if (value == "pump") { - return CompilerType::pump; } else { // Allow any unknown value for forward compatibility. return CompilerType::auto_guess; @@ -454,7 +452,6 @@ compiler_type_to_string(CompilerType compiler_type) CASE(gcc); CASE(nvcc); CASE(other); - CASE(pump); CASE(cl); } #undef CASE diff --git a/src/Config.hpp b/src/Config.hpp index 982511222..a21e7ff19 100644 --- a/src/Config.hpp +++ b/src/Config.hpp @@ -31,7 +31,7 @@ #include #include -enum class CompilerType { auto_guess, clang, gcc, nvcc, other, pump, cl }; +enum class CompilerType { auto_guess, clang, gcc, nvcc, other, cl }; std::string compiler_type_to_string(CompilerType compiler_type); diff --git a/src/ccache.cpp b/src/ccache.cpp index de262781f..bd3641ed6 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -230,8 +230,6 @@ guess_compiler(string_view path) return CompilerType::gcc; } else if (name.find("nvcc") != nonstd::string_view::npos) { return CompilerType::nvcc; - } else if (name == "pump" || name == "distcc-pump") { - return CompilerType::pump; } else if (name.find("cl") != nonstd::string_view::npos) { return CompilerType::cl; } else { @@ -434,10 +432,7 @@ print_included_files(const Context& ctx, FILE* fp) // when computing the hash sum. // - Stores the paths and hashes of included files in ctx.included_files. static nonstd::expected -process_preprocessed_file(Context& ctx, - Hash& hash, - const std::string& path, - bool pump) +process_preprocessed_file(Context& ctx, Hash& hash, const std::string& path) { std::string data; try { @@ -583,7 +578,7 @@ process_preprocessed_file(Context& ctx, "bin directive in source code"); return nonstd::make_unexpected( Failure(Statistic::unsupported_code_directive)); - } else if (pump && strncmp(q, "_________", 9) == 0) { + } else if (strncmp(q, "___________", 10) == 0) { // Unfortunately the distcc-pump wrapper outputs standard output lines: // __________Using distcc-pump from /usr/bin // __________Using # distcc servers in pump mode @@ -857,8 +852,7 @@ rewrite_stdout_from_compiler(const Context& ctx, std::string&& stdout_data) // __________Using # distcc servers in pump mode // // We don't want to cache those. - if (!stdout_data.empty() - && ctx.config.compiler_type() == CompilerType::pump) { + if (!stdout_data.empty()) { std::string new_stdout_text; for (const auto line : util::Tokenizer( stdout_data, "\n", util::Tokenizer::Mode::include_empty)) { @@ -1102,8 +1096,7 @@ get_result_key_from_cpp(Context& ctx, Args& args, Hash& hash) } hash.hash_delimiter("cpp"); - const bool is_pump = ctx.config.compiler_type() == CompilerType::pump; - TRY(process_preprocessed_file(ctx, hash, stdout_path, is_pump)); + TRY(process_preprocessed_file(ctx, hash, stdout_path)); hash.hash_delimiter("cppstderr"); if (!ctx.args_info.direct_i_file && !hash.hash_file(stderr_path)) { diff --git a/unittest/test_Config.cpp b/unittest/test_Config.cpp index 17a055d57..1fed21c8c 100644 --- a/unittest/test_Config.cpp +++ b/unittest/test_Config.cpp @@ -101,7 +101,7 @@ TEST_CASE("Config::update_from_file") " #A comment\n" "\t compiler = foo\n" "compiler_check = none\n" - "compiler_type = pump\n" + "compiler_type = nvcc\n" "compression=false\n" "compression_level= 2\n" "cpp_extension = .foo\n" @@ -141,7 +141,7 @@ TEST_CASE("Config::update_from_file") CHECK(config.cache_dir() == FMT("{0}$/{0}/.ccache", user)); CHECK(config.compiler() == "foo"); CHECK(config.compiler_check() == "none"); - CHECK(config.compiler_type() == CompilerType::pump); + CHECK(config.compiler_type() == CompilerType::nvcc); CHECK_FALSE(config.compression()); CHECK(config.compression_level() == 2); CHECK(config.cpp_extension() == ".foo"); diff --git a/unittest/test_ccache.cpp b/unittest/test_ccache.cpp index e465a97c5..88125e233 100644 --- a/unittest/test_ccache.cpp +++ b/unittest/test_ccache.cpp @@ -183,9 +183,6 @@ TEST_CASE("guess_compiler") CHECK(guess_compiler("/test/prefix/nvcc") == CompilerType::nvcc); CHECK(guess_compiler("/test/prefix/nvcc-10.1.243") == CompilerType::nvcc); - CHECK(guess_compiler("/test/prefix/pump") == CompilerType::pump); - CHECK(guess_compiler("/test/prefix/distcc-pump") == CompilerType::pump); - CHECK(guess_compiler("/test/prefix/x") == CompilerType::other); CHECK(guess_compiler("/test/prefix/cc") == CompilerType::other); CHECK(guess_compiler("/test/prefix/c++") == CompilerType::other);