Skip to content

Commit fe82a3d

Browse files
committed
Revert "[Support] Remove terminfo dependency (#92865)"
This reverts commit 6bf450c. It breaks LLDB CI: https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/4762/execution/node/97/log/ ``` /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -Wdocumentation -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-deprecated-register -Wno-vla-extension -O3 -DNDEBUG -arch arm64 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -mmacosx-version-min=14.1 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-dead_strip -Wl,-no_warn_duplicate_libraries tools/lldb/unittests/Editline/CMakeFiles/EditlineTests.dir/EditlineTest.cpp.o -o tools/lldb/unittests/Editline/EditlineTests lib/libLLVMSupport.a lib/libllvm_gtest_main.a lib/libllvm_gtest.a lib/liblldbHost.a lib/liblldbUtility.a lib/libLLVMTestingSupport.a /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/libxml2.tbd /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/libedit.tbd lib/liblldbHostMacOSXObjCXX.a lib/liblldbUtility.a -framework Foundation -framework CoreFoundation -framework CoreServices -framework Security lib/libLLVMObject.a lib/libLLVMIRReader.a lib/libLLVMBitReader.a lib/libLLVMAsmParser.a lib/libLLVMCore.a lib/libLLVMRemarks.a lib/libLLVMBitstreamReader.a lib/libLLVMMCParser.a lib/libLLVMMC.a lib/libLLVMDebugInfoCodeView.a lib/libLLVMTextAPI.a lib/libLLVMBinaryFormat.a lib/libLLVMTargetParser.a lib/libllvm_gtest.a lib/libLLVMSupport.a -lm /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/libz.tbd /opt/homebrew/lib/libzstd.dylib lib/libLLVMDemangle.a -lpthread && cd /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/tools/lldb/unittests/Editline && /opt/homebrew/Cellar/cmake/3.28.3/bin/cmake -E make_directory /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/tools/lldb/unittests/Editline/./Inputs ld: Undefined symbols: _setupterm, referenced from: lldb_private::Editline::Editline(char const*, __sFILE*, __sFILE*, __sFILE*, std::__1::recursive_mutex&) in liblldbHost.a[35](Editline.cpp.o) clang: error: linker command failed with exit code 1 (use -v to see invocation) ```
1 parent b15a0a3 commit fe82a3d

File tree

26 files changed

+218
-12
lines changed

26 files changed

+218
-12
lines changed

clang/cmake/caches/Fuchsia-stage2.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ set(LLVM_ENABLE_LLD ON CACHE BOOL "")
1919
set(LLVM_ENABLE_LTO ON CACHE BOOL "")
2020
set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON CACHE BOOL "")
2121
set(LLVM_ENABLE_PLUGINS OFF CACHE BOOL "")
22+
set(LLVM_ENABLE_TERMINFO OFF CACHE BOOL "")
2223
set(LLVM_ENABLE_UNWIND_TABLES OFF CACHE BOOL "")
2324
set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "")
2425
set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")

clang/cmake/caches/Fuchsia.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ set(LLVM_ENABLE_DIA_SDK OFF CACHE BOOL "")
1212
set(LLVM_ENABLE_LIBEDIT OFF CACHE BOOL "")
1313
set(LLVM_ENABLE_LIBXML2 OFF CACHE BOOL "")
1414
set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON CACHE BOOL "")
15+
set(LLVM_ENABLE_TERMINFO OFF CACHE BOOL "")
1516
set(LLVM_ENABLE_UNWIND_TABLES OFF CACHE BOOL "")
1617
set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "")
1718
set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
@@ -33,6 +34,7 @@ set(_FUCHSIA_BOOTSTRAP_PASSTHROUGH
3334
LibXml2_ROOT
3435
LLVM_ENABLE_CURL
3536
LLVM_ENABLE_HTTPLIB
37+
LLVM_ENABLE_TERMINFO
3638
LLVM_ENABLE_LIBEDIT
3739
CURL_ROOT
3840
OpenSSL_ROOT
@@ -45,6 +47,11 @@ set(_FUCHSIA_BOOTSTRAP_PASSTHROUGH
4547
CURSES_LIBRARIES
4648
PANEL_LIBRARIES
4749

50+
# Deprecated
51+
Terminfo_ROOT
52+
53+
Terminfo_LIBRARIES
54+
4855
# Deprecated
4956
LibEdit_ROOT
5057

clang/cmake/caches/VectorEngine.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
# ninja
1414
#
1515

16-
# Disable ZLIB, and ZSTD for VE since there is no pre-compiled libraries.
16+
# Disable TERMINFO, ZLIB, and ZSTD for VE since there is no pre-compiled
17+
# libraries.
18+
set(LLVM_ENABLE_TERMINFO OFF CACHE BOOL "")
1719
set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
1820
set(LLVM_ENABLE_ZSTD OFF CACHE BOOL "")
1921

clang/utils/analyzer/entrypoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def is_cmake_needed():
5454
"cmake -G Ninja -DCMAKE_BUILD_TYPE=Release "
5555
"-DCMAKE_INSTALL_PREFIX=/analyzer -DLLVM_TARGETS_TO_BUILD=X86 "
5656
'-DLLVM_ENABLE_PROJECTS="clang;openmp" -DLLVM_BUILD_RUNTIME=OFF '
57-
"-DCLANG_ENABLE_ARCMT=OFF "
57+
"-DLLVM_ENABLE_TERMINFO=OFF -DCLANG_ENABLE_ARCMT=OFF "
5858
"-DCLANG_ENABLE_STATIC_ANALYZER=ON"
5959
)
6060

compiler-rt/cmake/config-ix.cmake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,21 @@ check_library_exists(m pow "" COMPILER_RT_HAS_LIBM)
182182
check_library_exists(pthread pthread_create "" COMPILER_RT_HAS_LIBPTHREAD)
183183
check_library_exists(execinfo backtrace "" COMPILER_RT_HAS_LIBEXECINFO)
184184

185+
# Look for terminfo library, used in unittests that depend on LLVMSupport.
186+
if(LLVM_ENABLE_TERMINFO STREQUAL FORCE_ON)
187+
set(MAYBE_REQUIRED REQUIRED)
188+
else()
189+
set(MAYBE_REQUIRED)
190+
endif()
191+
if(LLVM_ENABLE_TERMINFO)
192+
find_library(COMPILER_RT_TERMINFO_LIB NAMES terminfo tinfo curses ncurses ncursesw ${MAYBE_REQUIRED})
193+
endif()
194+
if(COMPILER_RT_TERMINFO_LIB)
195+
set(LLVM_ENABLE_TERMINFO 1)
196+
else()
197+
set(LLVM_ENABLE_TERMINFO 0)
198+
endif()
199+
185200
if (ANDROID AND COMPILER_RT_HAS_LIBDL)
186201
# Android's libstdc++ has a dependency on libdl.
187202
list(APPEND CMAKE_REQUIRED_LIBRARIES dl)

compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ if [[ ! -f ${LLVM_BUILD}/build.ninja ]]; then
139139
-DLLVM_INCLUDE_TESTS=OFF \
140140
-DLLVM_ENABLE_ZLIB=ON \
141141
-DLLVM_ENABLE_ZSTD=OFF \
142+
-DLLVM_ENABLE_TERMINFO=OFF \
142143
-DLLVM_ENABLE_THREADS=OFF \
143144
$LLVM_SRC
144145
fi

compiler-rt/lib/xray/tests/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ set(XRAY_UNITTEST_LINK_FLAGS
5454
${COMPILER_RT_CXX_LINK_LIBS})
5555

5656
if (NOT APPLE)
57+
# Needed by LLVMSupport.
58+
append_list_if(
59+
LLVM_ENABLE_TERMINFO
60+
-l${COMPILER_RT_TERMINFO_LIB} XRAY_UNITTEST_LINK_FLAGS)
61+
5762
# We add the library directories one at a time in our CFLAGS.
5863
foreach (DIR ${LLVM_LIBRARY_DIR})
5964
list(APPEND XRAY_UNITTEST_LINK_FLAGS -L${DIR})

lldb/docs/resources/build.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ further by passing the appropriate cmake options, such as:
477477
-DLLDB_ENABLE_PYTHON=0
478478
-DLLDB_ENABLE_LIBEDIT=0
479479
-DLLDB_ENABLE_CURSES=0
480+
-DLLVM_ENABLE_TERMINFO=0
480481

481482
(see :ref:`Optional Dependencies` for more)
482483

lldb/source/Core/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ set(LLDB_LIBEDIT_LIBS)
1111

1212
if (LLDB_ENABLE_CURSES)
1313
list(APPEND LLDB_CURSES_LIBS ${PANEL_LIBRARIES} ${CURSES_LIBRARIES})
14+
if(LLVM_ENABLE_TERMINFO)
15+
list(APPEND LLDB_CURSES_LIBS ${Terminfo_LIBRARIES})
16+
endif()
1417
if (LLVM_BUILD_STATIC)
1518
list(APPEND LLDB_CURSES_LIBS gpm)
1619
endif()

llvm/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,8 @@ set(FFI_INCLUDE_DIR "" CACHE PATH "Additional directory, where CMake should sear
539539
set(LLVM_TARGET_ARCH "host"
540540
CACHE STRING "Set target to use for LLVM JIT or use \"host\" for automatic detection.")
541541

542+
option(LLVM_ENABLE_TERMINFO "Use terminfo database if available." ON)
543+
542544
set(LLVM_ENABLE_LIBXML2 "ON" CACHE STRING "Use libxml2 if available. Can be ON, OFF, or FORCE_ON")
543545

544546
option(LLVM_ENABLE_LIBEDIT "Use libedit if available." ON)

llvm/cmake/config-ix.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,21 @@ if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
240240
else()
241241
set(HAVE_LIBEDIT 0)
242242
endif()
243+
if(LLVM_ENABLE_TERMINFO)
244+
if(LLVM_ENABLE_TERMINFO STREQUAL FORCE_ON)
245+
find_package(Terminfo REQUIRED)
246+
else()
247+
find_package(Terminfo)
248+
endif()
249+
set(LLVM_ENABLE_TERMINFO "${Terminfo_FOUND}")
250+
endif()
243251
else()
244252
set(HAVE_LIBEDIT 0)
253+
set(LLVM_ENABLE_TERMINFO 0)
245254
endif()
246255
else()
247256
set(HAVE_LIBEDIT 0)
257+
set(LLVM_ENABLE_TERMINFO 0)
248258
endif()
249259

250260
if(LLVM_HAS_LOGF128)

llvm/cmake/modules/FindTerminfo.cmake

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Attempts to discover terminfo library with a linkable setupterm function.
2+
#
3+
# Example usage:
4+
#
5+
# find_package(Terminfo)
6+
#
7+
# If successful, the following variables will be defined:
8+
# Terminfo_FOUND
9+
# Terminfo_LIBRARIES
10+
#
11+
# Additionally, the following import target will be defined:
12+
# Terminfo::terminfo
13+
14+
find_library(Terminfo_LIBRARIES NAMES terminfo tinfo curses ncurses ncursesw)
15+
16+
if(Terminfo_LIBRARIES)
17+
include(CMakePushCheckState)
18+
cmake_push_check_state()
19+
list(APPEND CMAKE_REQUIRED_LIBRARIES ${Terminfo_LIBRARIES})
20+
set(Terminfo_LINKABLE_SRC [=[
21+
#ifdef __cplusplus
22+
extern "C" {
23+
#endif
24+
int setupterm(char *term, int filedes, int *errret);
25+
#ifdef __cplusplus
26+
}
27+
#endif
28+
int main(void) { return setupterm(0, 0, 0); }
29+
]=])
30+
if(DEFINED CMAKE_C_COMPILER)
31+
include(CheckCSourceCompiles)
32+
check_c_source_compiles("${Terminfo_LINKABLE_SRC}" Terminfo_LINKABLE)
33+
else()
34+
include(CheckCXXSourceCompiles)
35+
check_cxx_source_compiles("${Terminfo_LINKABLE_SRC}" Terminfo_LINKABLE)
36+
endif()
37+
cmake_pop_check_state()
38+
endif()
39+
40+
include(FindPackageHandleStandardArgs)
41+
find_package_handle_standard_args(Terminfo
42+
FOUND_VAR
43+
Terminfo_FOUND
44+
REQUIRED_VARS
45+
Terminfo_LIBRARIES
46+
Terminfo_LINKABLE)
47+
mark_as_advanced(Terminfo_LIBRARIES
48+
Terminfo_LINKABLE)
49+
50+
if(Terminfo_FOUND)
51+
if(NOT TARGET Terminfo::terminfo)
52+
add_library(Terminfo::terminfo UNKNOWN IMPORTED)
53+
set_target_properties(Terminfo::terminfo PROPERTIES IMPORTED_LOCATION "${Terminfo_LIBRARIES}")
54+
endif()
55+
endif()

llvm/cmake/modules/LLVMConfig.cmake.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ if(LLVM_ENABLE_LIBEDIT)
6060
find_package(LibEdit)
6161
endif()
6262

63+
set(LLVM_ENABLE_TERMINFO @LLVM_ENABLE_TERMINFO@)
64+
if(LLVM_ENABLE_TERMINFO)
65+
find_package(Terminfo)
66+
endif()
67+
6368
set(LLVM_ENABLE_THREADS @LLVM_ENABLE_THREADS@)
6469

6570
set(LLVM_ENABLE_UNWIND_TABLES @LLVM_ENABLE_UNWIND_TABLES@)

llvm/docs/ReleaseNotes.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ Changes to LLVM infrastructure
6363
Changes to building LLVM
6464
------------------------
6565

66-
- The ``LLVM_ENABLE_TERMINFO`` flag has been removed. LLVM no longer depends on
67-
terminfo and now always uses the ``TERM`` environment variable for color
68-
support autodetection.
69-
7066
Changes to TableGen
7167
-------------------
7268

llvm/include/llvm/Config/config.h.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@
209209
/* Define to 1 if you have the <sys/types.h> header file. */
210210
#cmakedefine HAVE_SYS_TYPES_H ${HAVE_SYS_TYPES_H}
211211

212+
/* Define if the setupterm() function is supported this platform. */
213+
#cmakedefine LLVM_ENABLE_TERMINFO ${LLVM_ENABLE_TERMINFO}
214+
212215
/* Define to 1 if you have the <termios.h> header file. */
213216
#cmakedefine HAVE_TERMIOS_H ${HAVE_TERMIOS_H}
214217

llvm/lib/Support/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ elseif( CMAKE_HOST_UNIX )
5656
STRING(REGEX REPLACE "^lib" "" Backtrace_LIBFILE ${Backtrace_LIBFILE})
5757
set(system_libs ${system_libs} ${Backtrace_LIBFILE})
5858
endif()
59+
if( LLVM_ENABLE_TERMINFO )
60+
set(imported_libs ${imported_libs} Terminfo::terminfo)
61+
endif()
5962
set(system_libs ${system_libs} ${LLVM_ATOMIC_LIB})
6063
set(system_libs ${system_libs} ${LLVM_PTHREAD_LIB})
6164
if( UNIX AND NOT (BEOS OR HAIKU) )
@@ -322,6 +325,14 @@ if(LLVM_ENABLE_ZSTD)
322325
set(llvm_system_libs ${llvm_system_libs} "${zstd_library}")
323326
endif()
324327

328+
if(LLVM_ENABLE_TERMINFO)
329+
if(NOT terminfo_library)
330+
get_property(terminfo_library TARGET Terminfo::terminfo PROPERTY LOCATION)
331+
endif()
332+
get_library_name(${terminfo_library} terminfo_library)
333+
set(llvm_system_libs ${llvm_system_libs} "${terminfo_library}")
334+
endif()
335+
325336
set_property(TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS "${llvm_system_libs}")
326337

327338

llvm/lib/Support/Unix/Process.inc

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,17 @@ unsigned Process::StandardErrColumns() {
341341
return getColumns();
342342
}
343343

344-
static bool terminalHasColors() {
345-
// Check if the current terminal is one of terminals that are known to support
346-
// ANSI color escape codes.
344+
#ifdef LLVM_ENABLE_TERMINFO
345+
// We manually declare these extern functions because finding the correct
346+
// headers from various terminfo, curses, or other sources is harder than
347+
// writing their specs down.
348+
extern "C" int setupterm(char *term, int filedes, int *errret);
349+
extern "C" struct term *set_curterm(struct term *termp);
350+
extern "C" int del_curterm(struct term *termp);
351+
extern "C" int tigetnum(char *capname);
352+
#endif
353+
354+
bool checkTerminalEnvironmentForColors() {
347355
if (const char *TermStr = std::getenv("TERM")) {
348356
return StringSwitch<bool>(TermStr)
349357
.Case("ansi", true)
@@ -360,10 +368,54 @@ static bool terminalHasColors() {
360368
return false;
361369
}
362370

371+
static bool terminalHasColors(int fd) {
372+
#ifdef LLVM_ENABLE_TERMINFO
373+
// First, acquire a global lock because these C routines are thread hostile.
374+
static std::mutex TermColorMutex;
375+
std::lock_guard<std::mutex> G(TermColorMutex);
376+
377+
struct term *previous_term = set_curterm(nullptr);
378+
int errret = 0;
379+
if (setupterm(nullptr, fd, &errret) != 0)
380+
// Regardless of why, if we can't get terminfo, we shouldn't try to print
381+
// colors.
382+
return false;
383+
384+
// Test whether the terminal as set up supports color output. How to do this
385+
// isn't entirely obvious. We can use the curses routine 'has_colors' but it
386+
// would be nice to avoid a dependency on curses proper when we can make do
387+
// with a minimal terminfo parsing library. Also, we don't really care whether
388+
// the terminal supports the curses-specific color changing routines, merely
389+
// if it will interpret ANSI color escape codes in a reasonable way. Thus, the
390+
// strategy here is just to query the baseline colors capability and if it
391+
// supports colors at all to assume it will translate the escape codes into
392+
// whatever range of colors it does support. We can add more detailed tests
393+
// here if users report them as necessary.
394+
//
395+
// The 'tigetnum' routine returns -2 or -1 on errors, and might return 0 if
396+
// the terminfo says that no colors are supported.
397+
int colors_ti = tigetnum(const_cast<char *>("colors"));
398+
bool HasColors =
399+
colors_ti >= 0 ? colors_ti : checkTerminalEnvironmentForColors();
400+
401+
// Now extract the structure allocated by setupterm and free its memory
402+
// through a really silly dance.
403+
struct term *termp = set_curterm(previous_term);
404+
(void)del_curterm(termp); // Drop any errors here.
405+
406+
// Return true if we found a color capabilities for the current terminal.
407+
return HasColors;
408+
#else
409+
// When the terminfo database is not available, check if the current terminal
410+
// is one of terminals that are known to support ANSI color escape codes.
411+
return checkTerminalEnvironmentForColors();
412+
#endif
413+
}
414+
363415
bool Process::FileDescriptorHasColors(int fd) {
364416
// A file descriptor has colors if it is displayed and the terminal has
365417
// colors.
366-
return FileDescriptorIsDisplayed(fd) && terminalHasColors();
418+
return FileDescriptorIsDisplayed(fd) && terminalHasColors(fd);
367419
}
368420

369421
bool Process::StandardOutHasColors() {

llvm/utils/gn/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ configure is used for three classes of feature checks:
131131

132132
For the last two points, it would be nice if LLVM didn't have a single
133133
``config.h`` header, but one header per toggle. That way, when e.g.
134-
``llvm_enable_zlib`` is toggled, only the 3 files caring about that setting
134+
``llvm_enable_terminfo`` is toggled, only the 3 files caring about that setting
135135
would need to be rebuilt, instead of everything including ``config.h``.
136136

137137
GN doesn't believe in users setting arbitrary cflags from an environment
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import("//llvm/utils/gn/build/libs/terminfo/enable.gni")
2+
3+
config("terminfo_config") {
4+
visibility = [ ":terminfo" ]
5+
libs = [ "ncurses" ]
6+
}
7+
8+
group("terminfo") {
9+
if (llvm_enable_terminfo) {
10+
public_configs = [ ":terminfo_config" ]
11+
}
12+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare_args() {
2+
# Whether to link against terminfo.
3+
llvm_enable_terminfo = false
4+
}

llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import("//llvm/utils/gn/build/buildflags.gni")
1010
import("//llvm/utils/gn/build/libs/curl/enable.gni")
1111
import("//llvm/utils/gn/build/libs/edit/enable.gni")
1212
import("//llvm/utils/gn/build/libs/pthread/enable.gni")
13+
import("//llvm/utils/gn/build/libs/terminfo/enable.gni")
1314
import("//llvm/utils/gn/build/libs/xar/enable.gni")
1415
import("//llvm/utils/gn/build/libs/xml/enable.gni")
1516
import("//llvm/utils/gn/build/libs/zlib/enable.gni")
@@ -293,6 +294,12 @@ write_cmake_config("config") {
293294
values += [ "HAVE_LIBEDIT=" ]
294295
}
295296

297+
if (llvm_enable_terminfo) {
298+
values += [ "LLVM_ENABLE_TERMINFO=1" ]
299+
} else {
300+
values += [ "LLVM_ENABLE_TERMINFO=" ]
301+
}
302+
296303
if (llvm_enable_libxml2) {
297304
values += [ "LLVM_ENABLE_LIBXML2=1" ]
298305
} else {

llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ static_library("Support") {
66
"//llvm/include/llvm/Support:write_vcsrevision",
77
"//llvm/lib/Demangle",
88
"//llvm/utils/gn/build/libs/pthread",
9+
"//llvm/utils/gn/build/libs/terminfo",
910
"//llvm/utils/gn/build/libs/zlib",
1011
]
1112

0 commit comments

Comments
 (0)