Skip to content

[lld][ELF] Support LLVM repository and LLVM revision information #97323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lld/Common/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,6 +23,11 @@ std::string lld::getLLDVersion() {
#else
#define LLD_VENDOR_DISPLAY
#endif
#if defined(LLVM_REPOSITORY) || defined(LLVM_REVISION)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you meant && here.

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
}
2 changes: 1 addition & 1 deletion lld/ELF/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lld/MinGW/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lld/test/ELF/version.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lld/test/MinGW/driver.test
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading