Skip to content

Commit e1b88c8

Browse files
committed
[clang] Only use major version in resource dir
This causes unnecessary churn for downstreams. For the full discussion, see https://discourse.llvm.org/t/should-we-continue-embed-the-full-llvm-version-in-lib-clang/62094 Differential Revision: https://reviews.llvm.org/D125860
1 parent baf4930 commit e1b88c8

File tree

11 files changed

+23
-16
lines changed

11 files changed

+23
-16
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ code bases.
176176
g(42);
177177
}
178178

179+
- Clang's resource dir used to include the full clang version. It will now
180+
include only the major version. The new resource directory is
181+
``$prefix/lib/clang/$CLANG_MAJOR_VERSION`` and can be queried using
182+
``clang -print-resource-dir``, just like before.
183+
179184
What's New in Clang |release|?
180185
==============================
181186
Some of the major new features and improvements to Clang are listed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#define CLANG_VERSION @CLANG_VERSION@
22
#define CLANG_VERSION_STRING "@CLANG_VERSION@"
33
#define CLANG_VERSION_MAJOR @CLANG_VERSION_MAJOR@
4+
#define CLANG_VERSION_MAJOR_STRING "@CLANG_VERSION_MAJOR@"
45
#define CLANG_VERSION_MINOR @CLANG_VERSION_MINOR@
56
#define CLANG_VERSION_PATCHLEVEL @CLANG_VERSION_PATCHLEVEL@

clang/lib/Driver/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ std::string Driver::GetResourcesPath(StringRef BinaryPath,
182182
// ../lib gets us to lib/ in both cases.
183183
P = llvm::sys::path::parent_path(Dir);
184184
llvm::sys::path::append(P, CLANG_INSTALL_LIBDIR_BASENAME, "clang",
185-
CLANG_VERSION_STRING);
185+
CLANG_VERSION_MAJOR_STRING);
186186
}
187187

188188
return std::string(P.str());

clang/lib/Headers/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ set(openmp_wrapper_files
281281
openmp_wrappers/new
282282
)
283283

284-
set(output_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include)
284+
set(output_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION_MAJOR}/include)
285285
set(out_files)
286286
set(generated_files)
287287

@@ -434,7 +434,7 @@ add_header_target("openmp-resource-headers" ${openmp_wrapper_files})
434434
add_header_target("windows-resource-headers" ${windows_only_files})
435435
add_header_target("utility-resource-headers" ${utility_files})
436436

437-
set(header_install_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
437+
set(header_install_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION_MAJOR}/include)
438438

439439
#############################################################
440440
# Install rules for the catch-all clang-resource-headers target

clang/lib/Tooling/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ else()
6060
$<TARGET_FILE:clang-ast-dump>
6161
# Skip this in debug mode because parsing AST.h is too slow
6262
--skip-processing=${skip_expensive_processing}
63-
-I ${LLVM_BINARY_DIR}/lib/clang/${CLANG_VERSION}/include
63+
-I ${LLVM_BINARY_DIR}/lib/clang/${CLANG_VERSION_MAJOR}/include
6464
-I ${CLANG_SOURCE_DIR}/include
6565
-I ${LLVM_BINARY_DIR}/tools/clang/include
6666
-I ${LLVM_BINARY_DIR}/include

clang/runtime/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/)
8282
-DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}
8383
-DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config
8484
-DLLVM_LIT_ARGS=${LLVM_LIT_ARGS}
85-
-DCOMPILER_RT_OUTPUT_DIR=${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}
85+
-DCOMPILER_RT_OUTPUT_DIR=${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION_MAJOR}
8686
-DCOMPILER_RT_EXEC_OUTPUT_DIR=${LLVM_RUNTIME_OUTPUT_INTDIR}
87-
-DCOMPILER_RT_INSTALL_PATH:PATH=lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}
87+
-DCOMPILER_RT_INSTALL_PATH:PATH=lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION_MAJOR}
8888
-DCOMPILER_RT_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
8989
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
9090
-DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX}

compiler-rt/cmake/base-config-ix.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ endif()
3838

3939
if (LLVM_TREE_AVAILABLE)
4040
# Compute the Clang version from the LLVM version.
41-
# FIXME: We should be able to reuse CLANG_VERSION variable calculated
41+
# FIXME: We should be able to reuse CLANG_VERSION_MAJOR variable calculated
4242
# in Clang cmake files, instead of copying the rules here.
43-
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
43+
string(REGEX MATCH "^[0-9]+" CLANG_VERSION_MAJOR
4444
${PACKAGE_VERSION})
4545
# Setup the paths where compiler-rt runtimes and headers should be stored.
46-
set(COMPILER_RT_OUTPUT_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION})
46+
set(COMPILER_RT_OUTPUT_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION_MAJOR})
4747
set(COMPILER_RT_EXEC_OUTPUT_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
48-
set(COMPILER_RT_INSTALL_PATH lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION})
48+
set(COMPILER_RT_INSTALL_PATH lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION_MAJOR})
4949
option(COMPILER_RT_INCLUDE_TESTS "Generate and build compiler-rt unit tests."
5050
${LLVM_INCLUDE_TESTS})
5151
option(COMPILER_RT_ENABLE_WERROR "Fail and stop if warning is triggered"

lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static bool DefaultComputeClangResourceDirectory(FileSpec &lldb_shlib_spec,
5555
static const llvm::StringRef kResourceDirSuffixes[] = {
5656
// LLVM.org's build of LLDB uses the clang resource directory placed
5757
// in $install_dir/lib{,64}/clang/$clang_version.
58-
CLANG_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_STRING,
58+
CLANG_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_MAJOR_STRING,
5959
// swift-lldb uses the clang resource directory copied from swift, which
6060
// by default is placed in $install_dir/lib{,64}/lldb/clang. LLDB places
6161
// it there, so we use LLDB_INSTALL_LIBDIR_BASENAME.

lldb/unittests/Expression/ClangParserTest.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ TEST_F(ClangHostTest, ComputeClangResourceDirectory) {
3838
#if !defined(_WIN32)
3939
std::string path_to_liblldb = "/foo/bar/lib/";
4040
std::string path_to_clang_dir =
41-
"/foo/bar/" LLDB_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_STRING;
41+
"/foo/bar/" LLDB_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_MAJOR_STRING;
4242
#else
4343
std::string path_to_liblldb = "C:\\foo\\bar\\lib";
44-
std::string path_to_clang_dir = "C:\\foo\\bar\\lib\\clang\\" CLANG_VERSION_STRING;
44+
std::string path_to_clang_dir =
45+
"C:\\foo\\bar\\lib\\clang\\" CLANG_VERSION_MAJOR_STRING;
4546
#endif
4647
EXPECT_EQ(ComputeClangResourceDir(path_to_liblldb), path_to_clang_dir);
4748

llvm/cmake/modules/LLVMExternalProjectUtils.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ function(llvm_ExternalProject_Add name source_dir)
255255
set(llvm_config_path ${LLVM_CONFIG_PATH})
256256

257257
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
258-
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
258+
string(REGEX MATCH "^[0-9]+" CLANG_VERSION_MAJOR
259259
${PACKAGE_VERSION})
260-
set(resource_dir "${LLVM_LIBRARY_DIR}/clang/${CLANG_VERSION}")
260+
set(resource_dir "${LLVM_LIBRARY_DIR}/clang/${CLANG_VERSION_MAJOR}")
261261
set(flag_types ASM C CXX MODULE_LINKER SHARED_LINKER EXE_LINKER)
262262
foreach(type ${flag_types})
263263
set(${type}_flag -DCMAKE_${type}_FLAGS=-resource-dir=${resource_dir})

polly/lib/External/isl/interface/extract_interface.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static llvm::cl::opt<string> OutputLanguage(llvm::cl::Required,
109109
llvm::cl::value_desc("name"));
110110

111111
static const char *ResourceDir =
112-
CLANG_PREFIX "/lib/clang/" CLANG_VERSION_STRING;
112+
CLANG_PREFIX "/lib/clang/" CLANG_VERSION_MAJOR_STRING;
113113

114114
/* Does decl have an attribute of the following form?
115115
*

0 commit comments

Comments
 (0)