================
@@ -397,33 +397,48 @@ Interpreter::getOrcRuntimePath(const driver::ToolChain 
&TC) {
   std::optional<std::string> CompilerRTPath = TC.getCompilerRTPath();
   std::optional<std::string> ResourceDir = TC.getRuntimePath();
 
-  if (!CompilerRTPath) {
-    return llvm::make_error<llvm::StringError>("CompilerRT path not found",
-                                               std::error_code());
+  if (!CompilerRTPath && !ResourceDir) {
+    return llvm::make_error<llvm::StringError>(
+        "Neither CompilerRT path nor ResourceDir path found",
+        std::error_code());
   }
 
   const std::array<const char *, 3> OrcRTLibNames = {
       "liborc_rt.a", "liborc_rt_osx.a", "liborc_rt-x86_64.a"};
 
-  for (const char *LibName : OrcRTLibNames) {
-    llvm::SmallString<256> CandidatePath((*CompilerRTPath).c_str());
-    llvm::sys::path::append(CandidatePath, LibName);
-
-    if (llvm::sys::fs::exists(CandidatePath)) {
-      return CandidatePath.str().str();
+  auto findInDir = [&](llvm::StringRef Base) -> std::optional<std::string> {
+    for (const char *LibName : OrcRTLibNames) {
+      llvm::SmallString<256> CandidatePath(Base);
+      llvm::sys::path::append(CandidatePath, LibName);
+      if (llvm::sys::fs::exists(CandidatePath))
+        return std::string(CandidatePath.str());
     }
+    return std::nullopt;
+  };
+
+  std::string searched;
+
+  if (CompilerRTPath) {
----------------
anutosh491 wrote:

Adressed.

https://github.com/llvm/llvm-project/pull/165852
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to