[lld] 44f7b40 - Add vendor macro to "lld"

Steven Wan via llvm-commits llvm-commits at lists.llvm.org
Mon May 11 15:35:20 PDT 2020


Author: stevewan
Date: 2020-05-11T18:35:11-04:00
New Revision: 44f7b4024982e75dd7826a93558242d3c9f1aed8

URL: https://github.com/llvm/llvm-project/commit/44f7b4024982e75dd7826a93558242d3c9f1aed8
DIFF: https://github.com/llvm/llvm-project/commit/44f7b4024982e75dd7826a93558242d3c9f1aed8.diff

LOG: Add vendor macro to "lld"

Summary:
Add the vendor macro to "lld" for extended version output support,
such that it's able to print additional version info. This is
consistent with the Clang and LLVM version printer, and the
additional version message can be provided via PACKAGE_VENDOR.

Reviewers: hubert.reinterpretcast, kbarton, cebowleratibm, rzurob, ruiu

Reviewed By: hubert.reinterpretcast

Subscribers: emaste, mgorny, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D79026

Added: 
    

Modified: 
    lld/CMakeLists.txt
    lld/Common/Version.cpp

Removed: 
    


################################################################################
diff  --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt
index 7bbc59c7a811..0cddb52889c8 100644
--- a/lld/CMakeLists.txt
+++ b/lld/CMakeLists.txt
@@ -142,6 +142,13 @@ set(LLD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 set(LLD_INCLUDE_DIR ${LLD_SOURCE_DIR}/include )
 set(LLD_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
 
+set(LLD_VENDOR ${PACKAGE_VENDOR} CACHE STRING
+  "Vendor-specific text for showing with version information.")
+
+if(LLD_VENDOR)
+  add_definitions(-DLLD_VENDOR="${LLD_VENDOR}")
+endif()
+
 # Compute the LLD version from the LLVM version.
 string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" LLD_VERSION
   ${PACKAGE_VERSION})

diff  --git a/lld/Common/Version.cpp b/lld/Common/Version.cpp
index ae10f2f28b22..cd9fcd4f4059 100644
--- a/lld/Common/Version.cpp
+++ b/lld/Common/Version.cpp
@@ -19,9 +19,16 @@
 // Returns a version string, e.g.:
 // lld 9.0.0 (https://github.com/llvm/llvm-project.git 9efdd7ac5e914d3c9fa1ef)
 std::string lld::getLLDVersion() {
+#ifdef LLD_VENDOR
+#define LLD_VENDOR_DISPLAY LLD_VENDOR " "
+#else
+#define LLD_VENDOR_DISPLAY
+#endif
 #if defined(LLD_REPOSITORY) && defined(LLD_REVISION)
-  return "LLD " LLD_VERSION_STRING " (" LLD_REPOSITORY " " LLD_REVISION ")";
+  return LLD_VENDOR_DISPLAY "LLD " LLD_VERSION_STRING " (" LLD_REPOSITORY
+                            " " LLD_REVISION ")";
 #else
-  return "LLD " LLD_VERSION_STRING;
+  return LLD_VENDOR_DISPLAY "LLD " LLD_VERSION_STRING;
 #endif
+#undef LLD_VENDOR_DISPLAY
 }


        


More information about the llvm-commits mailing list