]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
feat: Add support for -fdump-ipa-clones (#1449)
authorJiri Slaby <jirislaby@gmail.com>
Sun, 12 May 2024 07:48:28 +0000 (09:48 +0200)
committerGitHub <noreply@github.com>
Sun, 12 May 2024 07:48:28 +0000 (09:48 +0200)
Fixes #1447. Citing:

`-fdump-ipa-clones` is used heavily for live patching. Especially, when
one builds a distro kernel (like SLE 15 SP6), the build uses the option
to generate additional `.000i.ipa-clones` files.

src/ccache/ArgsInfo.hpp
src/ccache/argprocessing.cpp
src/ccache/ccache.cpp
src/ccache/core/Result.cpp
src/ccache/core/Result.hpp
src/ccache/core/ResultRetriever.cpp

index a9e2ae0fbef0c62be0970fba623f5d64081cbe2d..664af3f821098656ab46866fe8472f57fa026234 100644 (file)
@@ -64,6 +64,9 @@ struct ArgsInfo
   // Split dwarf information (GCC 4.8 and up). Contains pathname if not empty.
   std::string output_dwo;
 
+  // The path to the ipa clones (implicit when using -fdump-ipa-clones).
+  std::string output_ipa;
+
   // Assembler listing file.
   std::string output_al;
 
@@ -92,6 +95,8 @@ struct ArgsInfo
   // Is the compiler being asked to output stack usage?
   bool generating_stackusage = false;
 
+  bool generating_ipa_clones = false;
+
   bool generating_callgraphinfo = false;
 
   // Us the compiler being asked to generate diagnostics
index 346434b39a32825cd80a59e408149e453853aaa9..ef08d134de5502d7854023d0736a4b688a538701 100644 (file)
@@ -418,6 +418,12 @@ process_option_arg(const Context& ctx,
     return Statistic::none;
   }
 
+  if (arg == "-fdump-ipa-clones") {
+    args_info.generating_ipa_clones = true;
+    state.common_args.push_back(args[i]);
+    return Statistic::none;
+  }
+
   // These are always too hard.
   if (compopt_too_hard(arg) || util::starts_with(arg, "-fdump-")
       || util::starts_with(arg, "-MJ")
@@ -1602,6 +1608,13 @@ process_args(Context& ctx)
       pstr(core::make_relative_path(ctx, default_cifile_name)).str();
   }
 
+  if (args_info.generating_ipa_clones) {
+    fs::path ipa_path(args_info.orig_input_file);
+    ipa_path += ".000i.ipa-clones";
+    args_info.output_ipa =
+      pstr(core::make_relative_path(ctx, ipa_path.string())).str();
+  }
+
   Args compiler_args = state.common_args;
   compiler_args.push_back(state.compiler_only_args_no_hash);
   compiler_args.push_back(state.compiler_only_args);
index 7a01db5769b6221acb61b8d6a8cba324b358a861..a53d55a00f8c9d7939240dc202c08f93782f2bea 100644 (file)
@@ -955,6 +955,12 @@ write_result(Context& ctx,
     LOG("Callgraph info file {} missing", ctx.args_info.output_ci);
     return false;
   }
+  if (ctx.args_info.generating_ipa_clones
+      && !serializer.add_file(core::Result::FileType::ipa_clones,
+                              ctx.args_info.output_ipa)) {
+    LOG("IPA clones file {} missing", ctx.args_info.output_ipa);
+    return false;
+  }
   if (ctx.args_info.generating_diagnostics
       && !serializer.add_file(core::Result::FileType::diagnostic,
                               ctx.args_info.output_dia)) {
index b22ae0e7da6f4d1d936529c3711fdb5dca2932dc..5d1819edc5d5e80e514c88a63b51e82d46fb11f8 100644 (file)
@@ -153,6 +153,9 @@ file_type_to_string(FileType type)
 
   case FileType::callgraph_info:
     return ".ci";
+
+  case FileType::ipa_clones:
+    return ".000i.ipa-clones";
   }
 
   return k_unknown_file_type;
index 01ddfb6ffa220328da81ba08cc8a048a0e2036ec..f0010a9444173754f91a4552c16d51cce9eb5b4b 100644 (file)
@@ -88,6 +88,10 @@ enum class FileType : UnderlyingFileTypeInt {
   // callgraph info file generated by -fcallgraph-info, i.e. output file but
   // with a .ci extension.
   callgraph_info = 11,
+
+  // ipa clones generated by -fdump-ipa-clones, i.e. output file but with a
+  // .000i.ipa-clones extension.
+  ipa_clones = 12,
 };
 
 const char* file_type_to_string(FileType type);
index 9f0cbb86bcc142fb3d28f9cf300b355642a77b77..921aff5c773a51aa5a5570017ca806c788329606 100644 (file)
@@ -206,6 +206,11 @@ ResultRetriever::get_dest_path(FileType file_type) const
       return m_ctx.args_info.output_ci;
     }
     break;
+  case FileType::ipa_clones:
+    if (m_ctx.args_info.generating_ipa_clones) {
+      return m_ctx.args_info.output_ipa;
+    }
+    break;
   }
 
   return {};