Skip to content

Commit f4f3d52

Browse files
authored
Merge pull request #36456 from ahoppen/pr/no-xcrun-in-sourcekitd
[Driver] Don't validate arclite linking if the driver is only set up to get the swift-frontend invocation
2 parents 5499235 + 7e6b5b2 commit f4f3d52

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

include/swift/Driver/Driver.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@ class Driver {
201201
/// Indicates whether the driver should check that the input files exist.
202202
bool CheckInputFilesExist = true;
203203

204+
/// Indicates that this driver never actually executes any commands but is
205+
/// just set up to retrieve the swift-frontend invocation that would be
206+
/// executed during compilation.
207+
bool IsDummyDriverForFrontendInvocation = false;
208+
204209
public:
205210
Driver(StringRef DriverExecutable, StringRef Name,
206211
ArrayRef<const char *> Args, DiagnosticEngine &Diags);
@@ -227,6 +232,14 @@ class Driver {
227232

228233
void setCheckInputFilesExist(bool Value) { CheckInputFilesExist = Value; }
229234

235+
bool isDummyDriverForFrontendInvocation() const {
236+
return IsDummyDriverForFrontendInvocation;
237+
}
238+
239+
void setIsDummyDriverForFrontendInvocation(bool Value) {
240+
IsDummyDriverForFrontendInvocation = Value;
241+
}
242+
230243
/// Creates an appropriate ToolChain for a given driver, given the target
231244
/// specified in \p Args (or the default target). Sets the value of \c
232245
/// DefaultTargetTriple from \p Args as a side effect.

lib/Driver/DarwinToolChains.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,9 +901,15 @@ void
901901
toolchains::Darwin::validateArguments(DiagnosticEngine &diags,
902902
const llvm::opt::ArgList &args,
903903
StringRef defaultTarget) const {
904-
// Validating arclite library path when link-objc-runtime.
905-
validateLinkObjcRuntimeARCLiteLib(*this, diags, args);
906-
904+
if (!getDriver().isDummyDriverForFrontendInvocation()) {
905+
// Validating arclite library path when link-objc-runtime.
906+
// If the driver is just set up to retrieve the swift-frontend invocation,
907+
// we don't care about link-time, so we can skip this step, which may be
908+
// expensive since it might call to `xcrun` to find `clang` and `arclite`
909+
// relative to `clang`.
910+
validateLinkObjcRuntimeARCLiteLib(*this, diags, args);
911+
}
912+
907913
// Validating apple platforms deployment targets.
908914
validateDeploymentTarget(*this, diags, args);
909915
validateTargetVariant(*this, diags, args, defaultTarget);

lib/Driver/FrontendUtil.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ bool swift::driver::getSingleFrontendInvocationFromDriverArguments(
7575
// CompilerInvocation may wish to remap inputs to source buffers.
7676
TheDriver.setCheckInputFilesExist(false);
7777

78+
TheDriver.setIsDummyDriverForFrontendInvocation(true);
79+
7880
std::unique_ptr<llvm::opt::InputArgList> ArgList =
7981
TheDriver.parseArgStrings(ArrayRef<const char *>(Args).slice(1));
8082
if (Diags.hadAnyError())

0 commit comments

Comments
 (0)