Skip to content

TypeSystem: add a platform hook for library search path additions #6927

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lldb/include/lldb/Host/HostInfoBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ class HostInfoBase {
FileSpec &lldb_shlib_spec, FileSpec &file_spec, bool verify) {
return false;
}

/// Return the default set of library paths to search in. This allows a
/// platform specific extension for system libraries that may need to be
/// resolved (e.g. `/usr/lib` on Unicies and `Path` on Windows).
static std::vector<std::string> GetSwiftLibrarySearchPaths() { return {}; }
#endif

protected:
Expand Down
1 change: 1 addition & 0 deletions lldb/include/lldb/Host/windows/HostInfoWindows.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class HostInfoWindows : public HostInfoBase {
static bool ComputeSwiftResourceDirectory(FileSpec &lldb_shlib_spec,
FileSpec &file_spec, bool verify);
static llvm::Expected<llvm::StringRef> GetSDKRoot(SDKOptions options);
static std::vector<std::string> GetSwiftLibrarySearchPaths();
#endif

private:
Expand Down
20 changes: 20 additions & 0 deletions lldb/source/Host/windows/HostInfoWindowsSwift.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"

#include <llvm/ADT/STLExtras.h>
#include <llvm/ADT/StringExtras.h>
#include <llvm/ADT/StringRef.h>
#include <llvm/Support/ConvertUTF.h>

#include <cstdlib>
#include <string>
#include <vector>

using namespace lldb_private;

Expand Down Expand Up @@ -60,3 +66,17 @@ llvm::Expected<llvm::StringRef> HostInfoWindows::GetSDKRoot(SDKOptions options)
return g_sdkroot;
return llvm::make_error<HostInfoError>("`SDKROOT` is unset");
}

std::vector<std::string> HostInfoWindows::GetSwiftLibrarySearchPaths() {
static std::once_flag g_flag;
static std::vector<std::string> g_library_paths;

std::call_once(g_flag, []() {
llvm::for_each(llvm::split(std::getenv("Path"), ";"),
[](llvm::StringRef path) {
g_library_paths.emplace_back(path);
});
});

return g_library_paths;
}
2 changes: 2 additions & 0 deletions lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3528,6 +3528,8 @@ GetLibrarySearchPaths(const swift::SearchPathOptions &search_path_opts) {
paths.push_back(path);
for (std::string path : search_path_opts.LibrarySearchPaths)
paths.push_back(path);
for (const std::string &path : HostInfo::GetSwiftLibrarySearchPaths())
paths.emplace_back(path);
return paths;
}

Expand Down