This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] [cmake] Fix detecting terminfo library
ClosedPublic

Authored by mgorny on Nov 16 2018, 11:30 AM.

Details

Summary

Copy the fix for determining the correct terminfo library from LLVM --
use distinct variables for check_library_exists() calls. Otherwise,
the first check (for -ltinfo) populates the variable and no other checks
are performed. Effectively, systems with other libraries than the first
one listed are presumed not to have terminfo routines at all.

Also sync the check order to include the NetBSD fix from r347156.

This partially fixes undefined symbols when linking XRay tests. It's
probably not the best solution to the problem there but as long
as the terminfo check stays in config-ix, I thnk it's worth fixing.

Diff Detail

Event Timeline

mgorny created this revision.Nov 16 2018, 11:30 AM
Herald added subscribers: Restricted Project, llvm-commits. · View Herald TranscriptNov 16 2018, 11:30 AM

I have got a local patch in pkgsrc-wip/llvm-netbsd:

$NetBSD$

--- cmake/config-ix.cmake.orig	2017-12-08 18:50:04.615602612 +0000
+++ cmake/config-ix.cmake
@@ -153,7 +153,7 @@ if(NOT LLVM_USE_SANITIZER MATCHES "Memor
     endif()
     if(LLVM_ENABLE_TERMINFO)
       set(HAVE_TERMINFO 0)
-      foreach(library tinfo terminfo curses ncurses ncursesw)
+      foreach(library terminfo tinfo curses ncurses ncursesw)
         string(TOUPPER ${library} library_suffix)
         check_library_exists(${library} setupterm "" HAVE_TERMINFO_${library_suffix})
         if(HAVE_TERMINFO_${library_suffix})

Shouldn't we apply it here too?

Context:

Do not return -ltinfo from llvm-config --system-libs --link-static

under NetBSD. Bump PKGREVISION

Rust language 1.20.0 uses these options and Rust build system uses it
as '-l tinfo' and our wrapper does not handle this.

https://github.com/NetBSD/pkgsrc/commit/2ca60b7c8cec0e6c0f3100d9439b6d126424ae2d#diff-079668572f99829ef3e9afc048ebc7a0

As I understand it -ltinfo vs -lterminfo is mixing native curses(3) and external ncurses(3) from pkgsrc, while we prefer to use entirely our native version for all LLVM projects.

Well, sure but I think changing the order should be done separately from this. I'm fixing a bug resulting from people deciding to customize code instead of keeping it in sync; so I'd rather not combine it with intentionally mis-syncing the code.

krytarowski accepted this revision.Nov 16 2018, 1:39 PM

Well, sure but I think changing the order should be done separately from this. I'm fixing a bug resulting from people deciding to customize code instead of keeping it in sync; so I'd rather not combine it with intentionally mis-syncing the code.

It will be good to evaluate the changed order (in particular whether it still works fine on Linux).

This revision is now accepted and ready to land.Nov 16 2018, 1:39 PM
mgorny updated this revision to Diff 174534.Nov 18 2018, 4:35 AM
mgorny edited the summary of this revision. (Show Details)

Updated for check order change in master.

This revision was automatically updated to reflect the committed changes.