[Lldb-commits] [lldb] cdcb9ab - Revert "Use find_library for ncurses"
Galina Kistanova via lldb-commits
lldb-commits at lists.llvm.org
Thu Aug 27 17:57:57 PDT 2020
Author: Harmen Stoppels
Date: 2020-08-27T17:57:26-07:00
New Revision: cdcb9ab10e53ff08293915af3cd897c42112bcc5
URL: https://github.com/llvm/llvm-project/commit/cdcb9ab10e53ff08293915af3cd897c42112bcc5
DIFF: https://github.com/llvm/llvm-project/commit/cdcb9ab10e53ff08293915af3cd897c42112bcc5.diff
LOG: Revert "Use find_library for ncurses"
The introduction of find_library for ncurses caused more issues than it solved problems. The current open issue is it makes the static build of LLVM fail. It is better to revert for now, and get back to it later.
Revert "[CMake] Fix an issue where get_system_libname creates an empty regex capture on windows"
This reverts commit 1ed1e16ab83f55d85c90ae43a05cbe08a00c20e0.
Revert "Fix msan build"
This reverts commit 34fe9613dda3c7d8665b609136a8c12deb122382.
Revert "[CMake] Always mark terminfo as unavailable on Windows"
This reverts commit 76bf26236f6fd453343666c3cd91de8f74ffd89d.
Revert "[CMake] Fix OCaml build failure because of absolute path in system libs"
This reverts commit 8e4acb82f71ad4effec8895b8fc957189ce95933.
Revert "[CMake] Don't look for terminfo libs when LLVM_ENABLE_TERMINFO=OFF"
This reverts commit 495f91fd33d492941c39424a32cf24bcfe192f35.
Revert "Use find_library for ncurses"
This reverts commit a52173a3e56553d7b795bcf3cdadcf6433117107.
Differential revision: https://reviews.llvm.org/D86521
Added:
Modified:
compiler-rt/cmake/config-ix.cmake
compiler-rt/lib/xray/tests/CMakeLists.txt
lldb/source/Core/CMakeLists.txt
llvm/cmake/config-ix.cmake
llvm/include/llvm/Config/config.h.cmake
llvm/lib/Support/CMakeLists.txt
llvm/lib/Support/Unix/Process.inc
llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
Removed:
################################################################################
diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
index 1428a514b55a..5f9e868de5fd 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -133,18 +133,17 @@ check_library_exists(pthread pthread_create "" COMPILER_RT_HAS_LIBPTHREAD)
check_library_exists(execinfo backtrace "" COMPILER_RT_HAS_LIBEXECINFO)
# Look for terminfo library, used in unittests that depend on LLVMSupport.
-if(LLVM_ENABLE_TERMINFO STREQUAL FORCE_ON)
- set(MAYBE_REQUIRED REQUIRED)
-else()
- set(MAYBE_REQUIRED)
-endif()
if(LLVM_ENABLE_TERMINFO)
- find_library(COMPILER_RT_TERMINFO_LIB NAMES terminfo tinfo curses ncurses ncursesw ${MAYBE_REQUIRED})
-endif()
-if(COMPILER_RT_TERMINFO_LIB)
- set(LLVM_ENABLE_TERMINFO 1)
-else()
- set(LLVM_ENABLE_TERMINFO 0)
+ foreach(library terminfo tinfo curses ncurses ncursesw)
+ string(TOUPPER ${library} library_suffix)
+ check_library_exists(
+ ${library} setupterm "" COMPILER_RT_HAS_TERMINFO_${library_suffix})
+ if(COMPILER_RT_HAS_TERMINFO_${library_suffix})
+ set(COMPILER_RT_HAS_TERMINFO TRUE)
+ set(COMPILER_RT_TERMINFO_LIB "${library}")
+ break()
+ endif()
+ endforeach()
endif()
if (ANDROID AND COMPILER_RT_HAS_LIBDL)
diff --git a/compiler-rt/lib/xray/tests/CMakeLists.txt b/compiler-rt/lib/xray/tests/CMakeLists.txt
index 96a9db1ef877..a1fbccaeb6d2 100644
--- a/compiler-rt/lib/xray/tests/CMakeLists.txt
+++ b/compiler-rt/lib/xray/tests/CMakeLists.txt
@@ -55,7 +55,7 @@ set(XRAY_UNITTEST_LINK_FLAGS
if (NOT APPLE)
# Needed by LLVMSupport.
append_list_if(
- LLVM_ENABLE_TERMINFO
+ COMPILER_RT_HAS_TERMINFO
-l${COMPILER_RT_TERMINFO_LIB} XRAY_UNITTEST_LINK_FLAGS)
if (COMPILER_RT_STANDALONE_BUILD)
diff --git a/lldb/source/Core/CMakeLists.txt b/lldb/source/Core/CMakeLists.txt
index 01a25045081f..a4057d11077f 100644
--- a/lldb/source/Core/CMakeLists.txt
+++ b/lldb/source/Core/CMakeLists.txt
@@ -11,8 +11,8 @@ set(LLDB_LIBEDIT_LIBS)
if (LLDB_ENABLE_CURSES)
list(APPEND LLDB_CURSES_LIBS ${CURSES_LIBRARIES} ${PANEL_LIBRARIES})
- if(LLVM_ENABLE_TERMINFO)
- list(APPEND LLDB_CURSES_LIBS ${TERMINFO_LIB})
+ if(LLVM_ENABLE_TERMINFO AND HAVE_TERMINFO)
+ list(APPEND LLDB_CURSES_LIBS ${TERMINFO_LIBS})
endif()
if (LLVM_BUILD_STATIC)
list(APPEND LLDB_CURSES_LIBS gpm)
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 6b92180b739e..72505190e347 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -148,18 +148,19 @@ if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
else()
set(HAVE_LIBEDIT 0)
endif()
- if(LLVM_ENABLE_TERMINFO STREQUAL FORCE_ON)
- set(MAYBE_REQUIRED REQUIRED)
- else()
- set(MAYBE_REQUIRED)
- endif()
if(LLVM_ENABLE_TERMINFO)
- find_library(TERMINFO_LIB NAMES terminfo tinfo curses ncurses ncursesw ${MAYBE_REQUIRED})
- endif()
- if(TERMINFO_LIB)
- set(LLVM_ENABLE_TERMINFO 1)
+ set(HAVE_TERMINFO 0)
+ 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})
+ set(HAVE_TERMINFO 1)
+ set(TERMINFO_LIBS "${library}")
+ break()
+ endif()
+ endforeach()
else()
- set(LLVM_ENABLE_TERMINFO 0)
+ set(HAVE_TERMINFO 0)
endif()
find_library(ICONV_LIBRARY_PATH NAMES iconv libiconv libiconv-2 c)
@@ -176,11 +177,7 @@ if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
endif()
endif()
endif()
- else()
- set(LLVM_ENABLE_TERMINFO 0)
endif()
-else()
- set(LLVM_ENABLE_TERMINFO 0)
endif()
if (LLVM_ENABLE_LIBXML2 STREQUAL "FORCE_ON" AND NOT LLVM_LIBXML2_ENABLED)
diff --git a/llvm/include/llvm/Config/config.h.cmake b/llvm/include/llvm/Config/config.h.cmake
index aec8d08f30e7..90789df356ae 100644
--- a/llvm/include/llvm/Config/config.h.cmake
+++ b/llvm/include/llvm/Config/config.h.cmake
@@ -212,7 +212,7 @@
#cmakedefine HAVE_SYSEXITS_H ${HAVE_SYSEXITS_H}
/* Define if the setupterm() function is supported this platform. */
-#cmakedefine LLVM_ENABLE_TERMINFO ${LLVM_ENABLE_TERMINFO}
+#cmakedefine HAVE_TERMINFO ${HAVE_TERMINFO}
/* Define if the xar_open() function is supported this platform. */
#cmakedefine HAVE_LIBXAR ${HAVE_LIBXAR}
diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
index ed90c911c0b3..cf7408143361 100644
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/llvm/lib/Support/CMakeLists.txt
@@ -2,19 +2,6 @@ if(LLVM_ENABLE_ZLIB)
set(imported_libs ZLIB::ZLIB)
endif()
-function(get_system_libname libpath libname)
- get_filename_component(libpath ${libpath} NAME)
- if( CMAKE_FIND_LIBRARY_PREFIXES )
- string(REPLACE ";" "|" PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
- string(REGEX REPLACE "^(${PREFIXES})" "" libpath ${libpath})
- endif()
- if( CMAKE_FIND_LIBRARY_SUFFIXES )
- string(REPLACE ";" "|" SUFFIXES "${CMAKE_FIND_LIBRARY_SUFFIXES}")
- string(REGEX REPLACE "(${SUFFIXES})$" "" libpath ${libpath})
- endif()
- set(${libname} "${libpath}" PARENT_SCOPE)
-endfunction()
-
if( MSVC OR MINGW )
# libuuid required for FOLDERID_Profile usage in lib/Support/Windows/Path.inc.
# advapi32 required for CryptAcquireContextW in lib/Support/Windows/Path.inc.
@@ -34,8 +21,10 @@ elseif( CMAKE_HOST_UNIX )
STRING(REGEX REPLACE "^lib" "" Backtrace_LIBFILE ${Backtrace_LIBFILE})
set(system_libs ${system_libs} ${Backtrace_LIBFILE})
endif()
- if( LLVM_ENABLE_TERMINFO )
- set(imported_libs ${imported_libs} "${TERMINFO_LIB}")
+ if(LLVM_ENABLE_TERMINFO)
+ if(HAVE_TERMINFO)
+ set(system_libs ${system_libs} ${TERMINFO_LIBS})
+ endif()
endif()
if( LLVM_ENABLE_THREADS AND (HAVE_LIBATOMIC OR HAVE_CXX_LIBATOMICS64) )
set(system_libs ${system_libs} atomic)
@@ -248,15 +237,20 @@ if(LLVM_ENABLE_ZLIB)
if(NOT zlib_library)
get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION)
endif()
- get_system_libname(${zlib_library} zlib_library)
+ get_filename_component(zlib_library ${zlib_library} NAME)
+ if(CMAKE_STATIC_LIBRARY_PREFIX AND CMAKE_STATIC_LIBRARY_SUFFIX AND
+ zlib_library MATCHES "^${CMAKE_STATIC_LIBRARY_PREFIX}.*${CMAKE_STATIC_LIBRARY_SUFFIX}$")
+ STRING(REGEX REPLACE "^${CMAKE_STATIC_LIBRARY_PREFIX}" "" zlib_library ${zlib_library})
+ STRING(REGEX REPLACE "${CMAKE_STATIC_LIBRARY_SUFFIX}$" "" zlib_library ${zlib_library})
+ endif()
+ if(CMAKE_SHARED_LIBRARY_PREFIX AND CMAKE_SHARED_LIBRARY_SUFFIX AND
+ zlib_library MATCHES "^${CMAKE_SHARED_LIBRARY_PREFIX}.*${CMAKE_SHARED_LIBRARY_SUFFIX}$")
+ STRING(REGEX REPLACE "^${CMAKE_SHARED_LIBRARY_PREFIX}" "" zlib_library ${zlib_library})
+ STRING(REGEX REPLACE "${CMAKE_SHARED_LIBRARY_SUFFIX}$" "" zlib_library ${zlib_library})
+ endif()
set(llvm_system_libs ${llvm_system_libs} "${zlib_library}")
endif()
-if(LLVM_ENABLE_TERMINFO)
- get_system_libname(${TERMINFO_LIB} terminfo_library)
- set(llvm_system_libs ${llvm_system_libs} "${terminfo_library}")
-endif()
-
set_property(TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS "${llvm_system_libs}")
if(LLVM_WITH_Z3)
diff --git a/llvm/lib/Support/Unix/Process.inc b/llvm/lib/Support/Unix/Process.inc
index 7425d084da27..24f16b51af7b 100644
--- a/llvm/lib/Support/Unix/Process.inc
+++ b/llvm/lib/Support/Unix/Process.inc
@@ -313,7 +313,7 @@ unsigned Process::StandardErrColumns() {
return getColumns();
}
-#ifdef LLVM_ENABLE_TERMINFO
+#ifdef HAVE_TERMINFO
// We manually declare these extern functions because finding the correct
// headers from various terminfo, curses, or other sources is harder than
// writing their specs down.
@@ -323,12 +323,12 @@ extern "C" int del_curterm(struct term *termp);
extern "C" int tigetnum(char *capname);
#endif
-#ifdef LLVM_ENABLE_TERMINFO
+#ifdef HAVE_TERMINFO
static ManagedStatic<std::mutex> TermColorMutex;
#endif
static bool terminalHasColors(int fd) {
-#ifdef LLVM_ENABLE_TERMINFO
+#ifdef HAVE_TERMINFO
// First, acquire a global lock because these C routines are thread hostile.
std::lock_guard<std::mutex> G(*TermColorMutex);
diff --git a/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn b/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
index d54242da38cc..03dc191f8ffd 100644
--- a/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
@@ -286,9 +286,9 @@ write_cmake_config("config") {
}
if (llvm_enable_terminfo) {
- values += [ "LLVM_ENABLE_TERMINFO=1" ]
+ values += [ "HAVE_TERMINFO=1" ]
} else {
- values += [ "LLVM_ENABLE_TERMINFO=" ]
+ values += [ "HAVE_TERMINFO=" ]
}
if (llvm_enable_dia_sdk) {
More information about the lldb-commits
mailing list