<div dir="ltr">We may. Also, we may want to remove the length URL part and just print "trunk" as Clang does?</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 21, 2016 at 8:05 AM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">do we want to include the llvm version too? Clang --version says:<br>
<br>
clang version 3.8.0 (trunk 255273) (llvm/trunk 255300)<br>
<br>
Cheers,<br>
Rafael<br>
<br>
<br>
On 19 October 2016 at 16:53, Rui Ueyama via llvm-commits<br>
<div class="HOEnZb"><div class="h5"><<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br>
> Author: ruiu<br>
> Date: Wed Oct 19 15:53:07 2016<br>
> New Revision: 284641<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=284641&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=284641&view=rev</a><br>
> Log:<br>
> Move getVersionString to Core and simplify Version.cpp.<br>
><br>
> Modified:<br>
>     lld/trunk/ELF/Driver.cpp<br>
>     lld/trunk/ELF/Driver.h<br>
>     lld/trunk/ELF/DriverUtils.cpp<br>
>     lld/trunk/include/lld/Config/<wbr>Version.h<br>
>     lld/trunk/lib/Config/Version.<wbr>cpp<br>
><br>
> Modified: lld/trunk/ELF/Driver.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=284641&r1=284640&r2=284641&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/Driver.<wbr>cpp?rev=284641&r1=284640&r2=<wbr>284641&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/ELF/Driver.cpp (original)<br>
> +++ lld/trunk/ELF/Driver.cpp Wed Oct 19 15:53:07 2016<br>
> @@ -19,6 +19,7 @@<br>
>  #include "SymbolTable.h"<br>
>  #include "Target.h"<br>
>  #include "Writer.h"<br>
> +#include "lld/Config/Version.h"<br>
>  #include "lld/Driver/Driver.h"<br>
>  #include "llvm/ADT/StringExtras.h"<br>
>  #include "llvm/ADT/StringSwitch.h"<br>
> @@ -287,7 +288,7 @@ void LinkerDriver::main(ArrayRef<<wbr>const c<br>
>      return;<br>
>    }<br>
>    if (Args.hasArg(OPT_version))<br>
> -    outs() << getVersionString();<br>
> +    outs() << getLLDVersion() << "\n";<br>
><br>
>    if (const char *Path = getReproduceOption(Args)) {<br>
>      // Note that --reproduce is a debug option so you can ignore it<br>
> @@ -296,7 +297,7 @@ void LinkerDriver::main(ArrayRef<<wbr>const c<br>
>      if (F) {<br>
>        Cpio.reset(*F);<br>
>        Cpio->append("response.txt", createResponseFile(Args));<br>
> -      Cpio->append("version.txt", getVersionString());<br>
> +      Cpio->append("version.txt", (getLLDVersion() + "\n").str());<br>
>      } else<br>
>        error(F.getError(),<br>
>              Twine("--reproduce: failed to open ") + Path + ".cpio");<br>
><br>
> Modified: lld/trunk/ELF/Driver.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.h?rev=284641&r1=284640&r2=284641&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/Driver.<wbr>h?rev=284641&r1=284640&r2=<wbr>284641&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/ELF/Driver.h (original)<br>
> +++ lld/trunk/ELF/Driver.h Wed Oct 19 15:53:07 2016<br>
> @@ -70,7 +70,6 @@ enum {<br>
>  };<br>
><br>
>  void printHelp(const char *Argv0);<br>
> -std::string getVersionString();<br>
>  std::vector<uint8_t> parseHexstring(StringRef S);<br>
><br>
>  std::string createResponseFile(const llvm::opt::InputArgList &Args);<br>
><br>
> Modified: lld/trunk/ELF/DriverUtils.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/DriverUtils.cpp?rev=284641&r1=284640&r2=284641&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>DriverUtils.cpp?rev=284641&r1=<wbr>284640&r2=284641&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/ELF/DriverUtils.cpp (original)<br>
> +++ lld/trunk/ELF/DriverUtils.cpp Wed Oct 19 15:53:07 2016<br>
> @@ -98,14 +98,6 @@ void elf::printHelp(const char *Argv0) {<br>
>    Table.PrintHelp(outs(), Argv0, "lld", false);<br>
>  }<br>
><br>
> -std::string elf::getVersionString() {<br>
> -  std::string Version = getLLDVersion();<br>
> -  std::string Repo = getLLDRepositoryVersion();<br>
> -  if (Repo.empty())<br>
> -    return "LLD " + Version + "\n";<br>
> -  return "LLD " + Version + " " + Repo + "\n";<br>
> -}<br>
> -<br>
>  // Reconstructs command line arguments so that so that you can re-run<br>
>  // the same command with the same inputs. This is for --reproduce.<br>
>  std::string elf::createResponseFile(const opt::InputArgList &Args) {<br>
><br>
> Modified: lld/trunk/include/lld/Config/<wbr>Version.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Config/Version.h?rev=284641&r1=284640&r2=284641&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/include/lld/<wbr>Config/Version.h?rev=284641&<wbr>r1=284640&r2=284641&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/include/lld/Config/<wbr>Version.h (original)<br>
> +++ lld/trunk/include/lld/Config/<wbr>Version.h Wed Oct 19 15:53:07 2016<br>
> @@ -6,11 +6,9 @@<br>
>  // License. See LICENSE.TXT for details.<br>
>  //<br>
>  //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
> -///<br>
> -/// \file<br>
> -/// \brief Defines version macros and version-related utility functions<br>
> -/// for lld.<br>
> -///<br>
> +//<br>
> +// Defines a version-related utility function.<br>
> +//<br>
>  //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
><br>
>  #ifndef LLD_VERSION_H<br>
> @@ -18,32 +16,8 @@<br>
><br>
>  #include "lld/Config/Version.inc"<br>
>  #include "llvm/ADT/StringRef.h"<br>
> -#include <string><br>
> -<br>
> -/// \brief Helper macro for LLD_VERSION_STRING.<br>
> -#define LLD_MAKE_VERSION_STRING2(X) #X<br>
> -<br>
> -/// \brief Helper macro for LLD_VERSION_STRING.<br>
> -#define LLD_MAKE_VERSION_STRING(X, Y) LLD_MAKE_VERSION_STRING2(X.Y)<br>
> -<br>
> -/// \brief A string that describes the lld version number, e.g., "1.0".<br>
> -#define LLD_VERSION_STRING                                                     \<br>
> -  LLD_MAKE_VERSION_STRING(LLD_<wbr>VERSION_MAJOR, LLD_VERSION_MINOR)<br>
><br>
>  namespace lld {<br>
> -/// \brief Retrieves the repository path (e.g., Subversion path) that<br>
> -/// identifies the particular lld branch, tag, or trunk from which this<br>
> -/// lld was built.<br>
> -llvm::StringRef getLLDRepositoryPath();<br>
> -<br>
> -/// \brief Retrieves the repository revision number (or identifer) from which<br>
> -/// this lld was built.<br>
> -llvm::StringRef getLLDRevision();<br>
> -<br>
> -/// \brief Retrieves the full repository version that is an amalgamation of<br>
> -/// the information in getLLDRepositoryPath() and getLLDRevision().<br>
> -std::string getLLDRepositoryVersion();<br>
> -<br>
>  /// \brief Retrieves a string representing the complete lld version.<br>
>  llvm::StringRef getLLDVersion();<br>
>  }<br>
><br>
> Modified: lld/trunk/lib/Config/Version.<wbr>cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Config/Version.cpp?rev=284641&r1=284640&r2=284641&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/lib/Config/<wbr>Version.cpp?rev=284641&r1=<wbr>284640&r2=284641&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/lib/Config/Version.<wbr>cpp (original)<br>
> +++ lld/trunk/lib/Config/Version.<wbr>cpp Wed Oct 19 15:53:07 2016<br>
> @@ -12,46 +12,27 @@<br>
>  //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
><br>
>  #include "lld/Config/Version.h"<br>
> -#include "llvm/Support/raw_ostream.h"<br>
><br>
>  using namespace llvm;<br>
><br>
> -namespace lld {<br>
> +#define JOIN2(X) #X<br>
> +#define JOIN(X, Y) JOIN2(X.Y)<br>
><br>
> -StringRef getLLDRepositoryPath() {<br>
> -#ifdef LLD_REPOSITORY_STRING<br>
> -  return LLD_REPOSITORY_STRING;<br>
> -#else<br>
> -  return "";<br>
> -#endif<br>
> -}<br>
> -<br>
> -StringRef getLLDRevision() {<br>
> -#ifdef LLD_REVISION_STRING<br>
> -  return LLD_REVISION_STRING;<br>
> -#else<br>
> -  return "";<br>
> -#endif<br>
> -}<br>
> +// A string that describes the lld version number, e.g., "1.0".<br>
> +#define VERSION JOIN(LLD_VERSION_MAJOR, LLD_VERSION_MINOR)<br>
><br>
> -std::string getLLDRepositoryVersion() {<br>
> -  std::string S = getLLDRepositoryPath();<br>
> -  std::string T = getLLDRevision();<br>
> -  if (S.empty() && T.empty())<br>
> -    return "";<br>
> -  if (!S.empty() && !T.empty())<br>
> -    return "(" + S + " " + T + ")";<br>
> -  if (!S.empty())<br>
> -    return "(" + S + ")";<br>
> -  return "(" + T + ")";<br>
> -}<br>
> -<br>
> -StringRef getLLDVersion() {<br>
> -#ifdef LLD_VERSION_STRING<br>
> -  return LLD_VERSION_STRING;<br>
> +// A string that describes SVN repository, e.g.,<br>
> +// " (<a href="https://llvm.org/svn/llvm-project/lld/trunk" rel="noreferrer" target="_blank">https://llvm.org/svn/llvm-<wbr>project/lld/trunk</a> 284614)".<br>
> +#if defined(LLD_REPOSITORY_STRING) && defined(LLD_REVISION_STRING)<br>
> +#define REPO " (" LLD_REPOSITORY_STRING " " LLD_REVISION_STRING ")"<br>
> +#elif defined(LLD_REPOSITORY_STRING)<br>
> +#define REPO " (" LLD_REPOSITORY_STRING ")"<br>
> +#elif defined(LLD_REVISION_STRING)<br>
> +#define REPO " (" LLD_REVISION_STRING ")"<br>
>  #else<br>
> -  return "";<br>
> +#define REPO ""<br>
>  #endif<br>
> -}<br>
><br>
> -} // end namespace lld<br>
> +// Returns a version string, e.g.,<br>
> +// "LLD 4.0 (<a href="https://llvm.org/svn/llvm-project/lld/trunk" rel="noreferrer" target="_blank">https://llvm.org/svn/llvm-<wbr>project/lld/trunk</a> 284614)".<br>
> +StringRef lld::getLLDVersion() { return "LLD " VERSION REPO; }<br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div>