-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[lldb] Add terminfo dependency for ncurses support #126810
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
[lldb] Add terminfo dependency for ncurses support #126810
Conversation
@llvm/pr-subscribers-lldb Author: Jordan R AW (ajordanr-google) ChangesFor some operating systems, terminfo is a separate package and library from ncurses. Both are still requirements for curses support in lldb, individually. This is a rebase of this original spack commit: Fixes #101368 Full diff: https://github.com/llvm/llvm-project/pull/126810.diff 1 Files Affected:
diff --git a/lldb/cmake/modules/FindCursesAndPanel.cmake b/lldb/cmake/modules/FindCursesAndPanel.cmake
index aaadf214bf54b..df4980cc5e0d1 100644
--- a/lldb/cmake/modules/FindCursesAndPanel.cmake
+++ b/lldb/cmake/modules/FindCursesAndPanel.cmake
@@ -2,12 +2,15 @@
# FindCursesAndPanel
# -----------
#
-# Find the curses and panel library as a whole.
+# Find the curses, terminfo, and panel library as a whole.
+# NOTE: terminfo and curses libraries are required separately, as
+# some systems do not bundle them together.
-if(CURSES_INCLUDE_DIRS AND CURSES_LIBRARIES AND PANEL_LIBRARIES)
+if(CURSES_INCLUDE_DIRS AND CURSES_LIBRARIES AND TINFO_LIBRARIES AND PANEL_LIBRARIES)
set(CURSESANDPANEL_FOUND TRUE)
else()
find_package(Curses QUIET)
+ find_package(TINFO_LIBRARIES NAMES tinfo DOC "The curses tinfo library" QUIET)
find_library(PANEL_LIBRARIES NAMES panel DOC "The curses panel library" QUIET)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CursesAndPanel
@@ -16,9 +19,10 @@ else()
REQUIRED_VARS
CURSES_INCLUDE_DIRS
CURSES_LIBRARIES
+ TINFO_LIBRARIES
PANEL_LIBRARIES)
- if(CURSES_FOUND AND PANEL_LIBRARIES)
- mark_as_advanced(CURSES_INCLUDE_DIRS CURSES_LIBRARIES PANEL_LIBRARIES)
+ if(CURSES_FOUND AND TINFO_LIBRARIES AND PANEL_LIBRARIES)
+ mark_as_advanced(CURSES_INCLUDE_DIRS CURSES_LIBRARIES TINFO_LIBRARIES PANEL_LIBRARIES)
endif()
endif()
|
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 rebase of this original spack commit: spack/spack@9ea2612 Without this fix, LLDB cannot be built on these systems. Fixes llvm#101368
e234376
to
ddd3feb
Compare
Example downstream bug report: https://issuetracker.google.com/369219560 |
|
Hmm. This patch does seem to work locally, so it's not required. I would have thought the logic is entirely in the I understand the issue in point two--this patch may unnecessarily require a separate tinfo library even when the headers and objects are available via ncurses. But could you explain more on your recommended solutions, particularly on why we would need to set an optional variable? If we're going to require a CMAKE flag anyways to show a warning, why not just guard it on a |
Yes, you could do that, but then platforms that have a separate |
Thanks, this does clear it up! Yeah I'd rather have it work out of the box. I'll see what I can do for doing the autodetection ergonomically, and get back to you. If not, I'll add a flag. |
Tested with a system that has bundled terminfo in curses and one without locally! |
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.
LGTM. Thanks for bearing with me!
This apparently broke a downstream edge case with fuchsia: https://issues.fuchsia.dev/397455029, where they set all but the I have given them a downstream fix, but wondering if I can rework the patch so that this isn't an issue. I don't think we need to revert, given this only happens with edge-case defines and it's easily fixed downstream by setting I'm thinking we could make it easier for folks who hit similar errors by doing one of the following:
I don't really have a preference here. I also notice with this commit that we're changing |
Okay, I think I understand what's going on with fuchsia: they manually set (As an aside, while I'm reading this: why is this checking So next we check if the provided
It's fine (and common) for
|
That's correct!
I believe they don't even get this far. They apparently have an issue with find_package/find_library lookup mechanism, and that fails. So it breaks then without even trying to check for the symbol.
Mostly this variable was derived from the spack commit which uses it. That's the only place I know it exists. Technically now fuchsia is using it too, after they implemented the fix (which also logically makes some sense, If we were to hide TINFO_LIBRARIES entirely in the conditional, we must check Cool cool, will do about the |
Turns out
Both Using Everything else I think have working in a new patch. Will upload now. |
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
If this and the follow up are working well, consider backporting them to 20.x. |
We haven't had any issues since on our end. I'll check with Fuchsia again to be sure, then will try to backport. |
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-pick from commit: 8fff0c1)
/pull-request #129342 |
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)
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 #101368