@@ -995,6 +995,20 @@ SwiftASTContext::SwiftASTContext(std::string description,
995
995
GetClangModulesCacheProperty ());
996
996
}
997
997
998
+ static std::string DerivePlatformPluginPath (StringRef sdk_path) {
999
+ llvm::StringRef path = sdk_path;
1000
+ path = llvm::sys::path::parent_path (path);
1001
+ if (llvm::sys::path::filename (path) != " SDKs" )
1002
+ return {};
1003
+ path = llvm::sys::path::parent_path (path);
1004
+ if (llvm::sys::path::filename (path) != " Developer" )
1005
+ return {};
1006
+ path = llvm::sys::path::parent_path (path);
1007
+ if (!path.ends_with (" .platform" ))
1008
+ return {};
1009
+ return std::string (path) + " /usr/local/lib/swift/host/plugins" ;
1010
+ }
1011
+
998
1012
void SwiftASTContext::SetCompilerInvocationLLDBOverrides () {
999
1013
swift::IRGenOptions &ir_gen_opts =
1000
1014
m_compiler_invocation_ap->getIRGenOptions ();
@@ -1018,6 +1032,20 @@ void SwiftASTContext::SetCompilerInvocationLLDBOverrides() {
1018
1032
// Bypass deserialization safety to allow deserializing internal details from
1019
1033
// swiftmodule files.
1020
1034
lang_opts.EnableDeserializationSafety = false ;
1035
+
1036
+ // Platform plugin path (macOS hosts only).
1037
+ swift::PluginSearchOption::ExternalPluginPath platform_plugins;
1038
+ platform_plugins.SearchPath =
1039
+ DerivePlatformPluginPath (m_compiler_invocation_ap->getSDKPath ());
1040
+ if (!platform_plugins.SearchPath .empty ()) {
1041
+ platform_plugins.ServerPath = GetPluginServer (platform_plugins.SearchPath );
1042
+ if (!platform_plugins.ServerPath .empty ()) {
1043
+ if (FileSystem::Instance ().Exists (platform_plugins.SearchPath ) &&
1044
+ FileSystem::Instance ().Exists (platform_plugins.ServerPath ))
1045
+ m_compiler_invocation_ap->getSearchPathOptions ()
1046
+ .PluginSearchOpts .push_back (platform_plugins);
1047
+ }
1048
+ }
1021
1049
}
1022
1050
1023
1051
SwiftASTContext::~SwiftASTContext () {
@@ -1272,7 +1300,6 @@ static bool DeserializeAllCompilerFlags(swift::CompilerInvocation &invocation,
1272
1300
for (; !buf.empty (); buf = buf.substr (info.bytes )) {
1273
1301
llvm::SmallVector<swift::serialization::SearchPath> searchPaths;
1274
1302
swift::serialization::ExtendedValidationInfo extended_validation_info;
1275
- auto &langOpts = invocation.getLangOptions ();
1276
1303
info = swift::serialization::validateSerializedAST (
1277
1304
buf, invocation.getSILOptions ().EnableOSSAModules ,
1278
1305
/* requiredSDK*/ StringRef (), &extended_validation_info,
0 commit comments