[Lldb-commits] [PATCH] D47625: [cmake] Detect presence of wide-char libedit at build time

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 1 04:11:52 PDT 2018


labath created this revision.
labath added reviewers: krytarowski, uweigand, jankratochvil, timshen, beanz.
Herald added a subscriber: mgorny.

Instead of hardcoding a list of platforms where libedit is known to have
wide char support we detect this in cmake. The main motivation for this
is attempting to improve compatibility with different versions of
libedit, as the interface of non-wide-char functions varies slightly
between versions.

This should be NFC on all platforms except linux. On linux, we used to
hardcode to non-wide-char, now we will use wide-char if we detect
libedit supports that.


https://reviews.llvm.org/D47625

Files:
  cmake/modules/LLDBGenerateConfig.cmake
  include/lldb/Host/Config.h
  include/lldb/Host/Config.h.cmake
  include/lldb/Host/Editline.h


Index: include/lldb/Host/Editline.h
===================================================================
--- include/lldb/Host/Editline.h
+++ include/lldb/Host/Editline.h
@@ -33,23 +33,11 @@
 #define liblldb_Editline_h_
 #if defined(__cplusplus)
 
+#include <codecvt>
 #include <locale>
 #include <sstream>
 #include <vector>
 
-// components needed to handle wide characters ( <codecvt>, codecvt_utf8,
-// libedit built with '--enable-widec' ) are available on some platforms. The
-// wchar_t versions of libedit functions will only be used in cases where this
-// is true.  This is a compile time dependecy, for now selected per target
-// Platform
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) ||       \
-    defined(__OpenBSD__)
-#define LLDB_EDITLINE_USE_WCHAR 1
-#include <codecvt>
-#else
-#define LLDB_EDITLINE_USE_WCHAR 0
-#endif
-
 #include "lldb/Host/ConnectionFileDescriptor.h"
 #include "lldb/lldb-private.h"
 
Index: include/lldb/Host/Config.h.cmake
===================================================================
--- include/lldb/Host/Config.h.cmake
+++ include/lldb/Host/Config.h.cmake
@@ -12,6 +12,8 @@
 
 #cmakedefine LLDB_CONFIG_TERMIOS_SUPPORTED
 
+#cmakedefine01 LLDB_EDITLINE_USE_WCHAR
+
 #cmakedefine LLDB_DISABLE_POSIX
 
 #define LLDB_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}"
Index: include/lldb/Host/Config.h
===================================================================
--- include/lldb/Host/Config.h
+++ include/lldb/Host/Config.h
@@ -16,6 +16,8 @@
 // absence of a configuration step.
 #define LLDB_CONFIG_TERMIOS_SUPPORTED 1
 
+#define LLDB_EDITLINE_USE_WCHAR 1
+
 #define HAVE_SYS_EVENT_H 1
 
 #define HAVE_PPOLL 0
Index: cmake/modules/LLDBGenerateConfig.cmake
===================================================================
--- cmake/modules/LLDBGenerateConfig.cmake
+++ cmake/modules/LLDBGenerateConfig.cmake
@@ -33,6 +33,16 @@
   set(LLDB_DISABLE_POSIX 1)
 endif()
 
+if (NOT LLDB_DISABLE_LIBEDIT)
+  # Check if we libedit capable of handling wide characters (built with
+  # '--enable-widec').
+  set(CMAKE_REQUIRED_LIBRARIES ${libedit_LIBRARIES})
+  set(CMAKE_REQUIRED_INCLUDES ${libedit_INCLUDE_DIRS})
+  check_symbol_exists(el_winsertstr histedit.h LLDB_EDITLINE_USE_WCHAR)
+  set(CMAKE_REQUIRED_LIBRARIES)
+  set(CMAKE_REQUIRED_INCLUDES)
+endif()
+
 if(NOT LLDB_CONFIG_HEADER_INPUT)
  set(LLDB_CONFIG_HEADER_INPUT ${LLDB_INCLUDE_ROOT}/lldb/Host/Config.h.cmake)
 endif()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47625.149429.patch
Type: text/x-patch
Size: 2443 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20180601/ed966e54/attachment.bin>


More information about the lldb-commits mailing list