[lld] r316329 - Add the --version option.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 23 07:57:53 PDT 2017


Author: ruiu
Date: Mon Oct 23 07:57:53 2017
New Revision: 316329

URL: http://llvm.org/viewvc/llvm-project?rev=316329&view=rev
Log:
Add the --version option.

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

Modified:
    lld/trunk/COFF/Driver.cpp
    lld/trunk/COFF/Options.td
    lld/trunk/test/COFF/driver.test

Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=316329&r1=316328&r2=316329&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Mon Oct 23 07:57:53 2017
@@ -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<const c
     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);

Modified: lld/trunk/COFF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Options.td?rev=316329&r1=316328&r2=316329&view=diff
==============================================================================
--- lld/trunk/COFF/Options.td (original)
+++ lld/trunk/COFF/Options.td Mon Oct 23 07:57:53 2017
@@ -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">;

Modified: lld/trunk/test/COFF/driver.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/driver.test?rev=316329&r1=316328&r2=316329&view=diff
==============================================================================
--- lld/trunk/test/COFF/driver.test (original)
+++ lld/trunk/test/COFF/driver.test Mon Oct 23 07:57:53 2017
@@ -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]+}}




More information about the llvm-commits mailing list