[lld] r287448 - [ELF] - Exit on --version call.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 19 10:14:24 PST 2016
Author: grimar
Date: Sat Nov 19 12:14:24 2016
New Revision: 287448
URL: http://llvm.org/viewvc/llvm-project?rev=287448&view=rev
Log:
[ELF] - Exit on --version call.
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.
This fixes PR31057.
Differential revision: https://reviews.llvm.org/D26865
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/Options.td
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=287448&r1=287447&r2=287448&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Sat Nov 19 12:14:24 2016
@@ -290,8 +290,15 @@ void LinkerDriver::main(ArrayRef<const c
printHelp(ArgsArr[0]);
return;
}
- if (Args.hasArg(OPT_version))
+
+ // 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";
+ if (Args.hasArg(OPT_version))
+ return;
+
Config->ExitEarly = CanExitEarly && !Args.hasArg(OPT_full_shutdown);
if (const char *Path = getReproduceOption(Args)) {
Modified: lld/trunk/ELF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Options.td?rev=287448&r1=287447&r2=287448&view=diff
==============================================================================
--- lld/trunk/ELF/Options.td (original)
+++ lld/trunk/ELF/Options.td Sat Nov 19 12:14:24 2016
@@ -206,9 +206,11 @@ def unresolved_symbols: J<"unresolved-sy
def rsp_quoting: J<"rsp-quoting=">,
HelpText<"Quoting style for response files. Values supported: windows|posix">;
+def v: Flag<["-"], "v">, HelpText<"Display the version number">;
+
def verbose: F<"verbose">, HelpText<"Verbose mode">;
-def version: F<"version">, HelpText<"Display the version number">;
+def version: F<"version">, HelpText<"Display the version number and exit">;
def version_script: S<"version-script">,
HelpText<"Read a version script">;
@@ -266,7 +268,6 @@ def alias_Ttext: J<"Ttext=">, Alias<Ttex
def alias_undefined_eq: J<"undefined=">, Alias<undefined>;
def alias_undefined_u: JoinedOrSeparate<["-"], "u">, Alias<undefined>;
def alias_version_V: Flag<["-"], "V">, Alias<version>;
-def alias_version_v: Flag<["-"], "v">, Alias<version>;
def alias_wrap_wrap: J<"wrap=">, Alias<wrap>;
// Our symbol resolution algorithm handles symbols in archive files differently
Modified: lld/trunk/test/ELF/driver.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/driver.test?rev=287448&r1=287447&r2=287448&view=diff
==============================================================================
--- lld/trunk/test/ELF/driver.test (original)
+++ lld/trunk/test/ELF/driver.test Sat Nov 19 12:14:24 2016
@@ -16,9 +16,11 @@
# RUN: ld.lld --help 2>&1 | FileCheck -check-prefix=HELP %s
# HELP: USAGE:
-# RUN: not ld.lld --version 2>&1 | FileCheck -check-prefix=VERSION %s
+# RUN: ld.lld --version 2>&1 | FileCheck -check-prefix=VERSION %s
# VERSION: LLD
+# RUN: not ld.lld -v 2>&1 | FileCheck -check-prefix=VERSION %s
+
## Attempt to link DSO with -r
# RUN: ld.lld -shared %t -o %t.so
# RUN: not ld.lld -r %t.so %t -o %tfail 2>&1 | FileCheck -check-prefix=ERR %s
More information about the llvm-commits
mailing list