Skip to content

Commit

Permalink
feat: Add support for -fdump-ipa-clones (ccache#1449)
Browse files Browse the repository at this point in the history
Fixes ccache#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.
  • Loading branch information
jirislaby authored May 12, 2024
1 parent 911b899 commit 23f40d2
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ccache/ArgsInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions src/ccache/argprocessing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions src/ccache/ccache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
3 changes: 3 additions & 0 deletions src/ccache/core/Result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/ccache/core/Result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/ccache/core/ResultRetriever.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
Expand Down

0 comments on commit 23f40d2

Please sign in to comment.