[llvm] [llvm-bolt] Modify `getLibPath` to enable `--runtime-instrumentation-lib` option handle full path correctly.(llvm#99772) (PR #99806)

Zimo Ji via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 21 02:26:27 PDT 2024


https://github.com/lltsdyp created https://github.com/llvm/llvm-project/pull/99806

None

>From ede137b646939fa78dd454fb961d55678bbea2a9 Mon Sep 17 00:00:00 2001
From: Jizimo <jizimo0430 at outlook.com>
Date: Sun, 21 Jul 2024 17:24:18 +0800
Subject: [PATCH] [llvm-bolt] Modify `getLibPath` to enable
 `--runtime-instrumentation-lib` option handle full path correctly.

---
 bolt/lib/RuntimeLibs/RuntimeLibrary.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/bolt/lib/RuntimeLibs/RuntimeLibrary.cpp b/bolt/lib/RuntimeLibs/RuntimeLibrary.cpp
index 276b034d71f96..0826847ee1189 100644
--- a/bolt/lib/RuntimeLibs/RuntimeLibrary.cpp
+++ b/bolt/lib/RuntimeLibs/RuntimeLibrary.cpp
@@ -28,6 +28,12 @@ void RuntimeLibrary::anchor() {}
 
 std::string RuntimeLibrary::getLibPath(StringRef ToolPath,
                                        StringRef LibFileName) {
+  // Handle full path.
+  // It is weird that append LibFileName to LibPath when user gives a full path.
+  if(LibFileName[0]=='/')
+  {
+    return LibFileName.str();
+  }
   StringRef Dir = llvm::sys::path::parent_path(ToolPath);
   SmallString<128> LibPath = llvm::sys::path::parent_path(Dir);
   llvm::sys::path::append(LibPath, "lib" LLVM_LIBDIR_SUFFIX);



More information about the llvm-commits mailing list