[llvm] 3adda39 - [clang][lldb][cmake] Use new `*_INSTALL_LIBDIR_BASENAME` CPP macro
John Ericson via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 20 09:52:29 PDT 2022
Author: John Ericson
Date: 2022-08-20T12:52:21-04:00
New Revision: 3adda398cef7f56d024924158e7b17d65cbc565d
URL: https://github.com/llvm/llvm-project/commit/3adda398cef7f56d024924158e7b17d65cbc565d
DIFF: https://github.com/llvm/llvm-project/commit/3adda398cef7f56d024924158e7b17d65cbc565d.diff
LOG: [clang][lldb][cmake] Use new `*_INSTALL_LIBDIR_BASENAME` CPP macro
Use this instead of `*_LIBDIR_SUFFIX`, from which it is computed.
This gets us ready for D130586, in which `*_LIBDIR_SUFFIX` is
deprecated.
Differential Revision: https://reviews.llvm.org/D132300
Added:
Modified:
clang/CMakeLists.txt
clang/include/clang/Config/config.h.cmake
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/Cuda.cpp
lldb/cmake/modules/LLDBGenerateConfig.cmake
lldb/include/lldb/Host/Config.h.cmake
lldb/source/Host/linux/HostInfoLinux.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
lldb/unittests/Expression/ClangParserTest.cpp
llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn
utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
Removed:
################################################################################
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 60f6c162a2d55..a6782db7b5809 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -871,6 +871,8 @@ if(CLANG_BUILT_STANDALONE)
process_llvm_pass_plugins()
endif()
+set(CLANG_INSTALL_LIBDIR_BASENAME "lib${CLANG_LIBDIR_SUFFIX}")
+
configure_file(
${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake
${CLANG_BINARY_DIR}/include/clang/Config/config.h)
diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake
index dfd2f757a185b..a4083827e43f8 100644
--- a/clang/include/clang/Config/config.h.cmake
+++ b/clang/include/clang/Config/config.h.cmake
@@ -53,8 +53,8 @@
/* Default architecture for SystemZ. */
#define CLANG_SYSTEMZ_DEFAULT_ARCH "${CLANG_SYSTEMZ_DEFAULT_ARCH}"
-/* Multilib suffix for libdir. */
-#define CLANG_LIBDIR_SUFFIX "${CLANG_LIBDIR_SUFFIX}"
+/* Multilib basename for libdir. */
+#define CLANG_INSTALL_LIBDIR_BASENAME "${CLANG_INSTALL_LIBDIR_BASENAME}"
/* Relative directory for resource files */
#define CLANG_RESOURCE_DIR "${CLANG_RESOURCE_DIR}"
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 05d00a50504c4..d00f08d15ae58 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -180,7 +180,7 @@ std::string Driver::GetResourcesPath(StringRef BinaryPath,
// path of the embedding binary, which for LLVM binaries will be in bin/.
// ../lib gets us to lib/ in both cases.
P = llvm::sys::path::parent_path(Dir);
- llvm::sys::path::append(P, Twine("lib") + CLANG_LIBDIR_SUFFIX, "clang",
+ llvm::sys::path::append(P, CLANG_INSTALL_LIBDIR_BASENAME, "clang",
CLANG_VERSION_STRING);
}
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 77ce0395cf3c1..c0aec33b082a5 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -502,7 +502,8 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
SmallString<1024> Plugin;
llvm::sys::path::native(
- Twine(D.Dir) + "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold" + Suffix,
+ Twine(D.Dir) + "/../" CLANG_INSTALL_LIBDIR_BASENAME "/LLVMgold" +
+ Suffix,
Plugin);
CmdArgs.push_back(Args.MakeArgString(Plugin));
}
@@ -658,7 +659,7 @@ void tools::addOpenMPRuntimeSpecificRPath(const ToolChain &TC,
// runtime
SmallString<256> DefaultLibPath =
llvm::sys::path::parent_path(TC.getDriver().Dir);
- llvm::sys::path::append(DefaultLibPath, Twine("lib") + CLANG_LIBDIR_SUFFIX);
+ llvm::sys::path::append(DefaultLibPath, CLANG_INSTALL_LIBDIR_BASENAME);
CmdArgs.push_back("-rpath");
CmdArgs.push_back(Args.MakeArgString(DefaultLibPath));
}
@@ -671,7 +672,7 @@ void tools::addOpenMPRuntimeLibraryPath(const ToolChain &TC,
// runtime.
SmallString<256> DefaultLibPath =
llvm::sys::path::parent_path(TC.getDriver().Dir);
- llvm::sys::path::append(DefaultLibPath, Twine("lib") + CLANG_LIBDIR_SUFFIX);
+ llvm::sys::path::append(DefaultLibPath, CLANG_INSTALL_LIBDIR_BASENAME);
CmdArgs.push_back(Args.MakeArgString("-L" + DefaultLibPath));
}
@@ -1947,7 +1948,7 @@ void tools::AddStaticDeviceLibs(Compilation *C, const Tool *T,
// Add path to lib-debug folders
SmallString<256> DefaultLibPath = llvm::sys::path::parent_path(D.Dir);
- llvm::sys::path::append(DefaultLibPath, Twine("lib") + CLANG_LIBDIR_SUFFIX);
+ llvm::sys::path::append(DefaultLibPath, CLANG_INSTALL_LIBDIR_BASENAME);
LibraryPaths.emplace_back(DefaultLibPath.c_str());
// Build list of Static Device Libraries SDLs specified by -l option
@@ -2076,7 +2077,7 @@ void tools::addOpenMPDeviceRTL(const Driver &D,
// Add path to clang lib / lib64 folder.
SmallString<256> DefaultLibPath = llvm::sys::path::parent_path(D.Dir);
- llvm::sys::path::append(DefaultLibPath, Twine("lib") + CLANG_LIBDIR_SUFFIX);
+ llvm::sys::path::append(DefaultLibPath, CLANG_INSTALL_LIBDIR_BASENAME);
LibraryPaths.emplace_back(DefaultLibPath.c_str());
// Add user defined library paths from LIBRARY_PATH.
diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp
index 7ad990dda467e..40f19e4ecc6d8 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -592,7 +592,7 @@ void NVPTX::OpenMPLinker::ConstructJob(Compilation &C, const JobAction &JA,
// Add paths for the default clang library path.
SmallString<256> DefaultLibPath =
llvm::sys::path::parent_path(TC.getDriver().Dir);
- llvm::sys::path::append(DefaultLibPath, "lib" CLANG_LIBDIR_SUFFIX);
+ llvm::sys::path::append(DefaultLibPath, CLANG_INSTALL_LIBDIR_BASENAME);
CmdArgs.push_back(Args.MakeArgString(Twine("-L") + DefaultLibPath));
for (const auto &II : Inputs) {
diff --git a/lldb/cmake/modules/LLDBGenerateConfig.cmake b/lldb/cmake/modules/LLDBGenerateConfig.cmake
index 94332656b28c1..5acb7d873db49 100644
--- a/lldb/cmake/modules/LLDBGenerateConfig.cmake
+++ b/lldb/cmake/modules/LLDBGenerateConfig.cmake
@@ -19,6 +19,8 @@ check_cxx_symbol_exists(__NR_process_vm_readv "sys/syscall.h" HAVE_NR_PROCESS_VM
check_library_exists(compression compression_encode_buffer "" HAVE_LIBCOMPRESSION)
+set(LLDB_INSTALL_LIBDIR_BASENAME "lib${LLDB_LIBDIR_SUFFIX}")
+
# These checks exist in LLVM's configuration, so I want to match the LLVM names
# so that the check isn't duplicated, but we translate them into the LLDB names
# so that I don't have to change all the uses at the moment.
diff --git a/lldb/include/lldb/Host/Config.h.cmake b/lldb/include/lldb/Host/Config.h.cmake
index c24603f866d6b..14ce46f6559c8 100644
--- a/lldb/include/lldb/Host/Config.h.cmake
+++ b/lldb/include/lldb/Host/Config.h.cmake
@@ -51,7 +51,7 @@
#cmakedefine LLDB_PYTHON_HOME R"(${LLDB_PYTHON_HOME})"
-#define LLDB_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}"
+#define LLDB_INSTALL_LIBDIR_BASENAME "${LLDB_INSTALL_LIBDIR_BASENAME}"
#cmakedefine LLDB_GLOBAL_INIT_DIRECTORY R"(${LLDB_GLOBAL_INIT_DIRECTORY})"
diff --git a/lldb/source/Host/linux/HostInfoLinux.cpp b/lldb/source/Host/linux/HostInfoLinux.cpp
index 712e6983007bb..837b103a64b07 100644
--- a/lldb/source/Host/linux/HostInfoLinux.cpp
+++ b/lldb/source/Host/linux/HostInfoLinux.cpp
@@ -175,7 +175,7 @@ bool HostInfoLinux::ComputeSupportExeDirectory(FileSpec &file_spec) {
}
bool HostInfoLinux::ComputeSystemPluginsDirectory(FileSpec &file_spec) {
- FileSpec temp_file("/usr/lib" LLDB_LIBDIR_SUFFIX "/lldb/plugins");
+ FileSpec temp_file("/usr/" LLDB_INSTALL_LIBDIR_BASENAME "/lldb/plugins");
FileSystem::Instance().Resolve(temp_file);
file_spec.SetDirectory(temp_file.GetPath());
return true;
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
index 1b8ea9adfe808..dd59388cb59e0 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
@@ -55,11 +55,11 @@ static bool DefaultComputeClangResourceDirectory(FileSpec &lldb_shlib_spec,
static const llvm::StringRef kResourceDirSuffixes[] = {
// LLVM.org's build of LLDB uses the clang resource directory placed
// in $install_dir/lib{,64}/clang/$clang_version.
- "lib" CLANG_LIBDIR_SUFFIX "/clang/" CLANG_VERSION_STRING,
+ CLANG_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_STRING,
// swift-lldb uses the clang resource directory copied from swift, which
// by default is placed in $install_dir/lib{,64}/lldb/clang. LLDB places
- // it there, so we use LLDB_LIBDIR_SUFFIX.
- "lib" LLDB_LIBDIR_SUFFIX "/lldb/clang",
+ // it there, so we use LLDB_INSTALL_LIBDIR_BASENAME.
+ LLDB_INSTALL_LIBDIR_BASENAME "/lldb/clang",
};
for (const auto &Suffix : kResourceDirSuffixes) {
diff --git a/lldb/unittests/Expression/ClangParserTest.cpp b/lldb/unittests/Expression/ClangParserTest.cpp
index 4df557475314e..6c6ddf39f1349 100644
--- a/lldb/unittests/Expression/ClangParserTest.cpp
+++ b/lldb/unittests/Expression/ClangParserTest.cpp
@@ -37,7 +37,8 @@ static std::string ComputeClangResourceDir(std::string lldb_shlib_path,
TEST_F(ClangHostTest, ComputeClangResourceDirectory) {
#if !defined(_WIN32)
std::string path_to_liblldb = "/foo/bar/lib/";
- std::string path_to_clang_dir = "/foo/bar/lib" LLDB_LIBDIR_SUFFIX "/clang/" CLANG_VERSION_STRING;
+ std::string path_to_clang_dir =
+ "/foo/bar/" LLDB_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_STRING;
#else
std::string path_to_liblldb = "C:\\foo\\bar\\lib";
std::string path_to_clang_dir = "C:\\foo\\bar\\lib\\clang\\" CLANG_VERSION_STRING;
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 1d598d913501b..7af6ea8df2dc9 100644
--- a/llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
@@ -18,6 +18,7 @@ write_cmake_config("Config") {
"CLANG_DEFAULT_OBJCOPY=objcopy",
"CLANG_DEFAULT_OPENMP_RUNTIME=libomp",
"CLANG_DEFAULT_UNWINDLIB=",
+ "CLANG_INSTALL_LIBDIR_BASENAME=lib",
"CLANG_OPENMP_NVPTX_DEFAULT_ARCH=sm_35",
"CLANG_LIBDIR_SUFFIX=",
"CLANG_RESOURCE_DIR=",
diff --git a/llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn b/llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn
index 2df3cb3e3a4fa..6e512bb71ea88 100644
--- a/llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn
+++ b/llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn
@@ -21,6 +21,7 @@ write_cmake_config("Config") {
"LLDB_ENABLE_PYTHON=",
"LLDB_ENABLE_FBSDVMCORE=",
"LLDB_EMBED_PYTHON_HOME=",
+ "LLDB_INSTALL_LIBDIR_BASENAME=lib",
"LLDB_GLOBAL_INIT_DIRECTORY=",
"LLDB_PYTHON_HOME=",
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 dc1d7d57581b3..aea09101d0e26 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
@@ -67,8 +67,8 @@
/* Default architecture for SystemZ. */
#define CLANG_SYSTEMZ_DEFAULT_ARCH "z10"
-/* Multilib suffix for libdir. */
-#define CLANG_LIBDIR_SUFFIX ""
+/* Multilib basename for libdir. */
+#define CLANG_INSTALL_LIBDIR_BASENAME "lib"
/* Relative directory for resource files */
#define CLANG_RESOURCE_DIR ""
More information about the llvm-commits
mailing list