[llvm] [BOLT] Enable standalone build (PR #97130)
Tristan Ross via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 23 19:08:54 PDT 2024
================
@@ -38,13 +38,33 @@ std::string RuntimeLibrary::getLibPath(StringRef ToolPath,
llvm::sys::path::append(LibPath, "lib" LLVM_LIBDIR_SUFFIX);
}
llvm::sys::path::append(LibPath, LibFileName);
- if (!llvm::sys::fs::exists(LibPath)) {
- errs() << "BOLT-ERROR: library not found: " << LibPath << "\n";
- exit(1);
- }
return std::string(LibPath);
}
+std::string RuntimeLibrary::getLibPathByInstalled(StringRef LibFileName) {
+ SmallString<128> LibPath =
+ llvm::sys::path::root_path(CMAKE_INSTALL_FULL_LIBDIR);
+ llvm::sys::path::append(LibPath, LibFileName);
+ return std::string(LibPath);
+}
+
+std::string RuntimeLibrary::getLibPath(StringRef ToolPath,
+ StringRef LibFileName) {
+ std::string ByTool = getLibPathByToolPath(ToolPath, LibFileName);
+ if (llvm::sys::fs::exists(ByTool)) {
+ return ByTool;
+ }
+
+ std::string ByInstalled = getLibPathByInstalled(LibFileName);
+ if (llvm::sys::fs::exists(ByInstalled)) {
+ return ByInstalled;
+ }
+
+ errs() << "BOLT-ERROR: library not found: " << ByTool << " or " << ByInstalled
+ << "\n";
+ exit(1);
+}
+
----------------
RossComputerGuy wrote:
I think we can just throw a fs exists check on top of `getLibPath` and return the lib file name when that results in true.
https://github.com/llvm/llvm-project/pull/97130
More information about the llvm-commits
mailing list