Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Apr 2017 01:57:03 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r316432 - stable/11/contrib/llvm/tools/lld/ELF
Message-ID:  <201704030157.v331v33E009927@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Mon Apr  3 01:57:03 2017
New Revision: 316432
URL: https://svnweb.freebsd.org/changeset/base/316432

Log:
  MFC r316029: 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
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  stable/11/contrib/llvm/tools/lld/ELF/Driver.cpp
  stable/11/contrib/llvm/tools/lld/ELF/DriverUtils.cpp
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/llvm/tools/lld/ELF/Driver.cpp
==============================================================================
--- stable/11/contrib/llvm/tools/lld/ELF/Driver.cpp	Mon Apr  3 00:46:32 2017	(r316431)
+++ stable/11/contrib/llvm/tools/lld/ELF/Driver.cpp	Mon Apr  3 01:57:03 2017	(r316432)
@@ -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: stable/11/contrib/llvm/tools/lld/ELF/DriverUtils.cpp
==============================================================================
--- stable/11/contrib/llvm/tools/lld/ELF/DriverUtils.cpp	Mon Apr  3 00:46:32 2017	(r316431)
+++ stable/11/contrib/llvm/tools/lld/ELF/DriverUtils.cpp	Mon Apr  3 01:57:03 2017	(r316432)
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201704030157.v331v33E009927>