@@ -2484,23 +2484,43 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
2484
2484
}
2485
2485
2486
2486
void CompilerInvocation::buildDebugFlags (std::string &Output,
2487
- const ArrayRef< const char *> &Args,
2487
+ const ArgList &Args,
2488
2488
StringRef SDKPath,
2489
2489
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
+
2490
2510
// This isn't guaranteed to be the same temp directory as what the driver
2491
2511
// uses, but it's highly likely.
2492
2512
llvm::SmallString<128 > TDir;
2493
2513
llvm::sys::path::system_temp_directory (true , TDir);
2494
2514
2495
2515
llvm::raw_string_ostream OS (Output);
2496
- interleave (Args ,
2516
+ interleave (ReducedArgs ,
2497
2517
[&](const char *Argument) { PrintArg (OS, Argument, TDir.str ()); },
2498
2518
[&] { OS << " " ; });
2499
2519
2500
2520
// Inject the SDK path and resource dir if they are nonempty and missing.
2501
2521
bool haveSDKPath = SDKPath.empty ();
2502
2522
bool haveResourceDir = ResourceDir.empty ();
2503
- for (auto A : Args ) {
2523
+ for (auto A : ReducedArgs ) {
2504
2524
StringRef Arg (A);
2505
2525
// FIXME: this should distinguish between key and value.
2506
2526
if (!haveSDKPath && Arg.equals (" -sdk" ))
@@ -2579,14 +2599,10 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
2579
2599
" unknown -g<kind> option" );
2580
2600
}
2581
2601
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))
2586
2603
CompilerInvocation::buildDebugFlags (Opts.DebugFlags ,
2587
- RenderedArgs , SDKPath,
2604
+ Args , SDKPath,
2588
2605
ResourceDir);
2589
- }
2590
2606
2591
2607
if (const Arg *A = Args.getLastArg (OPT_file_compilation_dir))
2592
2608
Opts.DebugCompilationDir = A->getValue ();
0 commit comments