-
Notifications
You must be signed in to change notification settings - Fork 14.3k
release/20.x: [lldb] Fix manual CURSES_LIBRARIES tinfo finding (#128245) #129342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@JDevlieghere @JDevlieghere What do you think about merging this PR to the release branch? |
@llvm/pr-subscribers-lldb Author: None (llvmbot) ChangesRequested by: @ajordanr-google Full diff: https://github.com/llvm/llvm-project/pull/129342.diff 1 Files Affected:
diff --git a/lldb/cmake/modules/FindCursesAndPanel.cmake b/lldb/cmake/modules/FindCursesAndPanel.cmake
index aaadf214bf54b..8628059f91ba1 100644
--- a/lldb/cmake/modules/FindCursesAndPanel.cmake
+++ b/lldb/cmake/modules/FindCursesAndPanel.cmake
@@ -2,23 +2,67 @@
# FindCursesAndPanel
# -----------
#
-# Find the curses and panel library as a whole.
+# Find the curses, terminfo, and panel library as a whole.
+
+include(CMakePushCheckState)
+
+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 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)
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_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}")
+ 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()
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I support backporting this
Does this need to be in 20.1.0 or could it wait until 20.1.1 ? |
I think it can wait, I don't think this is urgent until we find others who
need this.
…On Sat, 1 Mar 2025, 14:56 Tom Stellard, ***@***.***> wrote:
Does this need to be in 20.1.0 or could it wait until 20.1.1 ?
—
Reply to this email directly, view it on GitHub
<#129342 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AYVMEOR4YUOP6WRQCH52ZQT2SI3KZAVCNFSM6AAAAABYDNOJQWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOJSGQ2TONZYGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
[image: tstellar]*tstellar* left a comment (llvm/llvm-project#129342)
<#129342 (comment)>
Does this need to be in 20.1.0 or could it wait until 20.1.1 ?
—
Reply to this email directly, view it on GitHub
<#129342 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AYVMEOR4YUOP6WRQCH52ZQT2SI3KZAVCNFSM6AAAAABYDNOJQWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOJSGQ2TONZYGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
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: spack/spack@9ea2612 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 llvm#101368 (cherry picked from commit 8fff0c1)
(cherry picked from commit bb6a273)
@ajordanr-google (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR. |
Fixes building LLDB with ncurses support when terminfo symbols are provided in a separate tinfo library. |
Backport 8fff0c1 bb6a273
Requested by: @ajordanr-google