mirror of
https://github.com/intel/llvm.git
synced 2026-02-05 04:46:27 +08:00
ELF: Add --version option.
llvm-svn: 262167
This commit is contained in:
@@ -164,6 +164,11 @@ void LinkerDriver::main(ArrayRef<const char *> ArgsArr) {
|
||||
initSymbols();
|
||||
|
||||
opt::InputArgList Args = parseArgs(&Alloc, ArgsArr);
|
||||
if (Args.hasArg(OPT_version)) {
|
||||
printVersion();
|
||||
return;
|
||||
}
|
||||
|
||||
readConfigs(Args);
|
||||
createFiles(Args);
|
||||
checkOptions(Args);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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::BumpPtrAllocator *A,
|
||||
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);
|
||||
|
||||
@@ -119,6 +119,9 @@ def undefined : Joined<["--"], "undefined=">,
|
||||
|
||||
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">;
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
|
||||
#include "lld/Config/Version.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user