diff options
-rw-r--r-- | lld/ELF/Driver.cpp | 5 | ||||
-rw-r--r-- | lld/ELF/Driver.h | 1 | ||||
-rw-r--r-- | lld/ELF/DriverUtils.cpp | 8 | ||||
-rw-r--r-- | lld/include/lld/Config/Version.h | 32 | ||||
-rw-r--r-- | lld/lib/Config/Version.cpp | 51 |
5 files changed, 22 insertions, 75 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index e1cfb745935..516970ac53a 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -19,6 +19,7 @@ #include "SymbolTable.h" #include "Target.h" #include "Writer.h" +#include "lld/Config/Version.h" #include "lld/Driver/Driver.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" @@ -287,7 +288,7 @@ void LinkerDriver::main(ArrayRef<const char *> ArgsArr) { return; } if (Args.hasArg(OPT_version)) - outs() << getVersionString(); + outs() << getLLDVersion() << "\n"; if (const char *Path = getReproduceOption(Args)) { // Note that --reproduce is a debug option so you can ignore it @@ -296,7 +297,7 @@ void LinkerDriver::main(ArrayRef<const char *> ArgsArr) { if (F) { Cpio.reset(*F); Cpio->append("response.txt", createResponseFile(Args)); - Cpio->append("version.txt", getVersionString()); + Cpio->append("version.txt", (getLLDVersion() + "\n").str()); } else error(F.getError(), Twine("--reproduce: failed to open ") + Path + ".cpio"); diff --git a/lld/ELF/Driver.h b/lld/ELF/Driver.h index 1acbdd0a866..c1619ec19b9 100644 --- a/lld/ELF/Driver.h +++ b/lld/ELF/Driver.h @@ -70,7 +70,6 @@ enum { }; void printHelp(const char *Argv0); -std::string getVersionString(); std::vector<uint8_t> parseHexstring(StringRef S); std::string createResponseFile(const llvm::opt::InputArgList &Args); diff --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp index a583ee0af76..b7a90358a8b 100644 --- a/lld/ELF/DriverUtils.cpp +++ b/lld/ELF/DriverUtils.cpp @@ -98,14 +98,6 @@ void elf::printHelp(const char *Argv0) { Table.PrintHelp(outs(), Argv0, "lld", false); } -std::string elf::getVersionString() { - std::string Version = getLLDVersion(); - std::string Repo = getLLDRepositoryVersion(); - if (Repo.empty()) - return "LLD " + Version + "\n"; - return "LLD " + Version + " " + Repo + "\n"; -} - // Reconstructs command line arguments so that so that you can re-run // the same command with the same inputs. This is for --reproduce. std::string elf::createResponseFile(const opt::InputArgList &Args) { diff --git a/lld/include/lld/Config/Version.h b/lld/include/lld/Config/Version.h index 41433c1175e..92164bc00de 100644 --- a/lld/include/lld/Config/Version.h +++ b/lld/include/lld/Config/Version.h @@ -6,11 +6,9 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -/// -/// \file -/// \brief Defines version macros and version-related utility functions -/// for lld. -/// +// +// Defines a version-related utility function. +// //===----------------------------------------------------------------------===// #ifndef LLD_VERSION_H @@ -18,32 +16,8 @@ #include "lld/Config/Version.inc" #include "llvm/ADT/StringRef.h" -#include <string> - -/// \brief Helper macro for LLD_VERSION_STRING. -#define LLD_MAKE_VERSION_STRING2(X) #X - -/// \brief Helper macro for LLD_VERSION_STRING. -#define LLD_MAKE_VERSION_STRING(X, Y) LLD_MAKE_VERSION_STRING2(X.Y) - -/// \brief A string that describes the lld version number, e.g., "1.0". -#define LLD_VERSION_STRING \ - LLD_MAKE_VERSION_STRING(LLD_VERSION_MAJOR, LLD_VERSION_MINOR) namespace lld { -/// \brief Retrieves the repository path (e.g., Subversion path) that -/// identifies the particular lld branch, tag, or trunk from which this -/// lld was built. -llvm::StringRef getLLDRepositoryPath(); - -/// \brief Retrieves the repository revision number (or identifer) from which -/// this lld was built. -llvm::StringRef getLLDRevision(); - -/// \brief Retrieves the full repository version that is an amalgamation of -/// the information in getLLDRepositoryPath() and getLLDRevision(). -std::string getLLDRepositoryVersion(); - /// \brief Retrieves a string representing the complete lld version. llvm::StringRef getLLDVersion(); } diff --git a/lld/lib/Config/Version.cpp b/lld/lib/Config/Version.cpp index 60687b9d894..9baf54a7c57 100644 --- a/lld/lib/Config/Version.cpp +++ b/lld/lib/Config/Version.cpp @@ -12,46 +12,27 @@ //===----------------------------------------------------------------------===// #include "lld/Config/Version.h" -#include "llvm/Support/raw_ostream.h" using namespace llvm; -namespace lld { +#define JOIN2(X) #X +#define JOIN(X, Y) JOIN2(X.Y) -StringRef getLLDRepositoryPath() { -#ifdef LLD_REPOSITORY_STRING - return LLD_REPOSITORY_STRING; -#else - return ""; -#endif -} - -StringRef getLLDRevision() { -#ifdef LLD_REVISION_STRING - return LLD_REVISION_STRING; -#else - return ""; -#endif -} - -std::string getLLDRepositoryVersion() { - std::string S = getLLDRepositoryPath(); - std::string T = getLLDRevision(); - if (S.empty() && T.empty()) - return ""; - if (!S.empty() && !T.empty()) - return "(" + S + " " + T + ")"; - if (!S.empty()) - return "(" + S + ")"; - return "(" + T + ")"; -} +// A string that describes the lld version number, e.g., "1.0". +#define VERSION JOIN(LLD_VERSION_MAJOR, LLD_VERSION_MINOR) -StringRef getLLDVersion() { -#ifdef LLD_VERSION_STRING - return LLD_VERSION_STRING; +// A string that describes SVN repository, e.g., +// " (https://llvm.org/svn/llvm-project/lld/trunk 284614)". +#if defined(LLD_REPOSITORY_STRING) && defined(LLD_REVISION_STRING) +#define REPO " (" LLD_REPOSITORY_STRING " " LLD_REVISION_STRING ")" +#elif defined(LLD_REPOSITORY_STRING) +#define REPO " (" LLD_REPOSITORY_STRING ")" +#elif defined(LLD_REVISION_STRING) +#define REPO " (" LLD_REVISION_STRING ")" #else - return ""; +#define REPO "" #endif -} -} // end namespace lld +// Returns a version string, e.g., +// "LLD 4.0 (https://llvm.org/svn/llvm-project/lld/trunk 284614)". +StringRef lld::getLLDVersion() { return "LLD " VERSION REPO; } |