-
Notifications
You must be signed in to change notification settings - Fork 3.8k
cmake: link terminfo to cpptest/tvm_allvisible when required by LLVM/libedit #18700
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
base: main
Are you sure you want to change the base?
Conversation
…libedit\n\nDetect and link libtinfo explicitly to avoid missing terminfo symbols when llvm-config does not export -ltinfo. This fixes cpptest link failures observed with USE_LLVM=ON on some systems (e.g. LLVM 18 packaged without propagating terminfo).\n\nReproduction: cmake -S . -B build-llvm_ON-hide_OFF -DUSE_LLVM=ON -DHIDE_PRIVATE_SYMBOLS=OFF -DUSE_GTEST=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo && cmake --build build-llvm_ON-hide_OFF --target cpptest\n\nVerified: cpptest now links successfully when libtinfo is present on the system and was added as a conditional link target.,
Summary of ChangesHello @at445, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a specific build issue encountered when compiling with LLVM, particularly affecting the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request adds logic to link libtinfo when building tests with LLVM to fix link-time failures on some systems. The change is correct in principle. My review includes a suggestion to improve the implementation by making the logic conditional on LLVM being used and by using a more portable CMake command to find the required library. This will improve maintainability and portability.
…erminfo with Curses
| # Ensure we link terminfo when required by LLVM / libedit at link time. | ||
| find_package(Curses) | ||
| if(CURSES_FOUND) | ||
| message(STATUS "Found Curses/terminfo library: ${CURSES_LIBRARIES}") |
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 think llvm only requires tinfo but not curses library? we do want to avoid dependency bloat in this case
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.
The dependency should also be specified and captured through llvm config in findllm instead of here
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.
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.
You're right, tqchen raises a good point about dependency bloat. While find_package(Curses) often works because libtinfo is frequently bundled with ncurses, explicitly searching for libtinfo is more precise if that's the only required dependency. This helps avoid pulling in unnecessary parts of the Curses library.
My initial suggestion aimed for a common, robust way to find terminal-related libraries, but find_library(TINFO_LIB tinfo) directly addresses the specific missing dependency (libtinfo) as indicated by your problem description. This is a medium severity suggestion to improve precision and minimize dependencies.
Regarding tqchen's second point, ideally, llvm-config should provide all necessary linker flags for its dependencies. If it doesn't include -ltinfo on certain systems, then explicitly finding and linking it as a workaround is a pragmatic approach for now. The long-term solution would involve ensuring FindLLVM.cmake or the llvm-config output itself correctly reports this dependency.
| message(STATUS "Found Curses/terminfo library: ${CURSES_LIBRARIES}") | |
| find_library(TINFO_LIB tinfo) | |
| if(TINFO_LIB) | |
| message(STATUS "Found terminfo library: ${TINFO_LIB}") | |
| target_link_libraries(cpptest PRIVATE ${TINFO_LIB}) | |
| if(TARGET tvm_allvisible) | |
| target_link_libraries(tvm_allvisible PRIVATE ${TINFO_LIB}) | |
| 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.
The dependency should also be specified and captured through llvm config in findllm instead of here
you are right! I will rethink about it

Summary
cpptestandtvm_allvisiblewhen found.llvm-configdoes not export-ltinfo, which can happen with some LLVM packages (observed with LLVM 18 in Ubuntu 24.04.3 LTS (x86_64-linux-gnu) ).Problem
tgetstr,setupterm) when linkingcpptest.ldd /usr/lib/llvm-18/lib/libLLVM-18.soshows it depends onlibeditandlibtinfo, butllvm-config --libs --link-staticdid not include-ltinfo, so CMake didn't add it to the final link.Change
find_library(TINFO_LIB tinfo)and, if found,target_link_libraries(cpptest PRIVATE ${TINFO_LIB})and, when present,target_link_libraries(tvm_allvisible PRIVATE ${TINFO_LIB}).Reproduction
cpptestbinary produced.cpptestlinks and is produced.Rationale
llvm-configexports.tinfois required and available.Logs
build-llvm_ON-hide_OFF.build.log
build-llvm_ON-hide_OFF.cmake.log
build-llvm_ON-hide_ON.build.log
build-llvm_ON-hide_ON.cmake.log