Skip to content

Commit

Permalink
Revert "[CMake] Ensure CLANG_RESOURCE_DIR is respected."
Browse files Browse the repository at this point in the history
This reverts commit 39aa0f5.

This is missing the new GetClangResourceDir.cmake that is being included,
so all clang builds are broken.
  • Loading branch information
mstorsjo committed Jun 3, 2023
1 parent 57dc16f commit d072d11
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 34 deletions.
5 changes: 2 additions & 3 deletions clang/lib/Headers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,7 @@ set(openmp_wrapper_files
openmp_wrappers/new
)

include(GetClangResourceDir)
get_clang_resource_dir(output_dir PREFIX ${LLVM_LIBRARY_OUTPUT_INTDIR}/.. SUBDIR include)
set(output_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION_MAJOR}/include)
set(out_files)
set(generated_files)

Expand Down Expand Up @@ -457,7 +456,7 @@ add_header_target("openmp-resource-headers" ${openmp_wrapper_files})
add_header_target("windows-resource-headers" ${windows_only_files})
add_header_target("utility-resource-headers" ${utility_files})

get_clang_resource_dir(header_install_dir SUBDIR include)
set(header_install_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION_MAJOR}/include)

#############################################################
# Install rules for the catch-all clang-resource-headers target
Expand Down
4 changes: 1 addition & 3 deletions clang/lib/Tooling/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ else()
list(APPEND implicitDirs -I ${implicitDir})
endforeach()

include(GetClangResourceDir)
get_clang_resource_dir(resource_dir PREFIX ${LLVM_BINARY_DIR})
add_custom_command(
COMMENT Generate ASTNodeAPI.json
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ASTNodeAPI.json
Expand All @@ -63,7 +61,7 @@ else()
$<TARGET_FILE:clang-ast-dump>
# Skip this in debug mode because parsing AST.h is too slow
--skip-processing=${skip_expensive_processing}
-I ${resource_dir}/include
-I ${LLVM_BINARY_DIR}/lib/clang/${CLANG_VERSION_MAJOR}/include
-I ${CLANG_SOURCE_DIR}/include
-I ${LLVM_BINARY_DIR}/tools/clang/include
-I ${LLVM_BINARY_DIR}/include
Expand Down
7 changes: 2 additions & 5 deletions clang/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/)
list(APPEND compiler_rt_configure_deps LLVMTestingSupport)
endif()

include(GetClangResourceDir)
get_clang_resource_dir(output_resource_dir PREFIX ${LLVM_BINARY_DIR})
get_clang_resource_dir(install_resource_dir)
ExternalProject_Add(compiler-rt
DEPENDS llvm-config clang ${compiler_rt_configure_deps}
PREFIX ${COMPILER_RT_PREFIX}
Expand All @@ -85,9 +82,9 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/)
-DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}
-DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config
-DLLVM_LIT_ARGS=${LLVM_LIT_ARGS}
-DCOMPILER_RT_OUTPUT_DIR=${output_resource_dir}
-DCOMPILER_RT_OUTPUT_DIR=${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION_MAJOR}
-DCOMPILER_RT_EXEC_OUTPUT_DIR=${LLVM_RUNTIME_OUTPUT_INTDIR}
-DCOMPILER_RT_INSTALL_PATH:PATH=${install_resource_dir}
-DCOMPILER_RT_INSTALL_PATH:PATH=lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION_MAJOR}
-DCOMPILER_RT_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX}
Expand Down
10 changes: 7 additions & 3 deletions compiler-rt/cmake/base-config-ix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ include(BuiltinTests)
include(CheckIncludeFile)
include(CheckCXXSourceCompiles)
include(GNUInstallDirs)
include(GetClangResourceDir)
include(ExtendPath)
include(CompilerRTDarwinUtils)

