@@ -2484,23 +2484,43 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
24842484}
24852485
24862486void CompilerInvocation::buildDebugFlags (std::string &Output,
2487- const ArrayRef< const char *> &Args,
2487+ const ArgList &Args,
24882488 StringRef SDKPath,
24892489 StringRef ResourceDir) {
2490+ ArgStringList ReducedArgs;
2491+ for (auto *A : Args) {
2492+ // Do not encode cache invariant options, even for non-caching build.
2493+ // Those options do not affect compilation task thus do not need to be
2494+ // tracked.
2495+ if (A->getOption ().hasFlag (options::CacheInvariant))
2496+ continue ;
2497+
2498+ A->render (Args, ReducedArgs);
2499+
2500+ // If the argument is file list, the path itself is irrelevant.
2501+ if (A->getOption ().hasFlag (options::ArgumentIsFileList)) {
2502+ assert (A->getValues ().size () == 1 &&
2503+ A->getOption ().getRenderStyle () == Option::RenderSeparateStyle &&
2504+ " filelist options all have one argument and are all Separate<>" );
2505+ ReducedArgs.pop_back ();
2506+ ReducedArgs.push_back (" <filelist>" );
2507+ }
2508+ }
2509+
24902510 // This isn't guaranteed to be the same temp directory as what the driver
24912511 // uses, but it's highly likely.
24922512 llvm::SmallString<128 > TDir;
24932513 llvm::sys::path::system_temp_directory (true , TDir);
24942514
24952515 llvm::raw_string_ostream OS (Output);
2496- interleave (Args ,
2516+ interleave (ReducedArgs ,
24972517 [&](const char *Argument) { PrintArg (OS, Argument, TDir.str ()); },
24982518 [&] { OS << " " ; });
24992519
25002520 // Inject the SDK path and resource dir if they are nonempty and missing.
25012521 bool haveSDKPath = SDKPath.empty ();
25022522 bool haveResourceDir = ResourceDir.empty ();
2503- for (auto A : Args ) {
2523+ for (auto A : ReducedArgs ) {
25042524 StringRef Arg (A);
25052525 // FIXME: this should distinguish between key and value.
25062526 if (!haveSDKPath && Arg.equals (" -sdk" ))
@@ -2579,14 +2599,10 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
25792599 " unknown -g<kind> option" );
25802600 }
25812601 if (Opts.DebugInfoLevel >= IRGenDebugInfoLevel::LineTables) {
2582- if (Args.hasArg (options::OPT_debug_info_store_invocation)) {
2583- ArgStringList RenderedArgs;
2584- for (auto A : Args)
2585- A->render (Args, RenderedArgs);
2602+ if (Args.hasArg (options::OPT_debug_info_store_invocation))
25862603 CompilerInvocation::buildDebugFlags (Opts.DebugFlags ,
2587- RenderedArgs , SDKPath,
2604+ Args , SDKPath,
25882605 ResourceDir);
2589- }
25902606
25912607 if (const Arg *A = Args.getLastArg (OPT_file_compilation_dir))
25922608 Opts.DebugCompilationDir = A->getValue ();
0 commit comments