Skip to content

Conversation

@at445
Copy link

@at445 at445 commented Jan 31, 2026

Summary

  • Detect and link libtinfo (terminfo) explicitly for cpptest and tvm_allvisible when found.
  • Prevents link-time failures for test binaries when llvm-config does 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

  • With USE_LLVM=ON, the build produced undefined references to terminfo symbols (e.g. tgetstr, setupterm) when linking cpptest. ldd /usr/lib/llvm-18/lib/libLLVM-18.so shows it depends on libedit and libtinfo, but llvm-config --libs --link-static did not include -ltinfo, so CMake didn't add it to the final link.

Change

  • Minimal, portable CMake 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

  • Steps:
    1. cmake -S . -B build-llvm_ON-hide_OFF -DUSE_LLVM=ON -DHIDE_PRIVATE_SYMBOLS=OFF -DUSE_GTEST=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo
    2. cmake --build build-llvm_ON-hide_OFF --target cpptest
  • Expected:
    • Before: link errors referencing terminfo symbols and no cpptest binary produced.
    • After: cpptest links and is produced.

Rationale

  • Safer and more portable than relying on consumers to fix package-level llvm-config exports.
  • No behavioral changes unless tinfo is required and available.

Logs

…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.,
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 cpptest and tvm_allvisible targets. It introduces a robust CMake-based solution to explicitly locate and link the libtinfo library, which is sometimes a missing dependency when llvm-config fails to export it. This ensures that these targets can link successfully across various LLVM configurations, enhancing the overall stability of the build system.

Highlights

  • Terminfo Linking: Explicitly links libtinfo (terminfo) to cpptest and tvm_allvisible targets in CMake when detected.
  • Build Fix: Resolves link-time failures for test binaries, specifically cpptest, that occur when llvm-config does not export -ltinfo, as observed with LLVM 18 on Ubuntu.
  • Portability: Improves build portability and reliability by not relying solely on llvm-config to provide all necessary link flags.

🧠 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant