When compiling LLVM on Spack, I saw library linking to my system libtinfo rather than the spack built ncurses. This is because the search path in config-ix.cmake list tinfo first.
The atttached patch creates a new variable to use to specify the library that contains the tinfo symbols, and then makes sure that it is first in the list. This may need to have a conditional relationship with LLVM_ENABLE_TERMINFO but that is not done in this patch.