diff options
author | Rui Ueyama <ruiu@google.com> | 2017-04-26 19:15:42 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2017-04-26 19:15:42 +0000 |
commit | ed4ac00409586b093a6d482ba47307f387a40743 (patch) | |
tree | c166db0a3022758f7ef9a5bb41a344464e80939b | |
parent | f3e1544a0fd20c1f8875d86ee53fda439301da11 (diff) |
Merge r298532: Add "(compatible with GNU linkers)" to the -version output.
Cherrypick request: http://bugs.llvm.org/show_bug.cgi?id=32601
git-svn-id: https://llvm.org/svn/llvm-project/lld/branches/release_40@301444 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | ELF/Driver.cpp | 26 | ||||
-rw-r--r-- | test/ELF/driver.test | 2 |
2 files changed, 22 insertions, 6 deletions
diff --git a/ELF/Driver.cpp b/ELF/Driver.cpp index 50b701175..4f4466a8a 100644 --- a/ELF/Driver.cpp +++ b/ELF/Driver.cpp @@ -281,11 +281,27 @@ void LinkerDriver::main(ArrayRef<const char *> ArgsArr, bool CanExitEarly) { 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; diff --git a/test/ELF/driver.test b/test/ELF/driver.test index 80d19cb4d..8c5d887d9 100644 --- a/test/ELF/driver.test +++ b/test/ELF/driver.test @@ -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 |