Skip to content

Commit

Permalink
[llvm][lldb] use FindLibEdit.cmake everywhere
Browse files Browse the repository at this point in the history
Currently, LLVM's LineEditor and LLDB both use libedit, but find them in different (inconsistent) ways.
This causes issues e.g. when you are using a locally installed version of libedit, which will not be used
by clang-query, but by lldb if picked up by FindLibEdit.cmake

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D124673
  • Loading branch information
upsj authored and MaskRay committed May 12, 2022
1 parent 6f3c7df commit b1aed14
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 24 deletions.
Expand Up @@ -62,3 +62,9 @@ else()
mark_as_advanced(LibEdit_INCLUDE_DIRS LibEdit_LIBRARIES)
endif()

if (LibEdit_FOUND AND NOT TARGET LibEdit::LibEdit)
add_library(LibEdit::LibEdit UNKNOWN IMPORTED)
set_target_properties(LibEdit::LibEdit PROPERTIES
IMPORTED_LOCATION ${LibEdit_LIBRARIES}
INTERFACE_INCLUDE_DIRECTORIES ${LibEdit_INCLUDE_DIRS})
endif()
10 changes: 10 additions & 0 deletions lldb/cmake/modules/LLDBStandalone.cmake
Expand Up @@ -4,6 +4,12 @@ if(POLICY CMP0116)
cmake_policy(SET CMP0116 OLD)
endif()

if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
endif()

list(APPEND CMAKE_MODULE_PATH "${LLVM_COMMON_CMAKE_UTILS}/Modules")

option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF)

find_package(LLVM REQUIRED CONFIG HINTS ${LLVM_DIR} NO_CMAKE_FIND_ROOT_PATH)
Expand Down Expand Up @@ -105,6 +111,10 @@ include_directories(
"${LLVM_INCLUDE_DIRS}"
"${CLANG_INCLUDE_DIRS}")

if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
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})
4 changes: 0 additions & 4 deletions lldb/source/Core/CMakeLists.txt
Expand Up @@ -103,10 +103,6 @@ add_dependencies(lldbCore
# TODO: Remove once we have better layering
set_target_properties(lldbCore PROPERTIES LINK_INTERFACE_MULTIPLICITY 5)

if (LLDB_ENABLE_LIBEDIT)
target_include_directories(lldbCore PRIVATE ${LibEdit_INCLUDE_DIRS})
endif()

if (LLDB_ENABLE_CURSES)
target_include_directories(lldbCore PRIVATE ${CURSES_INCLUDE_DIRS})
endif()
7 changes: 2 additions & 5 deletions lldb/source/Host/CMakeLists.txt
Expand Up @@ -141,7 +141,7 @@ if (HAVE_LIBDL)
list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS})
endif()
if (LLDB_ENABLE_LIBEDIT)
list(APPEND EXTRA_LIBS ${LibEdit_LIBRARIES})
list(APPEND EXTRA_LIBS LibEdit::LibEdit)
endif()
if (LLDB_ENABLE_LZMA)
list(APPEND EXTRA_LIBS ${LIBLZMA_LIBRARIES})
Expand All @@ -151,7 +151,7 @@ if (WIN32)
endif()

if (LLDB_ENABLE_LIBEDIT)
list(APPEND LLDB_LIBEDIT_LIBS ${LibEdit_LIBRARIES})
list(APPEND LLDB_LIBEDIT_LIBS LibEdit::LibEdit)
if (LLVM_BUILD_STATIC)
list(APPEND LLDB_SYSTEM_LIBS gpm)
endif()
Expand All @@ -171,6 +171,3 @@ add_lldb_library(lldbHost
Support
)

if (LLDB_ENABLE_LIBEDIT)
target_include_directories(lldbHost PUBLIC ${LibEdit_INCLUDE_DIRS})
endif()
3 changes: 0 additions & 3 deletions lldb/source/Interpreter/CMakeLists.txt
Expand Up @@ -68,6 +68,3 @@ add_dependencies(lldbInterpreter
LLDBInterpreterPropertiesGen
LLDBInterpreterPropertiesEnumGen)

if (LLDB_ENABLE_LIBEDIT)
target_include_directories(lldbInterpreter PRIVATE ${LibEdit_INCLUDE_DIRS})
endif()
8 changes: 1 addition & 7 deletions lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
Expand Up @@ -10,7 +10,7 @@ add_definitions(-DLLDB_PYTHON_EXE_RELATIVE_PATH="${LLDB_PYTHON_EXE_RELATIVE_PATH


if (LLDB_ENABLE_LIBEDIT)
list(APPEND LLDB_LIBEDIT_LIBS ${LibEdit_LIBRARIES})
list(APPEND LLDB_LIBEDIT_LIBS LibEdit::LibEdit)
endif()

add_lldb_library(lldbPluginScriptInterpreterPython PLUGIN
Expand All @@ -35,9 +35,3 @@ add_lldb_library(lldbPluginScriptInterpreterPython PLUGIN
LINK_COMPONENTS
Support
)

if (LLDB_ENABLE_LIBEDIT)
target_include_directories(lldbPluginScriptInterpreterPython PUBLIC
${LibEdit_INCLUDE_DIRS}
)
endif()
6 changes: 3 additions & 3 deletions llvm/cmake/config-ix.cmake
Expand Up @@ -64,7 +64,6 @@ check_symbol_exists(FE_ALL_EXCEPT "fenv.h" HAVE_DECL_FE_ALL_EXCEPT)
check_symbol_exists(FE_INEXACT "fenv.h" HAVE_DECL_FE_INEXACT)

check_include_file(mach/mach.h HAVE_MACH_MACH_H)
check_include_file(histedit.h HAVE_HISTEDIT_H)
check_include_file(CrashReporterClient.h HAVE_CRASHREPORTERCLIENT_H)
if(APPLE)
include(CheckCSourceCompiles)
Expand Down Expand Up @@ -184,8 +183,9 @@ if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
# Don't look for these libraries on Windows.
if (NOT PURE_WINDOWS)
# Skip libedit if using ASan as it contains memory leaks.
if (LLVM_ENABLE_LIBEDIT AND HAVE_HISTEDIT_H AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*")
check_library_exists(edit el_init "" HAVE_LIBEDIT)
if (LLVM_ENABLE_LIBEDIT AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*")
find_package(LibEdit)
set(HAVE_LIBEDIT ${LibEdit_FOUND})
else()
set(HAVE_LIBEDIT 0)
endif()
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/LineEditor/CMakeLists.txt
@@ -1,5 +1,5 @@
if(HAVE_LIBEDIT)
set(link_libs edit)
set(link_libs LibEdit::LibEdit)
endif()

add_llvm_component_library(LLVMLineEditor
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/gn/secondary/lldb/source/Host/BUILD.gn
Expand Up @@ -142,7 +142,7 @@ static_library("Host") {
# list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS})
# endif()
# if (LLDB_ENABLE_LIBEDIT)
# list(APPEND EXTRA_LIBS ${LibEdit_LIBRARIES})
# list(APPEND EXTRA_LIBS LibEdit::LibEdit)
# endif()
# if (LLDB_ENABLE_LZMA)
# list(APPEND EXTRA_LIBS ${LIBLZMA_LIBRARIES})
Expand Down

0 comments on commit b1aed14

Please sign in to comment.