Skip to content

Commit

Permalink
[lldb][NFCI] Change logic to find clang resource dir in standalone bu…
Browse files Browse the repository at this point in the history
…ilds

As of 0beffb8 there is a CMake
function to actually calculate the relative path to the clang resource
directory. Currently we have some bespoke logic that looks in a few
places, but with this new function we should be able to eliminate some
complexity here.

Also, I moved the functionality from LLDBConfig to LLDBStandalone since
it is only used in standalone builds.

Differential Revision: https://reviews.llvm.org/D156270

(cherry picked from commit a809720)
  • Loading branch information
bulbazord authored and tru committed Sep 29, 2023
1 parent cb23434 commit c056d72
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 24 deletions.
24 changes: 0 additions & 24 deletions lldb/cmake/modules/LLDBConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -282,30 +282,6 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
endif()
endif()


# If LLDB is building against a prebuilt Clang, then the Clang resource
# directory that LLDB is using for its embedded Clang instance needs to point
# to the resource directory of the used Clang installation.
if (NOT TARGET clang-resource-headers)
set(LLDB_CLANG_RESOURCE_DIR_NAME "${LLVM_VERSION_MAJOR}")
# Iterate over the possible places where the external resource directory
# could be and pick the first that exists.
foreach(CANDIDATE "${Clang_DIR}/../.." "${LLVM_DIR}" "${LLVM_LIBRARY_DIRS}"
"${LLVM_BUILD_LIBRARY_DIR}"
"${LLVM_LIBRARY_DIR}")
# Build the resource directory path by appending 'clang/<version number>'.
set(CANDIDATE_RESOURCE_DIR "${CANDIDATE}/clang/${LLDB_CLANG_RESOURCE_DIR_NAME}")
if (IS_DIRECTORY "${CANDIDATE_RESOURCE_DIR}")
set(LLDB_EXTERNAL_CLANG_RESOURCE_DIR "${CANDIDATE_RESOURCE_DIR}")
break()
endif()
endforeach()

if (NOT LLDB_EXTERNAL_CLANG_RESOURCE_DIR)
message(FATAL_ERROR "Expected directory for clang-resource headers not found: ${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}")
endif()
endif()

# Find Apple-specific libraries or frameworks that may be needed.
if (APPLE)
if(NOT APPLE_EMBEDDED)
Expand Down
13 changes: 13 additions & 0 deletions lldb/cmake/modules/LLDBStandalone.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,16 @@ endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})

# If LLDB is building against a prebuilt Clang, then the Clang resource
# directory that LLDB is using for its embedded Clang instance needs to point to
# the resource directory of the used Clang installation.
if (NOT TARGET clang-resource-headers)
include(GetClangResourceDir)
get_clang_resource_dir(LLDB_EXTERNAL_CLANG_RESOURCE_DIR
PREFIX "${Clang_DIR}/../../../")

if (NOT EXISTS ${LLDB_EXTERNAL_CLANG_RESOURCE_DIR})
message(FATAL_ERROR "Expected directory for clang-resource-headers not found: ${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}")
endif()
endif()

0 comments on commit c056d72

Please sign in to comment.