xref: /freebsd/contrib/llvm-project/lld/Common/Version.cpp (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
10b57cec5SDimitry Andric //===- lib/Common/Version.cpp - LLD Version Number ---------------*- C++-=====//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric // This file defines several version-related utility functions for LLD.
100b57cec5SDimitry Andric //
110b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric 
130b57cec5SDimitry Andric #include "lld/Common/Version.h"
140b57cec5SDimitry Andric #include "VCSVersion.inc"
15*0fca6ea1SDimitry Andric #include "llvm/Support/VCSRevision.h"
160b57cec5SDimitry Andric 
170b57cec5SDimitry Andric // Returns a version string, e.g.:
18349cc55cSDimitry Andric // LLD 14.0.0 (https://github.com/llvm/llvm-project.git
19349cc55cSDimitry Andric // 2d9759c7902c5cbc9a7e3ab623321d5578d51687)
getLLDVersion()200b57cec5SDimitry Andric std::string lld::getLLDVersion() {
215ffd83dbSDimitry Andric #ifdef LLD_VENDOR
225ffd83dbSDimitry Andric #define LLD_VENDOR_DISPLAY LLD_VENDOR " "
230b57cec5SDimitry Andric #else
245ffd83dbSDimitry Andric #define LLD_VENDOR_DISPLAY
250b57cec5SDimitry Andric #endif
26*0fca6ea1SDimitry Andric #if defined(LLVM_REPOSITORY) && defined(LLVM_REVISION)
27*0fca6ea1SDimitry Andric   return LLD_VENDOR_DISPLAY "LLD " LLD_VERSION_STRING " (" LLVM_REPOSITORY
28*0fca6ea1SDimitry Andric                             " " LLVM_REVISION ")";
29*0fca6ea1SDimitry Andric #else
305ffd83dbSDimitry Andric   return LLD_VENDOR_DISPLAY "LLD " LLD_VERSION_STRING;
31*0fca6ea1SDimitry Andric #endif
325ffd83dbSDimitry Andric #undef LLD_VENDOR_DISPLAY
330b57cec5SDimitry Andric }
34