[PATCH] D56215: [lld] [ELF] Include default search paths for NetBSD driver

Michał Górny via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 13 14:05:27 PST 2019


mgorny updated this revision to Diff 181484.
mgorny marked 7 inline comments as done.
mgorny set the repository for this revision to rLLD LLVM Linker.
mgorny added a comment.
Herald added a subscriber: fedor.sergeev.

Split target logic into D56650 <https://reviews.llvm.org/D56650>, switched to using target to determine which paths to apply. While at it, copied the code from clang since it now can match exactly.


Repository:
  rLLD LLVM Linker

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

https://reviews.llvm.org/D56215

Files:
  ELF/Driver.cpp
  ELF/Driver.h


Index: ELF/Driver.h
===================================================================
--- ELF/Driver.h
+++ ELF/Driver.h
@@ -33,6 +33,7 @@
 private:
   void setTargetTriple(StringRef argv0, llvm::opt::InputArgList &Args);
   void readConfigs(llvm::opt::InputArgList &Args);
+  void appendDefaultSearchPaths();
   void createFiles(llvm::opt::InputArgList &Args);
   void inferMachineType();
   template <class ELFT> void link(llvm::opt::InputArgList &Args);
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -366,6 +366,56 @@
       error("unknown -z value: " + StringRef(Arg->getValue()));
 }
 
+void LinkerDriver::appendDefaultSearchPaths() {
+  if (Config->TargetTriple.isOSNetBSD()) {
+    // NetBSD driver relies on the linker knowing the default search paths.
+    // Please keep this in sync with clang/lib/Driver/ToolChains/NetBSD.cpp
+    // (NetBSD::NetBSD constructor)
+    switch (Config->TargetTriple.getArch()) {
+    case llvm::Triple::x86:
+      Config->SearchPaths.push_back("=/usr/lib/i386");
+      break;
+    case llvm::Triple::arm:
+    case llvm::Triple::armeb:
+    case llvm::Triple::thumb:
+    case llvm::Triple::thumbeb:
+      switch (Config->TargetTriple.getEnvironment()) {
+      case llvm::Triple::EABI:
+      case llvm::Triple::GNUEABI:
+        Config->SearchPaths.push_back("=/usr/lib/eabi");
+        break;
+      case llvm::Triple::EABIHF:
+      case llvm::Triple::GNUEABIHF:
+        Config->SearchPaths.push_back("=/usr/lib/eabihf");
+        break;
+      default:
+        Config->SearchPaths.push_back("=/usr/lib/oabi");
+        break;
+      }
+      break;
+#if 0 // TODO
+    case llvm::Triple::mips64:
+    case llvm::Triple::mips64el:
+      if (tools::mips::hasMipsAbiArg(Args, "o32"))
+        Config->SearchPaths.push_back("=/usr/lib/o32");
+      else if (tools::mips::hasMipsAbiArg(Args, "64"))
+        Config->SearchPaths.push_back("=/usr/lib/64");
+      break;
+#endif
+    case llvm::Triple::ppc:
+      Config->SearchPaths.push_back("=/usr/lib/powerpc");
+      break;
+    case llvm::Triple::sparc:
+      Config->SearchPaths.push_back("=/usr/lib/sparc");
+      break;
+    default:
+      break;
+    }
+
+    Config->SearchPaths.push_back("=/usr/lib");
+  }
+}
+
 void LinkerDriver::main(ArrayRef<const char *> ArgsArr) {
   ELFOptTable Parser;
   opt::InputArgList Args = Parser.parse(ArgsArr.slice(1));
@@ -397,6 +447,7 @@
   setTargetTriple(ArgsArr[0], Args);
   readConfigs(Args);
   checkZOptions(Args);
+  appendDefaultSearchPaths();
 
   // Handle -v or -version.
   //


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56215.181484.patch
Type: text/x-patch
Size: 2626 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190113/66ee4d07/attachment.bin>


More information about the llvm-commits mailing list