From 3a3603ff99ffd7dd7c8d166ba6d15078e33a5f71 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Tue, 25 Oct 2022 00:24:25 -0700 Subject: [PATCH] [clang] Replace BACKEND_PACKAGE_STRING with LLVM_VERSION_STRING 420d7ccbac0f499a6ff9595bdbfa99cd3376df22 introduced BACKEND_PACKAGE_STRING to replace `PACKAGE_VERSION` (llvm/Config/config.h) to support standalone builds. This is used in the output of `clang -cc1 -v`. Since llvm-config.h is available for both standalone and non-standalone builds, we can just use `LLVM_VERSION_STRING` from llvm-config.h. clang/cmake/modules/AddClang.cmake uses `VERSION_STRING "${CLANG_VERSION} (${BACKEND_PACKAGE_STRING})"`. Just simplify it to `"${CLANG_VERSION}"` so that we can remove the CMake variable BACKEND_PACKAGE_STRING. Reviewed By: tstellar Differential Revision: https://reviews.llvm.org/D136660 --- clang/CMakeLists.txt | 4 ---- clang/cmake/modules/AddClang.cmake | 2 +- clang/include/clang/Config/config.h.cmake | 3 --- clang/lib/Frontend/CompilerInstance.cpp | 7 ++++--- .../utils/gn/secondary/clang/include/clang/Config/BUILD.gn | 1 - llvm/utils/release/bump-version.py | 7 ------- .../clang/include/clang/Config/config.h | 3 --- 7 files changed, 5 insertions(+), 22 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index 202a5d2667943..7c41eadc7bf9a 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -134,10 +134,6 @@ if(CLANG_BUILT_STANDALONE) umbrella_lit_testsuite_begin(check-all) endif() # LLVM_INCLUDE_TESTS - - set(BACKEND_PACKAGE_STRING "LLVM ${LLVM_PACKAGE_VERSION}") -else() - set(BACKEND_PACKAGE_STRING "${PACKAGE_STRING}") endif() # standalone if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS) diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake index 495ed1c6f18a1..75b0080f67156 100644 --- a/clang/cmake/modules/AddClang.cmake +++ b/clang/cmake/modules/AddClang.cmake @@ -37,7 +37,7 @@ macro(set_clang_windows_version_resource_properties name) VERSION_MAJOR ${CLANG_VERSION_MAJOR} VERSION_MINOR ${CLANG_VERSION_MINOR} VERSION_PATCHLEVEL ${CLANG_VERSION_PATCHLEVEL} - VERSION_STRING "${CLANG_VERSION} (${BACKEND_PACKAGE_STRING})" + VERSION_STRING "${CLANG_VERSION}" PRODUCT_NAME "clang") endif() endmacro() diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake index fdae92ba0edbb..1069e7261278a 100644 --- a/clang/include/clang/Config/config.h.cmake +++ b/clang/include/clang/Config/config.h.cmake @@ -60,9 +60,6 @@ /* Define if we have sys/resource.h (rlimits) */ #cmakedefine CLANG_HAVE_RLIMITS ${CLANG_HAVE_RLIMITS} -/* The LLVM product name and version */ -#define BACKEND_PACKAGE_STRING "${BACKEND_PACKAGE_STRING}" - /* Linker version detected at compile time. */ #cmakedefine HOST_LINK_VERSION "${HOST_LINK_VERSION}" diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 46f97e08f4e41..c28eaba80fba8 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -41,6 +41,7 @@ #include "clang/Serialization/InMemoryModuleCache.h" #include "llvm/ADT/ScopeExit.h" #include "llvm/ADT/Statistic.h" +#include "llvm/Config/llvm-config.h" #include "llvm/Support/BuryPointer.h" #include "llvm/Support/CrashRecoveryContext.h" #include "llvm/Support/Errc.h" @@ -1023,9 +1024,9 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) { // Validate/process some options. if (getHeaderSearchOpts().Verbose) - OS << "clang -cc1 version " CLANG_VERSION_STRING - << " based upon " << BACKEND_PACKAGE_STRING - << " default target " << llvm::sys::getDefaultTargetTriple() << "\n"; + OS << "clang -cc1 version " CLANG_VERSION_STRING << " based upon LLVM " + << LLVM_VERSION_STRING << " default target " + << llvm::sys::getDefaultTargetTriple() << "\n"; if (getCodeGenOpts().TimePasses) createFrontendTimer(); diff --git a/llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn b/llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn index b446af195f5b1..e5704b6a65406 100644 --- a/llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn +++ b/llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn @@ -25,7 +25,6 @@ write_cmake_config("Config") { "CLANG_SPAWN_CC1=", "DEFAULT_SYSROOT=", "GCC_INSTALL_PREFIX=", - "BACKEND_PACKAGE_STRING=LLVM ${llvm_version}git", "ENABLE_LINKER_BUILD_ID=", "ENABLE_X86_RELAX_RELOCATIONS=1", "CLANG_ENABLE_OBJC_REWRITER=1", # FIXME: flag? diff --git a/llvm/utils/release/bump-version.py b/llvm/utils/release/bump-version.py index 9d30c4ba8f370..e508bd10c0b33 100755 --- a/llvm/utils/release/bump-version.py +++ b/llvm/utils/release/bump-version.py @@ -121,13 +121,6 @@ def process_line(self, line: str) -> str: ) if nline != line: break - # Match the BACKEND_PACKAGE_STRING in clang/config.h - elif "BACKEND_PACKAGE_STRING" in line: - nline = re.sub( - r'#define BACKEND_PACKAGE_STRING "LLVM ([0-9\.rcgit-]+)"', - f'#define BACKEND_PACKAGE_STRING "LLVM {self.version_str()}"', - line, - ) return nline diff --git a/utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h b/utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h index bb404e8b7a8e6..3bd0a63059895 100644 --- a/utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h +++ b/utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h @@ -74,9 +74,6 @@ /* Define if we have sys/resource.h (rlimits) */ /* CLANG_HAVE_RLIMITS defined conditionally below */ -/* The LLVM product name and version */ -#define BACKEND_PACKAGE_STRING "LLVM 16.0.0git" - /* Linker version detected at compile time. */ /* #undef HOST_LINK_VERSION */