Skip to content

Commit 61e725f

Browse files
[Caching] Use swift-frontend as executable name in replays
Don't try to figure out the executable names during replay from libSwiftScan.dylib. The actual executable path for the process actually doesn't matter in this case to reconstruct the invocation and might actually be misleading. Just use `swift-frontend` as a placeheader executable name for in-process cache replay. rdar://132758308
1 parent aaf9e67 commit 61e725f

File tree

4 files changed

+6
-16
lines changed

4 files changed

+6
-16
lines changed

lib/Frontend/DiagnosticHelper.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@ static DetailedTaskDescription constructDetailedTaskDescription(
347347
ArrayRef<const char *> Args, bool isEmitModuleOnly = false) {
348348
// Command line and arguments
349349
std::string Executable = Invocation.getFrontendOptions().MainExecutablePath;
350+
// If main executable path is never set, use `swift-frontend` as placeholder.
351+
if (Executable.empty())
352+
Executable = "swift-frontend";
350353
SmallVector<std::string, 16> Arguments;
351354
std::string CommandLine;
352355
SmallVector<CommandInput, 4> Inputs;

test/CAS/swift-scan-diagnostics-batch.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@
5050

5151
// PARSEABLE-COUNT-1: "kind": "began",
5252
// PARSEABLE-COUNT-1: "kind": "finished",
53-
// PRASEABLE-NOT: "kind": "began",
54-
// PRASEABLE-NOT: "kind": "finished",
5553

5654
// NO-OUTPUT-NOT: "kind": "began",
5755

test/CAS/swift-scan-diagnostics.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
// PARSEABLE-NEXT: {
5555
// PARSEABLE-NEXT: "kind": "began",
5656
// PARSEABLE-NEXT: "name": "compile",
57+
// PARSEABLE-NEXT: "command": "swift-frontend
5758

5859
// PARSEABLE: "kind": "finished",
5960
// PARSEABLE-NEXT: "name": "compile",

tools/libSwiftScan/SwiftCaching.cpp

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,8 @@ computeCacheKey(llvm::cas::ObjectStore &CAS, llvm::ArrayRef<const char *> Args,
276276
swift::CompilerInvocation Invocation;
277277
swift::SourceManager SourceMgr;
278278
swift::DiagnosticEngine Diags(SourceMgr);
279-
llvm::SmallString<128> workingDirectory;
280-
llvm::sys::fs::current_path(workingDirectory);
281-
llvm::SmallVector<std::unique_ptr<llvm::MemoryBuffer>, 4>
282-
configurationFileBuffers;
283279

284-
std::string MainExecutablePath = llvm::sys::fs::getMainExecutable(
285-
"swift-frontend", (void *)swiftscan_cache_replay_compilation);
286-
287-
if (Invocation.parseArgs(Args, Diags, &configurationFileBuffers,
288-
workingDirectory, MainExecutablePath))
280+
if (Invocation.parseArgs(Args, Diags, nullptr, {}))
289281
return llvm::createStringError(llvm::inconvertibleErrorCode(),
290282
"Argument parsing failed");
291283

@@ -826,11 +818,7 @@ swiftscan_cache_replay_instance_create(int argc, const char **argv,
826818
swift::DiagnosticEngine DE(SrcMgr);
827819
DE.addConsumer(Diags);
828820

829-
std::string MainExecutablePath = llvm::sys::fs::getMainExecutable(
830-
"swift-frontend", (void *)swiftscan_cache_replay_compilation);
831-
832-
if (Instance->Invocation.parseArgs(Args, DE, nullptr, {},
833-
MainExecutablePath)) {
821+
if (Instance->Invocation.parseArgs(Args, DE, nullptr, {})) {
834822
delete Instance;
835823
*error = swift::c_string_utils::create_clone(err_msg.c_str());
836824
return nullptr;

0 commit comments

Comments
 (0)