Skip to content

Commit 997cd6e

Browse files
[Caching] Use swift-frontend as exectuable 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 395f5bf commit 997cd6e

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

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+
// PRASEABLE-NEXT: "command": "swift-frontend -frontend
5758

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

tools/libSwiftScan/SwiftCaching.cpp

Lines changed: 4 additions & 13 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, {}, "swift-frontend"))
289281
return llvm::createStringError(llvm::inconvertibleErrorCode(),
290282
"Argument parsing failed");
291283

@@ -826,11 +818,10 @@ 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-
821+
// This is inside a dylib so just use `swift-frontend` as executable path
822+
// since the actual executable path is not useful here.
832823
if (Instance->Invocation.parseArgs(Args, DE, nullptr, {},
833-
MainExecutablePath)) {
824+
"swift-frontend")) {
834825
delete Instance;
835826
*error = swift::c_string_utils::create_clone(err_msg.c_str());
836827
return nullptr;

0 commit comments

Comments
 (0)