@@ -2468,23 +2468,43 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
2468
2468
}
2469
2469
2470
2470
void CompilerInvocation::buildDebugFlags (std::string &Output,
2471
- const ArrayRef< const char *> &Args,
2471
+ const ArgList &Args,
2472
2472
StringRef SDKPath,
2473
2473
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
+
2474
2494
// This isn't guaranteed to be the same temp directory as what the driver
2475
2495
// uses, but it's highly likely.
2476
2496
llvm::SmallString<128 > TDir;
2477
2497
llvm::sys::path::system_temp_directory (true , TDir);
2478
2498
2479
2499
llvm::raw_string_ostream OS (Output);
2480
- interleave (Args ,
2500
+ interleave (ReducedArgs ,
2481
2501
[&](const char *Argument) { PrintArg (OS, Argument, TDir.str ()); },
2482
2502
[&] { OS << " " ; });
2483
2503
2484
2504
// Inject the SDK path and resource dir if they are nonempty and missing.
2485
2505
bool haveSDKPath = SDKPath.empty ();
2486
2506
bool haveResourceDir = ResourceDir.empty ();
2487
- for (auto A : Args ) {
2507
+ for (auto A : ReducedArgs ) {
2488
2508
StringRef Arg (A);
2489
2509
// FIXME: this should distinguish between key and value.
2490
2510
if (!haveSDKPath && Arg.equals (" -sdk" ))
@@ -2561,14 +2581,10 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
2561
2581
" unknown -g<kind> option" );
2562
2582
}
2563
2583
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))
2568
2585
CompilerInvocation::buildDebugFlags (Opts.DebugFlags ,
2569
- RenderedArgs , SDKPath,
2586
+ Args , SDKPath,
2570
2587
ResourceDir);
2571
- }
2572
2588
2573
2589
if (const Arg *A = Args.getLastArg (OPT_file_compilation_dir))
2574
2590
Opts.DebugCompilationDir = A->getValue ();
0 commit comments