Skip to content

Commit

Permalink
Fix DLOpen symbol not found macOS
Browse files Browse the repository at this point in the history
Signed-off-by: Shreyas Atre <shreyasatre16@gmail.com>
  • Loading branch information
SAtacker committed Jan 28, 2024
1 parent 6d3a759 commit d107d24
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions lib/Interpreter/Paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,20 @@ namespace platform {
return std::string(Buffer.str());
}

#if defined(LLVM_ON_UNIX)
#if defined(_WIN32)
void* DLOpen(const std::string& Path, std::string& Err /* = nullptr */) {
auto lib = llvm::sys::DynamicLibrary::getLibrary(Path.c_str(), Err);
return lib.getOSSpecificHandle();
}

void DLClose(void* Lib, std::string& Err /* = nullptr*/) {
auto dl = llvm::sys::DynamicLibrary(Lib);
llvm::sys::DynamicLibrary::closeLibrary(dl);
if (Err) {
*Err = std::string();
}
}
#else
static void DLErr(std::string& Err) {
if (Err.empty())
return;
Expand All @@ -124,20 +137,6 @@ namespace platform {
::dlclose(Lib);
DLErr(Err);
}
#elif defined(_WIN32)

void* DLOpen(const std::string& Path, std::string& Err /* = nullptr */) {
auto lib = llvm::sys::DynamicLibrary::getLibrary(Path.c_str(), Err);
return lib.getOSSpecificHandle();
}

void DLClose(void* Lib, std::string& Err /* = nullptr*/) {
auto dl = llvm::sys::DynamicLibrary(Lib);
llvm::sys::DynamicLibrary::closeLibrary(dl);
if (Err) {
*Err = std::string();
}
}
#endif

} // namespace platform
Expand Down

0 comments on commit d107d24

Please sign in to comment.