upsj created this revision.
upsj added reviewers: mgorny, MaskRay.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
upsj requested review of this revision.
Herald added projects: LLDB, LLVM.
Herald added subscribers: llvm-commits, lldb-commits.
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
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D124673
Files:
cmake/Modules/FindLibEdit.cmake
lldb/cmake/modules/FindLibEdit.cmake
lldb/cmake/modules/LLDBConfig.cmake
llvm/cmake/config-ix.cmake
llvm/include/llvm/Config/config.h.cmake
llvm/lib/LineEditor/CMakeLists.txt
utils/bazel/llvm_configs/config.h.cmake
Index: utils/bazel/llvm_configs/config.h.cmake
===================================================================
--- utils/bazel/llvm_configs/config.h.cmake
+++ utils/bazel/llvm_configs/config.h.cmake
@@ -105,7 +105,7 @@
#cmakedefine HAVE_ISATTY 1
/* Define to 1 if you have the `edit' library (-ledit). */
-#cmakedefine HAVE_LIBEDIT ${HAVE_LIBEDIT}
+#cmakedefine HAVE_LIBEDIT ${LibEdit_FOUND}
/* Define to 1 if you have the `pfm' library (-lpfm). */
#cmakedefine HAVE_LIBPFM ${HAVE_LIBPFM}
Index: llvm/lib/LineEditor/CMakeLists.txt
===================================================================
--- llvm/lib/LineEditor/CMakeLists.txt
+++ llvm/lib/LineEditor/CMakeLists.txt
@@ -1,15 +1,14 @@
-if(HAVE_LIBEDIT)
- set(link_libs edit)
-endif()
+# LibEdit is found in llvm/cmake/config-ix.cmake
add_llvm_component_library(LLVMLineEditor
LineEditor.cpp
ADDITIONAL_HEADER_DIRS
${LLVM_MAIN_INCLUDE_DIR}/llvm/LineEditor
+ ${LibEdit_INCLUDE_DIRS}
LINK_LIBS
- ${link_libs}
+ ${LibEdit_LIBRARIES}
LINK_COMPONENTS
Support
Index: llvm/include/llvm/Config/config.h.cmake
===================================================================
--- llvm/include/llvm/Config/config.h.cmake
+++ llvm/include/llvm/Config/config.h.cmake
@@ -105,7 +105,7 @@
#cmakedefine HAVE_ISATTY 1
/* Define to 1 if you have the `edit' library (-ledit). */
-#cmakedefine HAVE_LIBEDIT ${HAVE_LIBEDIT}
+#cmakedefine HAVE_LIBEDIT ${LibEdit_FOUND}
/* Define to 1 if you have the `pfm' library (-lpfm). */
#cmakedefine HAVE_LIBPFM ${HAVE_LIBPFM}
Index: llvm/cmake/config-ix.cmake
===================================================================
--- llvm/cmake/config-ix.cmake
+++ llvm/cmake/config-ix.cmake
@@ -64,7 +64,6 @@
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)
@@ -184,10 +183,11 @@
# 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)
- else()
- set(HAVE_LIBEDIT 0)
+ if (LLVM_ENABLE_LIBEDIT)
+ if (LLVM_USE_SANITIZER MATCHES ".*Address.*")
+ message(FATAL_ERROR "LLVM_ENABLE_LIBEDIT cannot be enabled with LLVM_USE_SANITIZER set to AddressSanitizer")
+ endif()
+ find_package(LibEdit REQUIRED)
endif()
if(LLVM_ENABLE_TERMINFO)
if(LLVM_ENABLE_TERMINFO STREQUAL FORCE_ON)
Index: lldb/cmake/modules/LLDBConfig.cmake
===================================================================
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -56,7 +56,9 @@
message(STATUS "${description}: ${${variable}}")
endmacro()
-add_optional_dependency(LLDB_ENABLE_LIBEDIT "Enable editline support in LLDB" LibEdit LibEdit_FOUND)
+if(LLVM_ENABLE_LIBEDIT)
+ find_package(LibEdit REQUIRED)
+endif()
add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support in LLDB" CursesAndPanel CURSESANDPANEL_FOUND)
add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support in LLDB" LibLZMA LIBLZMA_FOUND)
add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support in LLDB" LuaAndSwig LUAANDSWIG_FOUND)
Index: lldb/cmake/modules/FindLibEdit.cmake
===================================================================
--- /dev/null
+++ lldb/cmake/modules/FindLibEdit.cmake
@@ -1,64 +0,0 @@
-#.rst:
-# FindLibEdit
-# -----------
-#
-# Find libedit library and headers
-#
-# The module defines the following variables:
-#
-# ::
-#
-# LibEdit_FOUND - true if libedit was found
-# LibEdit_INCLUDE_DIRS - include search path
-# LibEdit_LIBRARIES - libraries to link
-# LibEdit_VERSION_STRING - version number
-
-if(LibEdit_INCLUDE_DIRS AND LibEdit_LIBRARIES)
- set(LibEdit_FOUND TRUE)
-else()
- find_package(PkgConfig QUIET)
- pkg_check_modules(PC_LIBEDIT QUIET libedit)
-
- find_path(LibEdit_INCLUDE_DIRS
- NAMES
- histedit.h
- HINTS
- ${PC_LIBEDIT_INCLUDEDIR}
- ${PC_LIBEDIT_INCLUDE_DIRS}
- "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
- find_library(LibEdit_LIBRARIES
- NAMES
- edit libedit
- HINTS
- ${PC_LIBEDIT_LIBDIR}
- ${PC_LIBEDIT_LIBRARY_DIRS}
- "${CMAKE_INSTALL_FULL_LIBDIR}")
-
- if(LibEdit_INCLUDE_DIRS AND EXISTS "${LibEdit_INCLUDE_DIRS}/histedit.h")
- file(STRINGS "${LibEdit_INCLUDE_DIRS}/histedit.h"
- libedit_major_version_str
- REGEX "^#define[ \t]+LIBEDIT_MAJOR[ \t]+[0-9]+")
- string(REGEX REPLACE "^#define[ \t]+LIBEDIT_MAJOR[ \t]+([0-9]+)" "\\1"
- LIBEDIT_MAJOR_VERSION "${libedit_major_version_str}")
-
- file(STRINGS "${LibEdit_INCLUDE_DIRS}/histedit.h"
- libedit_minor_version_str
- REGEX "^#define[ \t]+LIBEDIT_MINOR[ \t]+[0-9]+")
- string(REGEX REPLACE "^#define[ \t]+LIBEDIT_MINOR[ \t]+([0-9]+)" "\\1"
- LIBEDIT_MINOR_VERSION "${libedit_minor_version_str}")
-
- set(LibEdit_VERSION_STRING "${libedit_major_version}.${libedit_minor_version}")
- endif()
-
- include(FindPackageHandleStandardArgs)
- find_package_handle_standard_args(LibEdit
- FOUND_VAR
- LibEdit_FOUND
- REQUIRED_VARS
- LibEdit_INCLUDE_DIRS
- LibEdit_LIBRARIES
- VERSION_VAR
- LibEdit_VERSION_STRING)
- mark_as_advanced(LibEdit_INCLUDE_DIRS LibEdit_LIBRARIES)
-endif()
-
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits