Skip to content

Commit 1d6f6cf

Browse files
author
git apple-llvm automerger
committed
Merge commit '60e2a629ab9c' from swift/release/5.9 into stable/20221013
2 parents 38cb6fb + 60e2a62 commit 1d6f6cf

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

lldb/include/lldb/Host/HostInfoBase.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ class HostInfoBase {
147147
FileSpec &lldb_shlib_spec, FileSpec &file_spec, bool verify) {
148148
return false;
149149
}
150+
151+
/// Return the default set of library paths to search in. This allows a
152+
/// platform specific extension for system libraries that may need to be
153+
/// resolved (e.g. `/usr/lib` on Unicies and `Path` on Windows).
154+
static std::vector<std::string> GetSwiftLibrarySearchPaths() { return {}; }
150155
#endif
151156

152157
protected:

lldb/include/lldb/Host/windows/HostInfoWindows.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class HostInfoWindows : public HostInfoBase {
4242
static bool ComputeSwiftResourceDirectory(FileSpec &lldb_shlib_spec,
4343
FileSpec &file_spec, bool verify);
4444
static llvm::Expected<llvm::StringRef> GetSDKRoot(SDKOptions options);
45+
static std::vector<std::string> GetSwiftLibrarySearchPaths();
4546
#endif
4647

4748
private:

lldb/source/Host/windows/HostInfoWindowsSwift.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@
1313
#include "lldb/Utility/FileSpec.h"
1414
#include "lldb/Utility/LLDBLog.h"
1515
#include "lldb/Utility/Log.h"
16+
17+
#include <llvm/ADT/STLExtras.h>
18+
#include <llvm/ADT/StringExtras.h>
19+
#include <llvm/ADT/StringRef.h>
1620
#include <llvm/Support/ConvertUTF.h>
1721

22+
#include <cstdlib>
1823
#include <string>
24+
#include <vector>
1925

2026
using namespace lldb_private;
2127

@@ -60,3 +66,17 @@ llvm::Expected<llvm::StringRef> HostInfoWindows::GetSDKRoot(SDKOptions options)
6066
return g_sdkroot;
6167
return llvm::make_error<HostInfoError>("`SDKROOT` is unset");
6268
}
69+
70+
std::vector<std::string> HostInfoWindows::GetSwiftLibrarySearchPaths() {
71+
static std::once_flag g_flag;
72+
static std::vector<std::string> g_library_paths;
73+
74+
std::call_once(g_flag, []() {
75+
llvm::for_each(llvm::split(std::getenv("Path"), ";"),
76+
[](llvm::StringRef path) {
77+
g_library_paths.emplace_back(path);
78+
});
79+
});
80+
81+
return g_library_paths;
82+
}

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3233,6 +3233,8 @@ GetLibrarySearchPaths(const swift::SearchPathOptions &search_path_opts) {
32333233
paths.push_back(path);
32343234
for (std::string path : search_path_opts.LibrarySearchPaths)
32353235
paths.push_back(path);
3236+
for (const std::string &path : HostInfo::GetSwiftLibrarySearchPaths())
3237+
paths.emplace_back(path);
32363238
return paths;
32373239
}
32383240

0 commit comments

Comments
 (0)