@@ -2468,23 +2468,43 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
24682468}
24692469
24702470void CompilerInvocation::buildDebugFlags (std::string &Output,
2471- const ArrayRef< const char *> &Args,
2471+ const ArgList &Args,
24722472 StringRef SDKPath,
24732473 StringRef ResourceDir) {
2474+ ArgStringList ReducedArgs;
2475+ for (auto *A : Args) {
2476+ // Do not encode cache invariant options, even for non-caching build.
2477+ // Those options do not affect compilation task thus do not need to be
2478+ // tracked.
2479+ if (A->getOption ().hasFlag (options::CacheInvariant))
2480+ continue ;
2481+
2482+ A->render (Args, ReducedArgs);
2483+
2484+ // If the argument is file list, the path itself is irrelevant.
2485+ if (A->getOption ().hasFlag (options::ArgumentIsFileList)) {
2486+ assert (A->getValues ().size () == 1 &&
2487+ A->getOption ().getRenderStyle () == Option::RenderSeparateStyle &&
2488+ " filelist options all have one argument and are all Separate<>" );
2489+ ReducedArgs.pop_back ();
2490+ ReducedArgs.push_back (" <filelist>" );
2491+ }
2492+ }
2493+
24742494 // This isn't guaranteed to be the same temp directory as what the driver
24752495 // uses, but it's highly likely.
24762496 llvm::SmallString<128 > TDir;
24772497 llvm::sys::path::system_temp_directory (true , TDir);
24782498
24792499 llvm::raw_string_ostream OS (Output);
2480- interleave (Args ,
2500+ interleave (ReducedArgs ,
24812501 [&](const char *Argument) { PrintArg (OS, Argument, TDir.str ()); },
24822502 [&] { OS << " " ; });
24832503
24842504 // Inject the SDK path and resource dir if they are nonempty and missing.
24852505 bool haveSDKPath = SDKPath.empty ();
24862506 bool haveResourceDir = ResourceDir.empty ();
2487- for (auto A : Args ) {
2507+ for (auto A : ReducedArgs ) {
24882508 StringRef Arg (A);
24892509 // FIXME: this should distinguish between key and value.
24902510 if (!haveSDKPath && Arg.equals (" -sdk" ))
@@ -2561,14 +2581,10 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
25612581 " unknown -g<kind> option" );
25622582 }
25632583 if (Opts.DebugInfoLevel >= IRGenDebugInfoLevel::LineTables) {
2564- if (Args.hasArg (options::OPT_debug_info_store_invocation)) {
2565- ArgStringList RenderedArgs;
2566- for (auto A : Args)
2567- A->render (Args, RenderedArgs);
2584+ if (Args.hasArg (options::OPT_debug_info_store_invocation))
25682585 CompilerInvocation::buildDebugFlags (Opts.DebugFlags ,
2569- RenderedArgs , SDKPath,
2586+ Args , SDKPath,
25702587 ResourceDir);
2571- }
25722588
25732589 if (const Arg *A = Args.getLastArg (OPT_file_compilation_dir))
25742590 Opts.DebugCompilationDir = A->getValue ();
0 commit comments