svn commit: r316029 - head/contrib/llvm/tools/lld/ELF

Ed Maste emaste at FreeBSD.org
Mon Mar 27 16:01:18 UTC 2017


Author: emaste
Date: Mon Mar 27 16:01:16 2017
New Revision: 316029
URL: https://svnweb.freebsd.org/changeset/base/316029

Log:
  lld: hack version and help output for compatibility with libtool
  
  GNU libtool checks the output from invoking the linker with --version
  and --help, in order to determine the linker "flavour" and the command-
  ine arguments to use for various link operations (e.g. generating shared
  libraries). To detect GNU ld it looks for the strings "GNU" and
  "supported targets:.*elf". Since LLD is compatible with GNU ld we
  include those same strings to fool libtool.
  
  Quoting from a comment in the change:
      This is somewhat ugly hack, but in reality, we had no choice other
      than doing this. Considering the very long release cycle of Libtool,
      it is not easy to improve it to recognize LLD as a GNU compatible
      linker in a timely manner. Even if we can make it, there are still a
      lot of "configure" scripts out there that are generated by old
      version of Libtool. We cannot convince every software developer to
      migrate to the latest version and re-generate scripts. So we have
      this hack.
  
  Upstream LLVM revisions r298532, r298568, r298591
  
  Obtained from:	LLVM
  MFC after:	1 week
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/contrib/llvm/tools/lld/ELF/Driver.cpp
  head/contrib/llvm/tools/lld/ELF/DriverUtils.cpp

Modified: head/contrib/llvm/tools/lld/ELF/Driver.cpp
==============================================================================
--- head/contrib/llvm/tools/lld/ELF/Driver.cpp	Mon Mar 27 15:20:31 2017	(r316028)
+++ head/contrib/llvm/tools/lld/ELF/Driver.cpp	Mon Mar 27 16:01:16 2017	(r316029)
@@ -281,11 +281,27 @@ void LinkerDriver::main(ArrayRef<const c
     return;
   }
 
-  // GNU linkers disagree here. Though both -version and -v are mentioned
-  // in help to print the version information, GNU ld just normally exits,
-  // while gold can continue linking. We are compatible with ld.bfd here.
-  if (Args.hasArg(OPT_version) || Args.hasArg(OPT_v))
-    outs() << getLLDVersion() << "\n";
+  // Handle -v or -version.
+  //
+  // A note about "compatible with GNU linkers" message: this is a hack for
+  // scripts generated by GNU Libtool 2.4.6 (released in February 2014 and
+  // still the newest version in March 2017) or earlier to recognize LLD as
+  // a GNU compatible linker. As long as an output for the -v option
+  // contains "GNU" or "with BFD", they recognize us as GNU-compatible.
+  //
+  // This is somewhat ugly hack, but in reality, we had no choice other
+  // than doing this. Considering the very long release cycle of Libtool,
+  // it is not easy to improve it to recognize LLD as a GNU compatible
+  // linker in a timely manner. Even if we can make it, there are still a
+  // lot of "configure" scripts out there that are generated by old version
+  // of Libtool. We cannot convince every software developer to migrate to
+  // the latest version and re-generate scripts. So we have this hack.
+  if (Args.hasArg(OPT_v) || Args.hasArg(OPT_version))
+    outs() << getLLDVersion() << " (compatible with GNU linkers)\n";
+
+  // ld.bfd always exits after printing out the version string.
+  // ld.gold proceeds if a given option is -v. Because gold's behavior
+  // is more permissive than ld.bfd, we chose what gold does here.
   if (Args.hasArg(OPT_version))
     return;
 

Modified: head/contrib/llvm/tools/lld/ELF/DriverUtils.cpp
==============================================================================
--- head/contrib/llvm/tools/lld/ELF/DriverUtils.cpp	Mon Mar 27 15:20:31 2017	(r316028)
+++ head/contrib/llvm/tools/lld/ELF/DriverUtils.cpp	Mon Mar 27 16:01:16 2017	(r316029)
@@ -120,6 +120,20 @@ opt::InputArgList ELFOptTable::parse(Arr
 void elf::printHelp(const char *Argv0) {
   ELFOptTable Table;
   Table.PrintHelp(outs(), Argv0, "lld", false);
+  outs() << "\n";
+
+  // Scripts generated by Libtool versions up to at least 2.4.6 (the most
+  // recent version as of March 2017) expect /supported targets:.* elf/ in
+  // a message for the -help option. If it doesn't match, the scripts
+  // assume that the linker doesn't support very basic features such as
+  // shared libraries. Therefore, we need to print out at least "elf".
+  // Here, we print out all the targets that we support.
+  outs() << Argv0 << ": supported targets: "
+         << "elf32-i386 elf32-iamcu elf32-littlearm elf32-powerpc "
+         << "elf32-tradbigmips elf32-tradlittlemips "
+         << "elf32-ntradbigmips elf32-ntradlittlemips elf32-x86-64 "
+         << "elf64-amdgpu elf64-littleaarch64 elf64-powerpc "
+         << "elf64-tradbigmips elf64-tradlittlemips elf64-x86-64\n";
 }
 
 // Reconstructs command line arguments so that so that you can re-run


More information about the svn-src-all mailing list