[lld] r262167 - ELF: Add --version option.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 27 19:18:07 PST 2016
Author: ruiu
Date: Sat Feb 27 21:18:07 2016
New Revision: 262167
URL: http://llvm.org/viewvc/llvm-project?rev=262167&view=rev
Log:
ELF: Add --version option.
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/Driver.h
lld/trunk/ELF/DriverUtils.cpp
lld/trunk/ELF/Options.td
lld/trunk/lib/Config/Version.cpp
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=262167&r1=262166&r2=262167&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Sat Feb 27 21:18:07 2016
@@ -164,6 +164,11 @@ void LinkerDriver::main(ArrayRef<const c
initSymbols();
opt::InputArgList Args = parseArgs(&Alloc, ArgsArr);
+ if (Args.hasArg(OPT_version)) {
+ printVersion();
+ return;
+ }
+
readConfigs(Args);
createFiles(Args);
checkOptions(Args);
Modified: lld/trunk/ELF/Driver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.h?rev=262167&r1=262166&r2=262167&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.h (original)
+++ lld/trunk/ELF/Driver.h Sat Feb 27 21:18:07 2016
@@ -53,6 +53,8 @@ enum {
#undef OPTION
};
+void printVersion();
+
std::string findFromSearchPaths(StringRef Path);
std::string searchLibrary(StringRef Path);
std::string buildSysrootedPath(llvm::StringRef Dir, llvm::StringRef File);
Modified: lld/trunk/ELF/DriverUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/DriverUtils.cpp?rev=262167&r1=262166&r2=262167&view=diff
==============================================================================
--- lld/trunk/ELF/DriverUtils.cpp (original)
+++ lld/trunk/ELF/DriverUtils.cpp Sat Feb 27 21:18:07 2016
@@ -15,6 +15,7 @@
#include "Driver.h"
#include "Error.h"
+#include "lld/Config/Version.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
@@ -78,6 +79,13 @@ opt::InputArgList elf::parseArgs(llvm::B
return Args;
}
+void elf::printVersion() {
+ outs() << "LLD " << getLLDVersion();
+ std::string S = getLLDRepositoryVersion();
+ if (!S.empty())
+ outs() << " " << S << "\n";
+}
+
std::string elf::findFromSearchPaths(StringRef Path) {
for (StringRef Dir : Config->SearchPaths) {
std::string FullPath = buildSysrootedPath(Dir, Path);
Modified: lld/trunk/ELF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Options.td?rev=262167&r1=262166&r2=262167&view=diff
==============================================================================
--- lld/trunk/ELF/Options.td (original)
+++ lld/trunk/ELF/Options.td Sat Feb 27 21:18:07 2016
@@ -119,6 +119,9 @@ def undefined : Joined<["--"], "undefine
def verbose : Flag<["--"], "verbose">;
+def version : Flag<["--", "-"], "version">,
+ HelpText<"Display the version number">;
+
def whole_archive : Flag<["--", "-"], "whole-archive">,
HelpText<"Force load of all members in a static library">;
Modified: lld/trunk/lib/Config/Version.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Config/Version.cpp?rev=262167&r1=262166&r2=262167&view=diff
==============================================================================
--- lld/trunk/lib/Config/Version.cpp (original)
+++ lld/trunk/lib/Config/Version.cpp Sat Feb 27 21:18:07 2016
@@ -13,8 +13,6 @@
#include "lld/Config/Version.h"
#include "llvm/Support/raw_ostream.h"
-#include <cstdlib>
-#include <cstring>
using namespace llvm;
Modified: lld/trunk/test/ELF/driver.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/driver.test?rev=262167&r1=262166&r2=262167&view=diff
==============================================================================
--- lld/trunk/test/ELF/driver.test (original)
+++ lld/trunk/test/ELF/driver.test Sat Feb 27 21:18:07 2016
@@ -1,19 +1,21 @@
# REQUIRES: x86
# RUN: not ld.lld -unknown1 -unknown2 -m foo /no/such/file -lnosuchlib \
-# RUN: 2>&1 | FileCheck %s
+# RUN: 2>&1 | FileCheck -check-prefix=UNKNOWN %s
-# CHECK: warning: unknown argument: -unknown1
-# CHECK: warning: unknown argument: -unknown2
-# CHECK: unknown argument(s) found
-# CHECK: Unknown emulation: foo
-# CHECK: cannot open /no/such/file
-# CHECK: Unable to find library -lnosuchlib
+# UNKNOWN: warning: unknown argument: -unknown1
+# UNKNOWN: warning: unknown argument: -unknown2
+# UNKNOWN: unknown argument(s) found
+# UNKNOWN: Unknown emulation: foo
+# UNKNOWN: cannot open /no/such/file
+# UNKNOWN: Unable to find library -lnosuchlib
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-# RUN: not ld.lld %t -o /no/such/file 2>&1 | FileCheck -check-prefix=CHECK2 %s
+# RUN: not ld.lld %t -o /no/such/file 2>&1 | FileCheck -check-prefix=MISSING %s
+# MISSING: failed to open /no/such/file
-# CHECK2: failed to open /no/such/file
+# RUN: ld.lld --version 2>&1 | FileCheck -check-prefix=VERSION %s
+# VERSION: LLD
.globl _start
_start:
More information about the llvm-commits
mailing list