From d989e596998d89752df619d7ccb134223e03dd55 Mon Sep 17 00:00:00 2001 From: Konstantin Podshumok Date: Tue, 18 Aug 2020 21:03:37 +0300 Subject: [PATCH] unbundled: link with termcap when using static llvm ld.lld: error: undefined symbol: setupterm referenced by Process.cpp.o:(llvm::sys::Process::FileDescriptorHasColors(int)) in archive /usr/lib/llvm-9/lib/libLLVMSupport.a Squashed: - fixup termcap + external llvm Signed-off-by: Konstantin Podshumok --- CMakeLists.txt | 2 +- cmake/find/llvm.cmake | 5 +++-- cmake/find/termcap.cmake | 23 ++++++++++++++++------- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 88092681e35..e956ffbfb40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -393,7 +393,6 @@ include (cmake/find/icu.cmake) include (cmake/find/zlib.cmake) include (cmake/find/zstd.cmake) include (cmake/find/ltdl.cmake) # for odbc -include (cmake/find/termcap.cmake) # openssl, zlib before poco include (cmake/find/sparsehash.cmake) include (cmake/find/re2.cmake) @@ -404,6 +403,7 @@ include (cmake/find/rdkafka.cmake) include (cmake/find/amqpcpp.cmake) include (cmake/find/capnp.cmake) include (cmake/find/llvm.cmake) +include (cmake/find/termcap.cmake) # for external static llvm include (cmake/find/opencl.cmake) include (cmake/find/h3.cmake) include (cmake/find/libxml2.cmake) diff --git a/cmake/find/llvm.cmake b/cmake/find/llvm.cmake index 9542b8da6fc..70d0e356c39 100644 --- a/cmake/find/llvm.cmake +++ b/cmake/find/llvm.cmake @@ -44,8 +44,9 @@ if (NOT USE_INTERNAL_LLVM_LIBRARY) set (USE_EMBEDDED_COMPILER 0) endif() - if (LLVM_FOUND AND OS_LINUX AND USE_LIBCXX) - message(WARNING "Option USE_INTERNAL_LLVM_LIBRARY is not set but the LLVM library from OS packages in Linux is incompatible with libc++ ABI. LLVM Will be disabled.") + if (LLVM_FOUND AND OS_LINUX AND USE_LIBCXX AND NOT FORCE_LLVM_WITH_LIBCXX) + message(WARNING "Option USE_INTERNAL_LLVM_LIBRARY is not set but the LLVM library from OS packages " + "in Linux is incompatible with libc++ ABI. LLVM Will be disabled. Force: -DFORCE_LLVM_WITH_LIBCXX=ON") message (${RECONFIGURE_MESSAGE_LEVEL} "Unsupported LLVM configuration, cannot enable LLVM") set (LLVM_FOUND 0) set (USE_EMBEDDED_COMPILER 0) diff --git a/cmake/find/termcap.cmake b/cmake/find/termcap.cmake index 7564b7134e7..58454165785 100644 --- a/cmake/find/termcap.cmake +++ b/cmake/find/termcap.cmake @@ -1,8 +1,17 @@ -find_library (TERMCAP_LIBRARY tinfo) -if (NOT TERMCAP_LIBRARY) - find_library (TERMCAP_LIBRARY ncurses) +if (ENABLE_EMBEDDED_COMPILER AND NOT USE_INTERNAL_LLVM_LIBRARY AND USE_STATIC_LIBRARIES) + find_library (TERMCAP_LIBRARY tinfo) + if (NOT TERMCAP_LIBRARY) + find_library (TERMCAP_LIBRARY ncurses) + endif() + if (NOT TERMCAP_LIBRARY) + find_library (TERMCAP_LIBRARY termcap) + endif() + + if (NOT TERMCAP_LIBRARY) + message (FATAL_ERROR "Statically Linking external LLVM requires termcap") + endif() + + target_link_libraries(LLVMSupport INTERFACE ${TERMCAP_LIBRARY}) + + message (STATUS "Using termcap: ${TERMCAP_LIBRARY}") endif() -if (NOT TERMCAP_LIBRARY) - find_library (TERMCAP_LIBRARY termcap) -endif() -message (STATUS "Using termcap: ${TERMCAP_LIBRARY}")