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

Greg Steuck via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 3 02:47:15 PDT 2021


blackgnezdo updated this revision to Diff 370515.
blackgnezdo edited the summary of this revision.

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
@@ -16,6 +16,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;
@@ -304,9 +305,19 @@
 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());
+  } else {
+    SmallString<128> P(getDriver().ResourceDir);
+    std::string CRTBasename =
+        buildCompilerRTBasename(Args, Component, Type, /*AddArch=*/false);
+    llvm::sys::path::append(P, "lib", CRTBasename);
+    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.370515.patch
Type: text/x-patch
Size: 1369 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210903/ff8f5873/attachment.bin>


More information about the cfe-commits mailing list