mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[SourceKit] Pass the main swift executable path when constructing a compiler invocation
#58786 (rdar://93030932) was failing because the `swift-frontend` invocations passed a `swiftExecutablePath` to `Invocation.parseArgs`. This caused the `ClangImporter` instance to point to a `clang` binary next to the `swift-frontend` executable while SourceKit used PATH to find `clang`. The clang executable next to `swift-frontend` doesn’t actually exist because `clang` lives in `llvm-linux-aarch64/bin` and `swift-frontend` lives in `swift-linux-aarch64/bin`. So some checks for a minimum clang verison failed for the normal build (because the executable doesn’t actually exists) while they pass during the SourceKit build (which used `clang` from `PATH`). This in turn caused the `outline-atomics` to be enabled to the SourceKit clang compiler arguments but not the clang compiler arguments for a normal build and thus resulted in two separate module cache directories (which includes the enabled features in the module directory hash). To fix this issue, also set the swift executable path for compiler invocations created from SourceKit. Fixes #58786 (rdar://93030932)
This commit is contained in:
@@ -27,6 +27,12 @@ static StringRef getRuntimeLibPath() {
|
||||
return sys::path::parent_path(SWIFTLIB_DIR);
|
||||
}
|
||||
|
||||
static SmallString<128> getSwiftExecutablePath() {
|
||||
SmallString<128> path = sys::path::parent_path(getRuntimeLibPath());
|
||||
sys::path::append(path, "bin", "swift-frontend");
|
||||
return path;
|
||||
}
|
||||
|
||||
static void *createCancallationToken() {
|
||||
static std::atomic<size_t> handle(1000);
|
||||
return reinterpret_cast<void *>(
|
||||
@@ -125,7 +131,8 @@ public:
|
||||
}
|
||||
|
||||
CursorInfoTest()
|
||||
: Ctx(*new SourceKit::Context(getRuntimeLibPath(),
|
||||
: Ctx(*new SourceKit::Context(getSwiftExecutablePath(),
|
||||
getRuntimeLibPath(),
|
||||
/*diagnosticDocumentationPath*/ "",
|
||||
SourceKit::createSwiftLangSupport,
|
||||
/*dispatchOnMain=*/false)) {
|
||||
|
||||
Reference in New Issue
Block a user