@@ -1032,10 +1032,10 @@ SwiftASTContextForModule::~SwiftASTContextForModule() {
1032
1032
1033
1033
// / This code comes from CompilerInvocation.cpp (setRuntimeResourcePath).
1034
1034
static void ConfigureResourceDirs (swift::CompilerInvocation &invocation,
1035
- FileSpec resource_dir, llvm::Triple triple) {
1035
+ StringRef resource_dir, llvm::Triple triple) {
1036
1036
// Make sure the triple is right:
1037
1037
invocation.setTargetTriple (triple.str ());
1038
- invocation.setRuntimeResourcePath (resource_dir. GetPath (). c_str () );
1038
+ invocation.setRuntimeResourcePath (resource_dir);
1039
1039
}
1040
1040
1041
1041
static const char *getImportFailureString (swift::serialization::Status status) {
@@ -1930,8 +1930,8 @@ SwiftASTContext::CreateInstance(lldb::LanguageType language, Module &module,
1930
1930
1931
1931
std::string resource_dir =
1932
1932
HostInfo::GetSwiftResourceDir (triple, swift_ast_sp->GetPlatformSDKPath ());
1933
- ConfigureResourceDirs (swift_ast_sp->GetCompilerInvocation (),
1934
- FileSpec (resource_dir), triple);
1933
+ ConfigureResourceDirs (swift_ast_sp->GetCompilerInvocation (), resource_dir,
1934
+ triple);
1935
1935
1936
1936
// Apply the working directory to all relative paths.
1937
1937
std::vector<std::string> DeserializedArgs = swift_ast_sp->GetClangArguments ();
@@ -2390,8 +2390,8 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
2390
2390
llvm::Triple triple = swift_ast_sp->GetTriple ();
2391
2391
std::string resource_dir = HostInfo::GetSwiftResourceDir (
2392
2392
triple, swift_ast_sp->GetPlatformSDKPath ());
2393
- ConfigureResourceDirs (swift_ast_sp->GetCompilerInvocation (),
2394
- FileSpec (resource_dir), triple);
2393
+ ConfigureResourceDirs (swift_ast_sp->GetCompilerInvocation (), resource_dir,
2394
+ triple);
2395
2395
const bool discover_implicit_search_paths =
2396
2396
target.GetSwiftDiscoverImplicitSearchPaths ();
2397
2397
@@ -2813,8 +2813,7 @@ void SwiftASTContext::InitializeSearchPathOptions(
2813
2813
llvm::Triple triple (GetTriple ());
2814
2814
std::string resource_dir =
2815
2815
HostInfo::GetSwiftResourceDir (triple, GetPlatformSDKPath ());
2816
- ConfigureResourceDirs (GetCompilerInvocation (), FileSpec (resource_dir),
2817
- triple);
2816
+ ConfigureResourceDirs (GetCompilerInvocation (), resource_dir, triple);
2818
2817
2819
2818
std::string sdk_path = GetPlatformSDKPath ().str ();
2820
2819
if (TargetSP target_sp = GetTargetWP ().lock ())
@@ -2855,6 +2854,20 @@ void SwiftASTContext::InitializeSearchPathOptions(
2855
2854
lpaths.insert (lpaths.begin (), " /usr/lib/swift" );
2856
2855
}
2857
2856
2857
+ // Set the default host plugin paths.
2858
+ llvm::SmallString<256 > plugin_path;
2859
+ llvm::sys::path::append (plugin_path, resource_dir, " host" , " plugins" );
2860
+ if (!FileSystem::Instance ().Exists (plugin_path)) {
2861
+ LOG_PRINTF (GetLog (LLDBLog::Types), " Host plugin path %s does not exist" ,
2862
+ plugin_path.str ().str ().c_str ());
2863
+ } else {
2864
+ std::string server = SwiftASTContext::GetPluginServer (plugin_path);
2865
+ if (!server.empty () && FileSystem::Instance ().Exists (server))
2866
+ invocation.getSearchPathOptions ().PluginSearchOpts .emplace_back (
2867
+ swift::PluginSearchOption::ExternalPluginPath{plugin_path.str ().str (),
2868
+ server});
2869
+ }
2870
+
2858
2871
llvm::StringMap<bool > processed;
2859
2872
std::vector<std::string> invocation_import_paths (
2860
2873
invocation.getSearchPathOptions ().getImportSearchPaths ());
0 commit comments