llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: YunQiang Su (wzssyqa)

<details>
<summary>Changes</summary>

In ToolChain::getCompilerRT:
  If none is found, use a file name from the new layout, which may get
  printed in an error message, aiding users in knowing what Clang is
  looking for.

But in current code, the old layout is printed if no libclang_rt.builtin is 
found with cmd like:
  ./bin/clang --target=aarch64-linux-gnu -rtlib=compiler-rt hello.c

aarch64-linux-gnu/bin/ld: cannot find 
&lt;path&gt;/lib/clang/19/lib/linux/libclang_rt.builtins-aarch64.a: No such 
file or directory

---
Full diff: https://github.com/llvm/llvm-project/pull/87319.diff


1 Files Affected:

- (modified) clang/lib/Driver/ToolChain.cpp (+10-1) 


``````````diff
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 03450fc0f57b93..3b5960992a9dd1 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -692,12 +692,21 @@ std::string ToolChain::getCompilerRT(const ArgList &Args, 
StringRef Component,
       buildCompilerRTBasename(Args, Component, Type, /*AddArch=*/true);
   SmallString<128> OldPath(getCompilerRTPath());
   llvm::sys::path::append(OldPath, CRTBasename);
-  if (Path.empty() || getVFS().exists(OldPath))
+  if (getVFS().exists(OldPath))
     return std::string(OldPath);
 
   // If none is found, use a file name from the new layout, which may get
   // printed in an error message, aiding users in knowing what Clang is
   // looking for.
+  if (Path.empty()) {
+    CRTBasename =
+        buildCompilerRTBasename(Args, Component, Type, /*AddArch=*/false);
+    SmallString<128> NewP(D.ResourceDir);
+    llvm::sys::path::append(NewP, "lib");
+    llvm::sys::path::append(NewP, getTriple().str());
+    llvm::sys::path::append(NewP, CRTBasename);
+    return std::string(NewP);
+  }
   return std::string(Path);
 }
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/87319
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to