Expand Down Expand Up @@ -39,10 +38,15 @@ if (LLVM_LIBRARY_OUTPUT_INTDIR AND LLVM_RUNTIME_OUTPUT_INTDIR AND PACKAGE_VERSIO
endif()

if (LLVM_TREE_AVAILABLE)
# Compute the Clang version from the LLVM version.
# FIXME: We should be able to reuse CLANG_VERSION_MAJOR variable calculated
# in Clang cmake files, instead of copying the rules here.
string(REGEX MATCH "^[0-9]+" CLANG_VERSION_MAJOR
${PACKAGE_VERSION})
# Setup the paths where compiler-rt runtimes and headers should be stored.
get_clang_resource_dir(COMPILER_RT_OUTPUT_DIR PREFIX ${LLVM_LIBRARY_OUTPUT_INTDIR}/..)
set(COMPILER_RT_OUTPUT_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION_MAJOR})
set(COMPILER_RT_EXEC_OUTPUT_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
get_clang_resource_dir(COMPILER_RT_INSTALL_PATH)
set(COMPILER_RT_INSTALL_PATH lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION_MAJOR})
option(COMPILER_RT_INCLUDE_TESTS "Generate and build compiler-rt unit tests."
${LLVM_INCLUDE_TESTS})
option(COMPILER_RT_ENABLE_WERROR "Fail and stop if warning is triggered"
Expand Down
11 changes: 3 additions & 8 deletions lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include "clang/Basic/Version.h"
#include "clang/Config/config.h"
#include "clang/Driver/Driver.h"

#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
Expand Down Expand Up @@ -52,14 +51,11 @@ static bool DefaultComputeClangResourceDirectory(FileSpec &lldb_shlib_spec,
Log *log = GetLog(LLDBLog::Host);
std::string raw_path = lldb_shlib_spec.GetPath();
llvm::StringRef parent_dir = llvm::sys::path::parent_path(raw_path);
const std::string clang_resource_path =
clang::driver::Driver::GetResourcesPath("bin/lldb", CLANG_RESOURCE_DIR);

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 or
// $install_dir/bin/$CLANG_RESOURCE_DIR
clang_resource_path,
// in $install_dir/lib{,64}/clang/$clang_version.
CLANG_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_MAJOR_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_INSTALL_LIBDIR_BASENAME.
Expand All @@ -86,8 +82,7 @@ static bool DefaultComputeClangResourceDirectory(FileSpec &lldb_shlib_spec,
}

bool lldb_private::ComputeClangResourceDirectory(FileSpec &lldb_shlib_spec,
FileSpec &file_spec,
bool verify) {
FileSpec &file_spec, bool verify) {
#if !defined(__APPLE__)
return DefaultComputeClangResourceDirectory(lldb_shlib_spec, file_spec,
verify);
Expand Down
10 changes: 5 additions & 5 deletions lldb/unittests/Expression/ClangParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
//===----------------------------------------------------------------------===//

#include "clang/Basic/Version.h"
#include "clang/Config/config.h"
#include "clang/Driver/Driver.h"

#include "Plugins/ExpressionParser/Clang/ClangHost.h"
#include "TestingSupport/SubsystemRAII.h"
Expand Down Expand Up @@ -39,11 +37,13 @@ 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/" LLDB_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_MAJOR_STRING;
#else
std::string path_to_liblldb = "C:\\foo\\bar\\lib\\";
std::string path_to_liblldb = "C:\\foo\\bar\\lib";
std::string path_to_clang_dir =
"C:\\foo\\bar\\lib\\clang\\" CLANG_VERSION_MAJOR_STRING;
#endif
std::string path_to_clang_dir = clang::driver::Driver::GetResourcesPath(
path_to_liblldb + "liblldb", CLANG_RESOURCE_DIR);
EXPECT_EQ(ComputeClangResourceDir(path_to_liblldb), path_to_clang_dir);

// The path doesn't really exist, so setting verify to true should make
Expand Down
6 changes: 1 addition & 5 deletions llvm/cmake/modules/LLVMExternalProjectUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,7 @@ function(llvm_ExternalProject_Add name source_dir)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
string(REGEX MATCH "^[0-9]+" CLANG_VERSION_MAJOR
${PACKAGE_VERSION})
if(DEFINED CLANG_RESOURCE_DIR AND NOT CLANG_RESOURCE_DIR STREQUAL "")
set(resource_dir ${LLVM_TOOLS_BINARY_DIR}/${CLANG_RESOURCE_DIR})
else()
set(resource_dir "${LLVM_LIBRARY_DIR}/clang/${CLANG_VERSION_MAJOR}")
endif()
set(resource_dir "${LLVM_LIBRARY_DIR}/clang/${CLANG_VERSION_MAJOR}")
set(flag_types ASM C CXX MODULE_LINKER SHARED_LINKER EXE_LINKER)
foreach(type ${flag_types})
set(${type}_flag -DCMAKE_${type}_FLAGS=-resource-dir=${resource_dir})
Expand Down
4 changes: 2 additions & 2 deletions openmp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ option(OPENMP_ENABLE_LIBOMP_PROFILING "Enable time profiling for libomp." OFF)
if(${OPENMP_STANDALONE_BUILD})
set(LIBOMP_HEADERS_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}")
else()
include(GetClangResourceDir)
get_clang_resource_dir(LIBOMP_HEADERS_INSTALL_PATH SUBDIR include)
string(REGEX MATCH "[0-9]+" CLANG_VERSION ${PACKAGE_VERSION})
set(LIBOMP_HEADERS_INSTALL_PATH "${OPENMP_INSTALL_LIBDIR}/clang/${CLANG_VERSION}/include")
endif()

# Build host runtime library, after LIBOMPTARGET variables are set since they are needed
Expand Down

0 comments on commit d072d11

Please sign in to comment.