]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Revert "fix: Fall back to copying temporary preprocessed output file"
authorJoel Rosdahl <joel@rosdahl.net>
Tue, 7 Jun 2022 12:40:08 +0000 (14:40 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 7 Jun 2022 14:15:10 +0000 (16:15 +0200)
This reverts commit cbedccc9fa30f8958dc3e7fbdf900a952f63d5ad since the
fix doesn't work.

The hard link in question is used in get_result_key_from_cpp to create
an alias of file that captures stdout from the preprocessor, where the
alias has the correct cpp extension. It can't just be a copy since
do_execute writes to the original name. See #1079.

src/Result.cpp
src/ResultRetriever.cpp
src/Util.cpp
src/Util.hpp
src/ccache.cpp

index b272f33c310dc188f9c992f9b9a275433b7528bc..bc7c313d6c21c5e8d85b5211da315faa0b0f5caa 100644 (file)
@@ -417,7 +417,7 @@ Result::Writer::write_raw_file_entry(const std::string& path,
   const auto raw_file = get_raw_file_path(m_result_path, entry_number);
   const auto old_stat = Stat::stat(raw_file);
   try {
-    Util::clone_hard_link_or_copy_file(m_ctx.config, path, raw_file, true);
+    Util::clone_hard_link_or_copy_file(m_ctx, path, raw_file, true);
   } catch (core::Error& e) {
     throw core::Error(
       "Failed to store {} as raw file {}: {}", path, raw_file, e.what());
index 430ff966711e80712243b4e12410f73d4fd096e0..c1c584ebc815071cde11099407245b528127426c 100644 (file)
@@ -117,8 +117,7 @@ ResultRetriever::on_entry_start(uint8_t entry_number,
   } else if (dest_path == "/dev/null") {
     LOG_RAW("Not writing to /dev/null");
   } else if (raw_file) {
-    Util::clone_hard_link_or_copy_file(
-      m_ctx.config, *raw_file, dest_path, false);
+    Util::clone_hard_link_or_copy_file(m_ctx, *raw_file, dest_path, false);
 
     // Update modification timestamp to save the file from LRU cleanup (and, if
     // hard-linked, to make the object file newer than the source file).
index bb1f145b78579006f64770944d4614a858f75649..b94ee1a81b71bb252db9244be64d6629480981bb 100644 (file)
@@ -293,14 +293,13 @@ clone_file(const std::string& src, const std::string& dest, bool via_tmp_file)
 }
 #endif // FILE_CLONING_SUPPORTED
 
-static void
-clone_hard_link_or_copy_file(const std::string& source,
+void
+clone_hard_link_or_copy_file(const Context& ctx,
+                             const std::string& source,
                              const std::string& dest,
-                             bool try_clone,
-                             bool try_hard_link,
                              bool via_tmp_file)
 {
-  if (try_clone) {
+  if (ctx.config.file_clone()) {
 #ifdef FILE_CLONING_SUPPORTED
     LOG("Cloning {} to {}", source, dest);
     try {
@@ -313,7 +312,7 @@ clone_hard_link_or_copy_file(const std::string& source,
     LOG("Not cloning {} to {} since it's unsupported", source, dest);
 #endif
   }
-  if (try_hard_link) {
+  if (ctx.config.hard_link()) {
     LOG("Hard linking {} to {}", source, dest);
     try {
       Util::hard_link(source, dest);
@@ -333,16 +332,6 @@ clone_hard_link_or_copy_file(const std::string& source,
   copy_file(source, dest, via_tmp_file);
 }
 
-void
-clone_hard_link_or_copy_file(const Config& config,
-                             const std::string& source,
-                             const std::string& dest,
-                             bool via_tmp_file)
-{
-  clone_hard_link_or_copy_file(
-    source, dest, config.file_clone(), config.hard_link(), via_tmp_file);
-}
-
 size_t
 common_dir_prefix_length(std::string_view dir, std::string_view path)
 {
@@ -794,12 +783,6 @@ hard_link(const std::string& oldpath, const std::string& newpath)
 #endif
 }
 
-void
-hard_link_or_copy(const std::string& oldpath, const std::string& newpath)
-{
-  return clone_hard_link_or_copy_file(oldpath, newpath, false, true, false);
-}
-
 std::optional<size_t>
 is_absolute_path_with_prefix(std::string_view path)
 {
index 4358fca5a6337295fddf98c000e291f596593226..bf55484409f83ffc573812fcf39da7119f649f9a 100644 (file)
@@ -32,7 +32,6 @@
 #include <utility>
 #include <vector>
 
-class Config;
 class Context;
 
 namespace Util {
@@ -98,7 +97,7 @@ void clone_file(const std::string& src,
 // Clone, hard link or copy a file from `source` to `dest` depending on settings
 // in `ctx`. If cloning or hard linking cannot and should not be done the file
 // will be copied instead. Throws `core::Error` on error.
-void clone_hard_link_or_copy_file(const Config& config,
+void clone_hard_link_or_copy_file(const Context& ctx,
                                   const std::string& source,
                                   const std::string& dest,
                                   bool via_tmp_file = false);
@@ -193,10 +192,6 @@ mode_t get_umask();
 // Hard-link `oldpath` to `newpath`. Throws `core::Error` on error.
 void hard_link(const std::string& oldpath, const std::string& newpath);
 
-// Hard-link `oldpath` to `newpath`, or fall back to copying if hard-linking
-// doesn't work. Throws `core::Error` on error.
-void hard_link_or_copy(const std::string& oldpath, const std::string& newpath);
-
 // Write bytes in big endian order from an integer value.
 //
 // Parameters:
index db93bc8d786e64ed1274d6e6183fe49e79faa094..203c2893b48272b4afc2583e421bcd7c4442cc5b 100644 (file)
@@ -1125,7 +1125,7 @@ get_result_key_from_cpp(Context& ctx, Args& args, Hash& hash)
     // stdout_path needs the proper cpp_extension for the compiler to do its
     // thing correctly.
     stdout_path = FMT("{}.{}", tmp_stdout.path, ctx.config.cpp_extension());
-    Util::hard_link_or_copy(tmp_stdout.path, stdout_path);
+    Util::hard_link(tmp_stdout.path, stdout_path);
     ctx.register_pending_tmp_file(stdout_path);
 
     TemporaryFile tmp_stderr(