[Openmp-commits] [openmp] d072d11 - Revert "[CMake] Ensure `CLANG_RESOURCE_DIR` is respected."

Martin Storsjö via Openmp-commits openmp-commits at lists.llvm.org
Sat Jun 3 01:50:33 PDT 2023


Author: Martin Storsjö
Date: 2023-06-03T11:47:57+03:00
New Revision: d072d110227d118284cb4484814567782ab50186

URL: https://github.com/llvm/llvm-project/commit/d072d110227d118284cb4484814567782ab50186
DIFF: https://github.com/llvm/llvm-project/commit/d072d110227d118284cb4484814567782ab50186.diff

LOG: Revert "[CMake] Ensure `CLANG_RESOURCE_DIR` is respected."

This reverts commit 39aa0f5c434b463520ac39a8dbe933ee8c4c5ea7.

This is missing the new GetClangResourceDir.cmake that is being included,
so all clang builds are broken.

Added: 
    

Modified: 
    clang/lib/Headers/CMakeLists.txt
    clang/lib/Tooling/CMakeLists.txt
    clang/runtime/CMakeLists.txt
    compiler-rt/cmake/base-config-ix.cmake
    lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
    lldb/unittests/Expression/ClangParserTest.cpp
    llvm/cmake/modules/LLVMExternalProjectUtils.cmake
    openmp/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt
index f2ee2e036deb9..bbd3d0f2d719a 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -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)
 
@@ -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

diff  --git a/clang/lib/Tooling/CMakeLists.txt b/clang/lib/Tooling/CMakeLists.txt
index aff39e4de13c0..e4ce43762d6b6 100644
--- a/clang/lib/Tooling/CMakeLists.txt
+++ b/clang/lib/Tooling/CMakeLists.txt
@@ -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
@@ -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

diff  --git a/clang/runtime/CMakeLists.txt b/clang/runtime/CMakeLists.txt
index 2dd305428c9ac..94b5d783ce361 100644
--- a/clang/runtime/CMakeLists.txt
+++ b/clang/runtime/CMakeLists.txt
@@ -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}
@@ -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}

diff  --git a/compiler-rt/cmake/base-config-ix.cmake b/compiler-rt/cmake/base-config-ix.cmake
index ede8428c39382..c6e95055b0028 100644
--- a/compiler-rt/cmake/base-config-ix.cmake
+++ b/compiler-rt/cmake/base-config-ix.cmake
@@ -7,7 +7,6 @@ include(BuiltinTests)
 include(CheckIncludeFile)
 include(CheckCXXSourceCompiles)
 include(GNUInstallDirs)
-include(GetClangResourceDir)
 include(ExtendPath)
 include(CompilerRTDarwinUtils)
 
@@ -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"

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
index 3bb303c0e1931..ae4dcc05256e7 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
@@ -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"
@@ -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.
@@ -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);

diff  --git a/lldb/unittests/Expression/ClangParserTest.cpp b/lldb/unittests/Expression/ClangParserTest.cpp
index ed5ee323b7d20..e5d90b25bf430 100644
--- a/lldb/unittests/Expression/ClangParserTest.cpp
+++ b/lldb/unittests/Expression/ClangParserTest.cpp
@@ -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"
@@ -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

diff  --git a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
index 4b5b600307ec9..44af6c1462bde 100644
--- a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -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})

diff  --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt
index c1efcaf80b54d..04678cbd4f33d 100644
--- a/openmp/CMakeLists.txt
+++ b/openmp/CMakeLists.txt
@@ -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


        


More information about the Openmp-commits mailing list