mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #72168 from cachemeifyoucan/eng/PR-124222904
[Caching] Normalize DebugInfo flags
This commit is contained in:
@@ -2484,23 +2484,43 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
|
||||
}
|
||||
|
||||
void CompilerInvocation::buildDebugFlags(std::string &Output,
|
||||
const ArrayRef<const char*> &Args,
|
||||
const ArgList &Args,
|
||||
StringRef SDKPath,
|
||||
StringRef ResourceDir) {
|
||||
ArgStringList ReducedArgs;
|
||||
for (auto *A : Args) {
|
||||
// Do not encode cache invariant options, even for non-caching build.
|
||||
// Those options do not affect compilation task thus do not need to be
|
||||
// tracked.
|
||||
if (A->getOption().hasFlag(options::CacheInvariant))
|
||||
continue;
|
||||
|
||||
A->render(Args, ReducedArgs);
|
||||
|
||||
// If the argument is file list, the path itself is irrelevant.
|
||||
if (A->getOption().hasFlag(options::ArgumentIsFileList)) {
|
||||
assert(A->getValues().size() == 1 &&
|
||||
A->getOption().getRenderStyle() == Option::RenderSeparateStyle &&
|
||||
"filelist options all have one argument and are all Separate<>");
|
||||
ReducedArgs.pop_back();
|
||||
ReducedArgs.push_back("<filelist>");
|
||||
}
|
||||
}
|
||||
|
||||
// This isn't guaranteed to be the same temp directory as what the driver
|
||||
// uses, but it's highly likely.
|
||||
llvm::SmallString<128> TDir;
|
||||
llvm::sys::path::system_temp_directory(true, TDir);
|
||||
|
||||
llvm::raw_string_ostream OS(Output);
|
||||
interleave(Args,
|
||||
interleave(ReducedArgs,
|
||||
[&](const char *Argument) { PrintArg(OS, Argument, TDir.str()); },
|
||||
[&] { OS << " "; });
|
||||
|
||||
// Inject the SDK path and resource dir if they are nonempty and missing.
|
||||
bool haveSDKPath = SDKPath.empty();
|
||||
bool haveResourceDir = ResourceDir.empty();
|
||||
for (auto A : Args) {
|
||||
for (auto A : ReducedArgs) {
|
||||
StringRef Arg(A);
|
||||
// FIXME: this should distinguish between key and value.
|
||||
if (!haveSDKPath && Arg.equals("-sdk"))
|
||||
@@ -2579,14 +2599,10 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
|
||||
"unknown -g<kind> option");
|
||||
}
|
||||
if (Opts.DebugInfoLevel >= IRGenDebugInfoLevel::LineTables) {
|
||||
if (Args.hasArg(options::OPT_debug_info_store_invocation)) {
|
||||
ArgStringList RenderedArgs;
|
||||
for (auto A : Args)
|
||||
A->render(Args, RenderedArgs);
|
||||
if (Args.hasArg(options::OPT_debug_info_store_invocation))
|
||||
CompilerInvocation::buildDebugFlags(Opts.DebugFlags,
|
||||
RenderedArgs, SDKPath,
|
||||
Args, SDKPath,
|
||||
ResourceDir);
|
||||
}
|
||||
|
||||
if (const Arg *A = Args.getLastArg(OPT_file_compilation_dir))
|
||||
Opts.DebugCompilationDir = A->getValue();
|
||||
|
||||
Reference in New Issue
Block a user