[PATCH] D31199: Add "(compatible with the GNU linker)" to the -version output.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 21 13:28:01 PDT 2017

ruiu updated this revision to Diff 92534.
ruiu added a comment.

Make it plural. By the way, this patch reminds me why all major
browsers are still claiming that they are "Mozilla/5.0" in their
user-agent strings.



Index: lld/test/ELF/driver.test
--- lld/test/ELF/driver.test
+++ lld/test/ELF/driver.test
@@ -17,7 +17,7 @@
 # RUN: ld.lld --version 2>&1 | FileCheck -check-prefix=VERSION %s
+# VERSION: LLD {{.*}} (compatible with the GNU linkers)
 # RUN: not ld.lld -v 2>&1 | FileCheck -check-prefix=VERSION %s
Index: lld/ELF/Driver.cpp
--- lld/ELF/Driver.cpp
+++ lld/ELF/Driver.cpp
@@ -300,11 +300,28 @@
-  // 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.
+  // Handle -v or -version.
+  //
+  // A note about "compatible with the 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 make it, there are still a lot
+  // of "configure" scripts 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_version) || Args.hasArg(OPT_v))
-    message(getLLDVersion());
+    message(getLLDVersion() + " (compatible with the 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))

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31199.92534.patch
Type: text/x-patch
Size: 2151 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170321/741a057c/attachment.bin>

More information about the llvm-commits mailing list