Fix searching for library twice: DynamicLibraryManage::loadLibrary takes optional argument indicating if the path is from a previous lookupLibrary call.
(cherry picked from commit 244b26d6021e55e214ee078bec99e7c6a43d4820)
This commit is contained in:
committed by
sftnight
parent
39dd90e183
commit
5a0e1bca84
@ -87,14 +87,17 @@ namespace cling {
|
||||
|
||||
///\brief Loads a shared library.
|
||||
///
|
||||
///\param [in] libStem - The file to loaded.
|
||||
///\param [in] libStem - The file to load.
|
||||
///\param [in] permanent - If false, the file can be unloaded later.
|
||||
///\param [in] resolved - Whether libStem is an absolute path or resolved
|
||||
/// from a previous call to DynamicLibraryManager::lookupLibrary
|
||||
///
|
||||
///\returns kLoadLibSuccess on success, kLoadLibAlreadyLoaded if the library
|
||||
/// was already loaded, kLoadLibError if the library cannot be found or any
|
||||
/// other error was encountered.
|
||||
///
|
||||
LoadLibResult loadLibrary(const std::string& libStem, bool permanent);
|
||||
LoadLibResult loadLibrary(const std::string& libStem, bool permanent,
|
||||
bool resolved = false );
|
||||
|
||||
void unloadLibrary(llvm::StringRef libStem);
|
||||
|
||||
|
@ -323,10 +323,14 @@ namespace cling {
|
||||
|
||||
DynamicLibraryManager::LoadLibResult
|
||||
DynamicLibraryManager::loadLibrary(const std::string& libStem,
|
||||
bool permanent) {
|
||||
std::string canonicalLoadedLib = lookupLibrary(libStem);
|
||||
if (canonicalLoadedLib.empty())
|
||||
return kLoadLibNotFound;
|
||||
bool permanent, bool resolved) {
|
||||
std::string lResolved;
|
||||
const std::string &canonicalLoadedLib = resolved ? libStem : lResolved;
|
||||
if (!resolved) {
|
||||
lResolved = lookupLibrary(libStem);
|
||||
if (lResolved.empty())
|
||||
return kLoadLibNotFound;
|
||||
}
|
||||
|
||||
if (m_LoadedLibraries.find(canonicalLoadedLib) != m_LoadedLibraries.end())
|
||||
return kLoadLibAlreadyLoaded;
|
||||
|
@ -1214,7 +1214,7 @@ namespace cling {
|
||||
DynamicLibraryManager* DLM = getDynamicLibraryManager();
|
||||
std::string canonicalLib = DLM->lookupLibrary(filename);
|
||||
if (allowSharedLib && !canonicalLib.empty()) {
|
||||
switch (DLM->loadLibrary(filename, /*permanent*/false)) {
|
||||
switch (DLM->loadLibrary(canonicalLib, /*permanent*/false, /*resolved*/true)) {
|
||||
case DynamicLibraryManager::kLoadLibSuccess: // Intentional fall through
|
||||
case DynamicLibraryManager::kLoadLibAlreadyLoaded:
|
||||
return kSuccess;
|
||||
|
Reference in New Issue
Block a user