abidh created this revision. abidh added reviewers: labath, zturner. abidh added a subscriber: lldb-commits. Herald added subscribers: mgorny, ki.stfu.
I was building lldb using cross mingw-w64 toolchain on Linux and observed some issues. This is first patch in the series to fix that build. It mostly corrects the case of include files and adjusts some #ifdefs from _MSC_VER to _WIN32 and vice versa. I built lldb on windows with VS after applying this patch to make sure it does not break the build there. https://reviews.llvm.org/D27759 Files: cmake/LLDBDependencies.cmake cmake/modules/AddLLDB.cmake cmake/modules/LLDBConfig.cmake include/lldb/Host/windows/windows.h source/API/SystemInitializerFull.cpp source/Core/Mangled.cpp source/Host/common/File.cpp source/Host/windows/Host.cpp source/Host/windows/HostProcessWindows.cpp source/Host/windows/ProcessRunLock.cpp source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp source/Plugins/Process/Windows/Common/ExceptionRecord.h source/Target/ProcessLaunchInfo.cpp tools/driver/Driver.cpp tools/lldb-mi/MICmnStreamStdin.cpp tools/lldb-mi/MIUtilDebug.cpp
Index: tools/lldb-mi/MIUtilDebug.cpp =================================================================== --- tools/lldb-mi/MIUtilDebug.cpp +++ tools/lldb-mi/MIUtilDebug.cpp @@ -9,7 +9,7 @@ // Third party headers: #ifdef _WIN32 -#include <Windows.h> +#include <windows.h> #endif // In-house headers: Index: tools/lldb-mi/MICmnStreamStdin.cpp =================================================================== --- tools/lldb-mi/MICmnStreamStdin.cpp +++ tools/lldb-mi/MICmnStreamStdin.cpp @@ -9,7 +9,7 @@ // Third Party Headers #ifdef _MSC_VER -#include <Windows.h> +#include <windows.h> #endif #include <string.h> // For std::strerror() Index: tools/driver/Driver.cpp =================================================================== --- tools/driver/Driver.cpp +++ tools/driver/Driver.cpp @@ -1208,13 +1208,13 @@ } int -#ifdef WIN32 +#ifdef _MSC_VER wmain(int argc, wchar_t const *wargv[]) #else main(int argc, char const *argv[]) #endif { -#ifdef _WIN32 +#ifdef _MSC_VER // Convert wide arguments to UTF-8 std::vector<std::string> argvStrings(argc); std::vector<const char *> argvPointers(argc); Index: source/Target/ProcessLaunchInfo.cpp =================================================================== --- source/Target/ProcessLaunchInfo.cpp +++ source/Target/ProcessLaunchInfo.cpp @@ -294,7 +294,7 @@ __FUNCTION__); int open_flags = O_RDWR | O_NOCTTY; -#if !defined(_MSC_VER) +#if !defined(_WIN32) // We really shouldn't be specifying platform specific flags // that are intended for a system call in generic code. But // this will have to do for now. Index: source/Plugins/Process/Windows/Common/ExceptionRecord.h =================================================================== --- source/Plugins/Process/Windows/Common/ExceptionRecord.h +++ source/Plugins/Process/Windows/Common/ExceptionRecord.h @@ -12,7 +12,7 @@ #include "lldb/Host/windows/windows.h" #include "lldb/lldb-forward.h" -#include <DbgHelp.h> +#include <dbghelp.h> #include <memory> #include <vector> Index: source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp =================================================================== --- source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp +++ source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp @@ -16,7 +16,7 @@ #ifdef _WIN32 #include "lldb/Host/windows/windows.h" -#include <DbgHelp.h> // for MiniDumpWriteDump +#include <dbghelp.h> // for MiniDumpWriteDump #endif namespace lldb_private { Index: source/Host/windows/ProcessRunLock.cpp =================================================================== --- source/Host/windows/ProcessRunLock.cpp +++ source/Host/windows/ProcessRunLock.cpp @@ -10,16 +10,6 @@ #include "lldb/Host/ProcessRunLock.h" #include "lldb/Host/windows/windows.h" -namespace { -#if defined(__MINGW32__) -// Taken from WinNT.h -typedef struct _RTL_SRWLOCK { PVOID Ptr; } RTL_SRWLOCK, *PRTL_SRWLOCK; - -// Taken from WinBase.h -typedef RTL_SRWLOCK SRWLOCK, *PSRWLOCK; -#endif -} - static PSRWLOCK GetLock(lldb::rwlock_t lock) { return static_cast<PSRWLOCK>(lock); } Index: source/Host/windows/HostProcessWindows.cpp =================================================================== --- source/Host/windows/HostProcessWindows.cpp +++ source/Host/windows/HostProcessWindows.cpp @@ -16,7 +16,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Support/ConvertUTF.h" -#include <Psapi.h> +#include <psapi.h> using namespace lldb_private; Index: source/Host/windows/Host.cpp =================================================================== --- source/Host/windows/Host.cpp +++ source/Host/windows/Host.cpp @@ -29,7 +29,7 @@ #include "llvm/Support/ConvertUTF.h" // Windows includes -#include <TlHelp32.h> +#include <tlhelp32.h> using namespace lldb; using namespace lldb_private; Index: source/Host/common/File.cpp =================================================================== --- source/Host/common/File.cpp +++ source/Host/common/File.cpp @@ -222,7 +222,7 @@ } do { -#ifdef _WIN32 +#ifdef _MSC_VER std::wstring wpath; if (!llvm::ConvertUTF8toWide(path, wpath)) { m_descriptor = -1; Index: source/Core/Mangled.cpp =================================================================== --- source/Core/Mangled.cpp +++ source/Core/Mangled.cpp @@ -9,9 +9,9 @@ // FreeBSD9-STABLE requires this to know about size_t in cxxabi.h #include <cstddef> -#if defined(_MSC_VER) +#if defined(_WIN32) #include "lldb/Host/windows/windows.h" -#include <Dbghelp.h> +#include <dbghelp.h> #pragma comment(lib, "dbghelp.lib") #endif Index: source/API/SystemInitializerFull.cpp =================================================================== --- source/API/SystemInitializerFull.cpp +++ source/API/SystemInitializerFull.cpp @@ -107,7 +107,7 @@ #include "Plugins/Process/FreeBSD/ProcessFreeBSD.h" #endif -#if defined(_MSC_VER) +#if defined(_WIN32) #include "Plugins/Process/Windows/Common/ProcessWindows.h" #include "lldb/Host/windows/windows.h" #endif @@ -332,7 +332,7 @@ ObjCPlusPlusLanguage::Initialize(); OCamlLanguage::Initialize(); -#if defined(_MSC_VER) +#if defined(_WIN32) ProcessWindows::Initialize(); #endif #if defined(__FreeBSD__) Index: include/lldb/Host/windows/windows.h =================================================================== --- include/lldb/Host/windows/windows.h +++ include/lldb/Host/windows/windows.h @@ -11,9 +11,11 @@ #define LLDB_lldb_windows_h_ #define NTDDI_VERSION NTDDI_VISTA +#undef _WIN32_WINNT // undef a previous definition to avoid warning #define _WIN32_WINNT _WIN32_WINNT_VISTA #define WIN32_LEAN_AND_MEAN #define NOGDI +#undef NOMINMAX // undef a previous definition to avoid warning #define NOMINMAX #include <windows.h> #undef GetUserName Index: cmake/modules/LLDBConfig.cmake =================================================================== --- cmake/modules/LLDBConfig.cmake +++ cmake/modules/LLDBConfig.cmake @@ -242,8 +242,10 @@ endif() # Use the Unicode (UTF-16) APIs by default on Win32 -if (CMAKE_SYSTEM_NAME MATCHES "Windows") - add_definitions( /D _UNICODE /D UNICODE ) +if (MSVC) + add_definitions( /D _UNICODE /D UNICODE ) +elseif (MINGW) + add_definitions( -D_UNICODE -DUNICODE ) endif() set(LLDB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) Index: cmake/modules/AddLLDB.cmake =================================================================== --- cmake/modules/AddLLDB.cmake +++ cmake/modules/AddLLDB.cmake @@ -49,7 +49,7 @@ endif() #PIC not needed on Win - if (NOT MSVC) + if (NOT WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") endif() Index: cmake/LLDBDependencies.cmake =================================================================== --- cmake/LLDBDependencies.cmake +++ cmake/LLDBDependencies.cmake @@ -91,8 +91,8 @@ if ( CMAKE_SYSTEM_NAME MATCHES "Windows" ) list(APPEND LLDB_USED_LIBS lldbPluginProcessWindowsCommon - Ws2_32 - Rpcrt4 + ws2_32 + rpcrt4 ) endif ()
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits