I was building LLDB under mingw (x64-4.8.1-posix-seh-rev5) today and these are 
the changes I needed to make the build work. It would be good if people with 
different windows configurations could make sure this doesn't break something 
else. 

I also fixed the Makefile in Interpreter. It used to check for DISABLE_PYTHON 
but was then changed to check for MinGw (DISABLE_PYTHON is defined 
automatically for MinGW, but I think it's a valid use case to define it even on 
other platforms). It now checks for both and actually disables the build of 
LLDWrapPython if requested to do so (before it would still call the target).

http://reviews.llvm.org/D4737

Files:
  include/lldb/Host/windows/win32.h
  lib/Makefile
  source/Host/windows/EditLineWin.cpp
  source/Host/windows/Windows.cpp
  source/Interpreter/Makefile
  source/Plugins/Makefile
  source/Utility/PseudoTerminal.cpp
  tools/driver/Driver.cpp
Index: include/lldb/Host/windows/win32.h
===================================================================
--- include/lldb/Host/windows/win32.h
+++ include/lldb/Host/windows/win32.h
@@ -13,8 +13,11 @@
 #include <stdarg.h>
 #include <time.h>
 
+extern "C" {
 // posix utilities
+#ifndef __MINGW32__
 int vasprintf(char **ret, const char *fmt, va_list ap);
+#endif
 char * strcasestr(const char *s, const char* find);
 char* realpath(const char * name, char * resolved);
 
@@ -51,8 +54,10 @@
 typedef unsigned short mode_t;
 
 #ifdef LLDB_DISABLE_PYTHON
+#ifdef __MINGW32__
 typedef uint32_t pid_t;
 #endif
+#endif
 
 int usleep(uint32_t useconds);
 
@@ -75,12 +80,14 @@
 #define snprintf _snprintf
 #endif
 
+#ifndef __MINGW32__
 // timespec
 struct timespec
 {
     time_t tv_sec;
     long   tv_nsec;
 };
-
+#endif
+} // extern "C"
 
 #endif  // LLDB_lldb_win32_h_
Index: lib/Makefile
===================================================================
--- lib/Makefile
+++ lib/Makefile
@@ -121,6 +121,7 @@
 ifeq ($(HOST_OS),MingW)
   USEDLIBS += lldbHostWindows.a \
               lldbPluginProcessElfCore.a \
+              lldbPluginProcessWindows.a \
               lldbPluginJITLoaderGDB.a
 endif
 
Index: source/Host/windows/EditLineWin.cpp
===================================================================
--- source/Host/windows/EditLineWin.cpp
+++ source/Host/windows/EditLineWin.cpp
@@ -47,7 +47,11 @@
 static char *
 el_get_s (char *buffer, int chars)
 {
+#ifdef __MINGW32__
+    return fgets(buffer,chars,stdin);
+#else
     return gets_s(buffer, chars);
+#endif
 }
 #else
 
Index: source/Host/windows/Windows.cpp
===================================================================
--- source/Host/windows/Windows.cpp
+++ source/Host/windows/Windows.cpp
@@ -20,6 +20,8 @@
 #include <cerrno>
 #include <ctype.h>
 
+extern "C" {
+#ifndef __MINGW32__
 int vasprintf(char **ret, const char *fmt, va_list ap)
 {
     char *buf;
@@ -46,6 +48,7 @@
     va_end(ap2);
     return len;
 }
+#endif
 
 char* strcasestr(const char *s, const char* find)
 {
@@ -191,3 +194,4 @@
 }
 
 #endif // _MSC_VER
+}
\ No newline at end of file
Index: source/Interpreter/Makefile
===================================================================
--- source/Interpreter/Makefile
+++ source/Interpreter/Makefile
@@ -13,12 +13,16 @@
 include $(LLDB_LEVEL)/../../Makefile.config
 
 ifneq ($(HOST_OS),MingW)
+ifeq (,$(findstring -DLLDB_DISABLE_PYTHON,$(CXXFLAGS)))
+DO_BUILD = 1
 BUILT_SOURCES := LLDBWrapPython.cpp
 endif
+endif
 
 include $(LLDB_LEVEL)/Makefile
 -include $(PROJ_OBJ_DIR)/LLDBWrapPython.cpp.d
 
+ifeq ($(DO_BUILD),1)
 # Drop -Wfour-char-constants,  which we are not currently clean with.
 EXTRA_OPTIONS += -Wno-four-char-constants
 
@@ -40,3 +44,4 @@
 
 clean-local::
 	$(Verb) $(RM) -f LLDBWrapPython.cpp lldb.py
+endif
\ No newline at end of file
Index: source/Plugins/Makefile
===================================================================
--- source/Plugins/Makefile
+++ source/Plugins/Makefile
@@ -47,6 +47,7 @@
 
 ifeq ($(HOST_OS),MingW)
 DIRS += Process/elf-core
+DIRS += Process/Windows
 DIRS += JITLoader/GDB
 endif
 
Index: source/Utility/PseudoTerminal.cpp
===================================================================
--- source/Utility/PseudoTerminal.cpp
+++ source/Utility/PseudoTerminal.cpp
@@ -19,7 +19,12 @@
 
 #ifdef _WIN32
 #include "lldb/Host/windows/win32.h"
+
+#ifndef __MINGW32__
+#ifndef LLDB_DISABLE_PYTHON
 typedef uint32_t pid_t;
+#endif
+#endif
 // empty functions
 int posix_openpt(int flag) { return 0; }
 
Index: tools/driver/Driver.cpp
===================================================================
--- tools/driver/Driver.cpp
+++ tools/driver/Driver.cpp
@@ -7,8 +7,14 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include <signal.h>
+
 #include "Driver.h"
 
+#ifdef __MINGW32__
+#include <sys/stat.h>
+#endif
+
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -910,7 +916,12 @@
         
         if (lldb_temp_dir_spec.GetPath(lldb_cmds_file, sizeof(lldb_cmds_file)))
         {
+#ifndef __MINGW32__
             int fd = mkstemp(lldb_cmds_file);
+#else
+            mktemp(lldb_cmds_file);
+            int fd = open(lldb_cmds_file,S_IRUSR|S_IWUSR|O_RDWR);
+#endif
             if (fd == -1)
             {
                 fprintf(stderr, "error: can't create temporary file for LLDB commands\n");
@@ -996,6 +1007,7 @@
 	exit (signo);
 }
 
+#ifndef _WIN32
 void
 sigtstp_handler (int signo)
 {
@@ -1013,6 +1025,7 @@
     kill (getpid(), signo);
     signal (signo, sigcont_handler);
 }
+#endif
 
 int
 main (int argc, char const *argv[], const char *envp[])
@@ -1027,11 +1040,13 @@
     
     SBHostOS::ThreadCreated ("<lldb.driver.main-thread>");
 
+#ifndef __MINGW32__
     signal (SIGPIPE, SIG_IGN);
     signal (SIGWINCH, sigwinch_handler);
-    signal (SIGINT, sigint_handler);
     signal (SIGTSTP, sigtstp_handler);
     signal (SIGCONT, sigcont_handler);
+#endif
+    signal (SIGINT, sigint_handler);
 
     // Create a scope for driver so that the driver object will destroy itself
     // before SBDebugger::Terminate() is called.
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

Reply via email to