[lld] r298532 - Add "(compatible with GNU linkers)" to the -version output.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 22 11:04:58 PDT 2017


Author: ruiu
Date: Wed Mar 22 13:04:57 2017
New Revision: 298532

URL: http://llvm.org/viewvc/llvm-project?rev=298532&view=rev
Log:
Add "(compatible with GNU linkers)" to the -version output.

Previous output:

  $ ld.lld -version
  LLD 5.0.0

New output:

  $ ld.lld -version
  LLD 5.0.0 (compatible with GNU linkers)

Differential Revision: https://reviews.llvm.org/D31199

Modified:
    lld/trunk/ELF/Driver.cpp
    lld/trunk/test/ELF/driver.test

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=298532&r1=298531&r2=298532&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Wed Mar 22 13:04:57 2017
@@ -300,11 +300,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))
-    message(getLLDVersion());
+  // 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))
+    message(getLLDVersion() + " (compatible with GNU linkers)");
+
+  // 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: lld/trunk/test/ELF/driver.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/driver.test?rev=298532&r1=298531&r2=298532&view=diff
==============================================================================
--- lld/trunk/test/ELF/driver.test (original)
+++ lld/trunk/test/ELF/driver.test Wed Mar 22 13:04:57 2017
@@ -17,7 +17,7 @@
 # HELP: USAGE:
 
 # RUN: ld.lld --version 2>&1 | FileCheck -check-prefix=VERSION %s
-# VERSION: LLD
+# VERSION: LLD {{.*}} (compatible with GNU linkers)
 
 # RUN: not ld.lld -v 2>&1 | FileCheck -check-prefix=VERSION %s
 




More information about the llvm-commits mailing list