From: Rui Ueyama Date: Mon, 23 Oct 2017 14:57:53 +0000 (+0000) Subject: Add the --version option. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a4cf97bc9cfaca4697b80f3e78dd5135c4600028;p=platform%2Fupstream%2Fllvm.git Add the --version option. Differential Revision: https://reviews.llvm.org/D38972 llvm-svn: 316329 --- diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp index 988fb4b..133cf40 100644 --- a/lld/COFF/Driver.cpp +++ b/lld/COFF/Driver.cpp @@ -17,6 +17,7 @@ #include "Symbols.h" #include "Writer.h" #include "lld/Common/Driver.h" +#include "lld/Common/Version.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/BinaryFormat/Magic.h" @@ -731,6 +732,14 @@ void LinkerDriver::link(ArrayRef ArgsArr) { return; } + // Handle --version, which is an lld extension. This option is a bit odd + // because it doesn't start with "/", but we deliberately chose "--" to + // avoid conflict with /version and for compatibility with clang-cl. + if (Args.hasArg(OPT_dash_dash_version)) { + outs() << getLLDVersion() << "\n"; + return; + } + // Handle /lldmingw early, since it can potentially affect how other // options are handled. Config->MinGW = Args.hasArg(OPT_lldmingw); diff --git a/lld/COFF/Options.td b/lld/COFF/Options.td index e303624..8df7a0f 100644 --- a/lld/COFF/Options.td +++ b/lld/COFF/Options.td @@ -110,6 +110,8 @@ def msvclto : F<"msvclto">; def output_def : Joined<["/", "-"], "output-def:">; def rsp_quoting : Joined<["--"], "rsp-quoting=">, HelpText<"Quoting style for response files, 'windows' (default) or 'posix'">; +def dash_dash_version : Flag<["--"], "version">, + HelpText<"Print version information">; // Flags for debugging def lldmap : F<"lldmap">; diff --git a/lld/test/COFF/driver.test b/lld/test/COFF/driver.test index 0832350..36de6c2 100644 --- a/lld/test/COFF/driver.test +++ b/lld/test/COFF/driver.test @@ -1,3 +1,6 @@ # RUN: not lld-link nosuchfile.obj >& %t.log # RUN: FileCheck -check-prefix=MISSING %s < %t.log MISSING: nosuchfile.obj: {{[Nn]}}o such file or directory + +# RUN: lld-link --version | FileCheck -check-prefix=VERSION %s +VERSION: {{LLD [0-9]+\.[0-9]+}}