[PATCH] D109051: Use Component in OpenBSD::getCompilerRT to find libraries

Frederic Cambus via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 26 12:12:34 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3caa32b26f5a: [Driver] Use Component in OpenBSD::getCompilerRT to find libraries (authored by blackgnezdo, committed by fcambus).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109051/new/

https://reviews.llvm.org/D109051

Files:
  clang/lib/Driver/ToolChains/OpenBSD.cpp


Index: clang/lib/Driver/ToolChains/OpenBSD.cpp
===================================================================
--- clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -17,6 +17,7 @@
 #include "clang/Driver/SanitizerArgs.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/VirtualFileSystem.h"
 
 using namespace clang::driver;
 using namespace clang::driver::tools;
@@ -334,12 +335,21 @@
   CmdArgs.push_back(Profiling ? "-lpthread_p" : "-lpthread");
 }
 
-std::string OpenBSD::getCompilerRT(const ArgList &Args,
-                                   StringRef Component,
+std::string OpenBSD::getCompilerRT(const ArgList &Args, StringRef Component,
                                    FileType Type) const {
-  SmallString<128> Path(getDriver().SysRoot);
-  llvm::sys::path::append(Path, "/usr/lib/libcompiler_rt.a");
-  return std::string(Path.str());
+  if (Component == "builtins") {
+    SmallString<128> Path(getDriver().SysRoot);
+    llvm::sys::path::append(Path, "/usr/lib/libcompiler_rt.a");
+    return std::string(Path.str());
+  }
+  SmallString<128> P(getDriver().ResourceDir);
+  std::string CRTBasename =
+      buildCompilerRTBasename(Args, Component, Type, /*AddArch=*/false);
+  llvm::sys::path::append(P, "lib", CRTBasename);
+  // Checks if this is the base system case which uses a different location.
+  if (getVFS().exists(P))
+    return std::string(P.str());
+  return ToolChain::getCompilerRT(Args, Component, Type);
 }
 
 Tool *OpenBSD::buildAssembler() const {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109051.440084.patch
Type: text/x-patch
Size: 1568 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220626/d4857a0a/attachment.bin>


More information about the cfe-commits mailing list