aboutsummaryrefslogtreecommitdiff
path: root/lld
diff options
context:
space:
mode:
authorHongyu Chen <hongyuchy@google.com>2024-07-02 20:32:45 -0700
committerGitHub <noreply@github.com>2024-07-02 20:32:45 -0700
commit0f9fbbb63cfcd2069441aa2ebef622c9716f8dbb (patch)
tree32f0ff60b13832ce54a031c85a6706b6c5032550 /lld
parent3641efcf8cb256ddbd20f4add5ce55800cad5399 (diff)
downloadllvm-0f9fbbb63cfcd2069441aa2ebef622c9716f8dbb.zip
llvm-0f9fbbb63cfcd2069441aa2ebef622c9716f8dbb.tar.gz
llvm-0f9fbbb63cfcd2069441aa2ebef622c9716f8dbb.tar.bz2
[lld][ELF] Support LLVM repository and LLVM revision information (#97323)
Added LLVM repository and LLVM revision information for `lld::getLLDVersion()` Before this change: ``` hongyuchy@hongyuchy:~/llvm-project/.build_lld_version$ bin/ld.lld --version LLD 19.0.0 (compatible with GNU linkers) ``` After this change with LLVM_APPEND_VC_REV=on ``` hongyuchy@hongyuchy:~/llvm-project/.build_lld_version$ bin/ld.lld --version LLD 19.0.0 (https://github.com/yugier/llvm-project.git 4134b33c6a362cb462b335177d6d9e8235f04309), compatible with GNU linkers ``` with LLVM_APPEND_VC_REV=off ``` hongyuchy@hongyuchy:~/llvm-project/.build_lld_version$ bin/ld.lld --version LLD 19.0.0, compatible with GNU linkers ```
Diffstat (limited to 'lld')
-rw-r--r--lld/Common/Version.cpp7
-rw-r--r--lld/ELF/Driver.cpp2
-rw-r--r--lld/MinGW/Driver.cpp2
-rw-r--r--lld/test/ELF/version.test2
-rw-r--r--lld/test/MinGW/driver.test2
5 files changed, 10 insertions, 5 deletions
diff --git a/lld/Common/Version.cpp b/lld/Common/Version.cpp
index ec6eda6..78f7c6b 100644
--- a/lld/Common/Version.cpp
+++ b/lld/Common/Version.cpp
@@ -11,8 +11,8 @@
//===----------------------------------------------------------------------===//
#include "lld/Common/Version.h"
-
#include "VCSVersion.inc"
+#include "llvm/Support/VCSRevision.h"
// Returns a version string, e.g.:
// LLD 14.0.0 (https://github.com/llvm/llvm-project.git
@@ -23,6 +23,11 @@ std::string lld::getLLDVersion() {
#else
#define LLD_VENDOR_DISPLAY
#endif
+#if defined(LLVM_REPOSITORY) || defined(LLVM_REVISION)
+ return LLD_VENDOR_DISPLAY "LLD " LLD_VERSION_STRING " (" LLVM_REPOSITORY
+ " " LLVM_REVISION ")";
+#else
return LLD_VENDOR_DISPLAY "LLD " LLD_VERSION_STRING;
+#endif
#undef LLD_VENDOR_DISPLAY
}
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index a4863d6..7800c29 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -631,7 +631,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
// of Libtool. We cannot convince every software developer to migrate to
// the latest version and re-generate scripts. So we have this hack.
if (args.hasArg(OPT_v) || args.hasArg(OPT_version))
- message(getLLDVersion() + " (compatible with GNU linkers)");
+ message(getLLDVersion() + ", compatible with GNU linkers");
if (const char *path = getReproduceOption(args)) {
// Note that --reproduce is a debug option so you can ignore it
diff --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp
index 35fd478..1fd120a 100644
--- a/lld/MinGW/Driver.cpp
+++ b/lld/MinGW/Driver.cpp
@@ -199,7 +199,7 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
// a GNU compatible linker. As long as an output for the -v option
// contains "GNU" or "with BFD", they recognize us as GNU-compatible.
if (args.hasArg(OPT_v) || args.hasArg(OPT_version))
- message(getLLDVersion() + " (compatible with GNU linkers)");
+ message(getLLDVersion() + ", compatible with GNU linkers");
// The behavior of -v or --version is a bit strange, but this is
// needed for compatibility with GNU linkers.
diff --git a/lld/test/ELF/version.test b/lld/test/ELF/version.test
index cdeeb47..383c1ac 100644
--- a/lld/test/ELF/version.test
+++ b/lld/test/ELF/version.test
@@ -7,4 +7,4 @@
# RUN: ld.lld -V 2>&1 | FileCheck %s
# RUN: not ld.lld -V %t/not-exist 2>&1 | FileCheck %s
-# CHECK: LLD {{.*}} (compatible with GNU linkers)
+# CHECK: LLD {{.*}}, compatible with GNU linkers
diff --git a/lld/test/MinGW/driver.test b/lld/test/MinGW/driver.test
index b723c0a..44ec588 100644
--- a/lld/test/MinGW/driver.test
+++ b/lld/test/MinGW/driver.test
@@ -268,7 +268,7 @@ APPCONTAINER: -appcontainer
RUN: ld.lld -m i386pep --version 2>&1 | FileCheck -check-prefix=VERSION %s
RUN: ld.lld -m i386pep -v 2>&1 | FileCheck -check-prefix=VERSION %s
RUN: not ld.lld -m i386pep -v xyz 2>&1 | FileCheck -check-prefix=VERSION %s
-VERSION: LLD {{.*}} (compatible with GNU linkers)
+VERSION: LLD {{.*}}, compatible with GNU linkers
RUN: ld.lld -m i386pep --help 2>&1 | FileCheck -check-prefix=HELP %s
HELP: USAGE: