[llvm-branch-commits] [lldb] release/20.x: [lldb] Fix manual CURSES_LIBRARIES tinfo finding (#128245) (PR #129342)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Feb 28 16:21:51 PST 2025
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/129342
Backport 8fff0c181f26a5e8b2344c061ebf2559118b1160 bb6a273d9ab9ee90dbb957e541f4d810fffb22ee
Requested by: @ajordanr-google
>From 7569564987598d41273cbe235da6f957b71c72f7 Mon Sep 17 00:00:00 2001
From: Jordan R AW <ajordanr at google.com>
Date: Fri, 14 Feb 2025 21:37:39 -0800
Subject: [PATCH 1/2] [lldb] Add terminfo dependency for ncurses support
(#126810)
For some operating systems (e.g. chromiumos), terminfo is a separate
package and library from ncurses. Both are still requirements for curses
support in lldb, individually.
This is a rework of this original spack commit:
https://github.com/spack/spack/commit/9ea261265010eacd250691a8361f661d0576f25c
Instead though, this PR uses CMake to detect whether the symbol is
present and defined in the curses library, and only falls back to a separate
tinfo if not found.
Without this fix, LLDB cannot be built on these systems.
Fixes #101368
(cherry picked from commit 8fff0c181f26a5e8b2344c061ebf2559118b1160)
---
lldb/cmake/modules/FindCursesAndPanel.cmake | 42 ++++++++++++++++++---
1 file changed, 37 insertions(+), 5 deletions(-)
diff --git a/lldb/cmake/modules/FindCursesAndPanel.cmake b/lldb/cmake/modules/FindCursesAndPanel.cmake
index aaadf214bf54b..75ebaa35d7ea1 100644
--- a/lldb/cmake/modules/FindCursesAndPanel.cmake
+++ b/lldb/cmake/modules/FindCursesAndPanel.cmake
@@ -2,23 +2,55 @@
# FindCursesAndPanel
# -----------
#
-# Find the curses and panel library as a whole.
+# Find the curses, terminfo, and panel library as a whole.
-if(CURSES_INCLUDE_DIRS AND CURSES_LIBRARIES AND PANEL_LIBRARIES)
+include(CMakePushCheckState)
+
+function(lldb_check_curses_tinfo CURSES_LIBRARIES CURSES_HAS_TINFO)
+ cmake_reset_check_state()
+ set(CMAKE_REQUIRED_LIBRARIES "${CURSES_LIBRARIES}")
+ # acs_map is one of many symbols that are part of tinfo but could
+ # be bundled in curses.
+ check_symbol_exists(acs_map "curses.h" CURSES_HAS_TINFO)
+endfunction()
+
+if(CURSES_INCLUDE_DIRS AND CURSES_LIBRARIES AND TINFO_LIBRARIES AND PANEL_LIBRARIES)
set(CURSESANDPANEL_FOUND TRUE)
else()
find_package(Curses QUIET)
find_library(PANEL_LIBRARIES NAMES panel DOC "The curses panel library" QUIET)
include(FindPackageHandleStandardArgs)
+
+ if(CURSES_FOUND AND PANEL_LIBRARIES)
+ # Sometimes the curses libraries define their own terminfo symbols,
+ # other times they're extern and are defined by a separate terminfo library.
+ # Auto-detect which.
+ lldb_check_curses_tinfo("${CURSES_LIBRARIES}" CURSES_HAS_TINFO)
+ if (NOT CURSES_HAS_TINFO)
+ message(STATUS "curses library missing terminfo symbols, looking for tinfo separately")
+ find_library(TINFO_LIBRARIES NAMES tinfo DOC "The curses tinfo library" QUIET)
+ list(APPEND CURSES_LIBRARIES "${TINFO_LIBRARIES}")
+ endif()
+ set(HAS_TERMINFO_SYMBOLS "$<OR:$<BOOL:${TERMINFO_LIBRARIES}>,$<BOOL:${CURSES_HAS_TINFO}>>")
+ endif()
+
find_package_handle_standard_args(CursesAndPanel
FOUND_VAR
CURSESANDPANEL_FOUND
REQUIRED_VARS
CURSES_INCLUDE_DIRS
CURSES_LIBRARIES
- PANEL_LIBRARIES)
- if(CURSES_FOUND AND PANEL_LIBRARIES)
- mark_as_advanced(CURSES_INCLUDE_DIRS CURSES_LIBRARIES PANEL_LIBRARIES)
+ PANEL_LIBRARIES
+ HAS_TERMINFO_SYMBOLS)
+
+ if(CURSES_FOUND AND PANEL_LIBRARIES AND HAS_TERMINFO_SYMBOLS)
+ mark_as_advanced(CURSES_INCLUDE_DIRS
+ PANEL_LIBRARIES
+ HAS_TERMINFO_SYMBOLS
+ CURSES_HAS_TINFO)
+ endif()
+ if(TINFO_LIBRARIES)
+ mark_as_advanced(TINFO_LIBRARIES)
endif()
endif()
>From bfb9789ec7cf63a7b4630c5a7c492c5f6c3f9644 Mon Sep 17 00:00:00 2001
From: Jordan R AW <ajordanr at google.com>
Date: Sat, 22 Feb 2025 09:13:46 -0800
Subject: [PATCH 2/2] [lldb] Fix manual CURSES_LIBRARIES tinfo finding
(#128245)
(cherry picked from commit bb6a273d9ab9ee90dbb957e541f4d810fffb22ee)
---
lldb/cmake/modules/FindCursesAndPanel.cmake | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/lldb/cmake/modules/FindCursesAndPanel.cmake b/lldb/cmake/modules/FindCursesAndPanel.cmake
index 75ebaa35d7ea1..8628059f91ba1 100644
--- a/lldb/cmake/modules/FindCursesAndPanel.cmake
+++ b/lldb/cmake/modules/FindCursesAndPanel.cmake
@@ -6,15 +6,25 @@
include(CMakePushCheckState)
-function(lldb_check_curses_tinfo CURSES_LIBRARIES CURSES_HAS_TINFO)
+function(lldb_check_curses_tinfo CURSES_INCLUDE_DIRS CURSES_LIBRARIES CURSES_HAS_TINFO)
cmake_reset_check_state()
+ set(CMAKE_REQUIRED_INCLUDES "${CURSES_INCLUDE_DIRS}")
set(CMAKE_REQUIRED_LIBRARIES "${CURSES_LIBRARIES}")
# acs_map is one of many symbols that are part of tinfo but could
# be bundled in curses.
check_symbol_exists(acs_map "curses.h" CURSES_HAS_TINFO)
endfunction()
-if(CURSES_INCLUDE_DIRS AND CURSES_LIBRARIES AND TINFO_LIBRARIES AND PANEL_LIBRARIES)
+if(CURSES_INCLUDE_DIRS AND CURSES_LIBRARIES AND PANEL_LIBRARIES)
+ if(NOT HAS_TERMINFO_SYMBOLS)
+ lldb_check_curses_tinfo("${CURSES_INCLUDE_DIRS}"
+ "${CURSES_LIBRARIES}"
+ CURSES_HAS_TINFO)
+ if(NOT CURSES_HAS_TINFO)
+ message(WARNING "CURSES_LIBRARIES was provided manually but is missing terminfo symbols")
+ endif()
+ mark_as_advanced(CURSES_HAS_TINFO)
+ endif()
set(CURSESANDPANEL_FOUND TRUE)
else()
find_package(Curses QUIET)
@@ -25,8 +35,10 @@ else()
# Sometimes the curses libraries define their own terminfo symbols,
# other times they're extern and are defined by a separate terminfo library.
# Auto-detect which.
- lldb_check_curses_tinfo("${CURSES_LIBRARIES}" CURSES_HAS_TINFO)
- if (NOT CURSES_HAS_TINFO)
+ lldb_check_curses_tinfo("${CURSES_INCLUDE_DIRS}"
+ "${CURSES_LIBRARIES}"
+ CURSES_HAS_TINFO)
+ if(NOT CURSES_HAS_TINFO)
message(STATUS "curses library missing terminfo symbols, looking for tinfo separately")
find_library(TINFO_LIBRARIES NAMES tinfo DOC "The curses tinfo library" QUIET)
list(APPEND CURSES_LIBRARIES "${TINFO_LIBRARIES}")
More information about the llvm-branch-commits
mailing list