@@ -1127,10 +1127,15 @@ void SwiftASTContext::DiagnoseWarnings(Process &process, Module &module) const {
1127
1127
// / by converting ${toolchain}/usr/(local)?/lib/swift/host/plugins
1128
1128
// / into ${toolchain}/usr/bin/swift-plugin-server
1129
1129
// / FIXME: move this to Host, it may be platform-specific.
1130
- static std::string GetPluginServer (llvm::StringRef plugin_library_path) {
1131
- llvm::StringRef path = llvm::sys::path::parent_path (plugin_library_path);
1132
- if (llvm::sys::path::filename (path) != " plugins" )
1133
- return {};
1130
+ std::string
1131
+ SwiftASTContext::GetPluginServer (llvm::StringRef plugin_library_path) {
1132
+ llvm::StringRef path = plugin_library_path;
1133
+ if (llvm::sys::path::filename (path) != " plugins" ) {
1134
+ // Strip off a plugin name.
1135
+ path = llvm::sys::path::parent_path (plugin_library_path);
1136
+ if (llvm::sys::path::filename (path) != " plugins" )
1137
+ return {};
1138
+ }
1134
1139
path = llvm::sys::path::parent_path (path);
1135
1140
if (llvm::sys::path::filename (path) != " host" )
1136
1141
return {};
@@ -1145,10 +1150,7 @@ static std::string GetPluginServer(llvm::StringRef plugin_library_path) {
1145
1150
path = llvm::sys::path::parent_path (path);
1146
1151
llvm::SmallString<256 > server (path);
1147
1152
llvm::sys::path::append (server, " bin" , " swift-plugin-server" );
1148
- std::string result (server);
1149
- if (FileSystem::Instance ().Exists (result))
1150
- return result;
1151
- return {};
1153
+ return std::string (server);
1152
1154
}
1153
1155
1154
1156
static std::string GetPluginServerForSDK (llvm::StringRef sdk_path) {
@@ -1325,8 +1327,12 @@ static bool DeserializeAllCompilerFlags(swift::CompilerInvocation &invocation,
1325
1327
// Rewrite them to go through an ABI-compatible swift-plugin-server.
1326
1328
if (known_plugin_search_paths.insert (path).second ) {
1327
1329
if (known_external_plugin_search_paths.insert (path).second ) {
1328
- std::string server = get_plugin_server (
1329
- path, [&]() { return GetPluginServer (path); });
1330
+ std::string server = get_plugin_server (path, [&]() {
1331
+ std::string server = SwiftASTContext::GetPluginServer (path);
1332
+ if (!server.empty () && !FileSystem::Instance ().Exists (server))
1333
+ server.clear ();
1334
+ return server;
1335
+ });
1330
1336
if (server.empty ())
1331
1337
continue ;
1332
1338
if (exists (path))
0 commit comments