]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Handle stdout from distcc-pump when used as a prefix
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 12 Dec 2021 19:41:36 +0000 (20:41 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 12 Dec 2021 20:32:49 +0000 (21:32 +0100)
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.

src/Config.cpp
src/Config.hpp
src/ccache.cpp
unittest/test_Config.cpp
unittest/test_ccache.cpp

index 2dd1e44be2b44c2297e4d0f380dc69e7a9fef386..bea38d92091e34f93a7bb5ede29ddb48a816a992 100644 (file)
@@ -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
index 982511222c4ef7ebe2c7eba12a472c5bd72f2add..a21e7ff198a2885a56fd5b24c5b5c1f4183accbd 100644 (file)
@@ -31,7 +31,7 @@
 #include <string>
 #include <unordered_map>
 
-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);
 
index de262781f3c2699ea530f1a17368028c400e7900..bd3641ed673d3c929e48bfde523118e9e3be1346 100644 (file)
@@ -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<void, Failure>
-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)) {
index 17a055d571727cae74b95fe834f1947d93d8dbd1..1fed21c8cce582d344582001a737184ca2491130 100644 (file)
@@ -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");
index e465a97c5bf368b3b440774a9dc9f8eb5f1e686a..88125e233a570e6f04b6164b1039f18d057cc078 100644 (file)
@@ -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);