Author: abidh Date: Thu Dec 15 09:00:41 2016 New Revision: 289821 URL: http://llvm.org/viewvc/llvm-project?rev=289821&view=rev Log: Fix build for mingw.
Summary: 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. Reviewers: zturner, labath, abidh Subscribers: ki.stfu, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D27759 Modified: lldb/trunk/cmake/LLDBDependencies.cmake lldb/trunk/cmake/modules/AddLLDB.cmake lldb/trunk/cmake/modules/LLDBConfig.cmake lldb/trunk/include/lldb/Host/windows/windows.h lldb/trunk/source/API/SystemInitializerFull.cpp lldb/trunk/source/Core/Mangled.cpp lldb/trunk/source/Host/common/File.cpp lldb/trunk/source/Host/windows/Host.cpp lldb/trunk/source/Host/windows/HostProcessWindows.cpp lldb/trunk/source/Host/windows/ProcessRunLock.cpp lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp lldb/trunk/source/Plugins/Process/Windows/Common/ExceptionRecord.h lldb/trunk/source/Target/ProcessLaunchInfo.cpp lldb/trunk/tools/driver/Driver.cpp lldb/trunk/tools/lldb-mi/MICmnStreamStdin.cpp lldb/trunk/tools/lldb-mi/MIUtilDebug.cpp Modified: lldb/trunk/cmake/LLDBDependencies.cmake URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/LLDBDependencies.cmake?rev=289821&r1=289820&r2=289821&view=diff ============================================================================== --- lldb/trunk/cmake/LLDBDependencies.cmake (original) +++ lldb/trunk/cmake/LLDBDependencies.cmake Thu Dec 15 09:00:41 2016 @@ -91,8 +91,8 @@ set( LLDB_USED_LIBS if ( CMAKE_SYSTEM_NAME MATCHES "Windows" ) list(APPEND LLDB_USED_LIBS lldbPluginProcessWindowsCommon - Ws2_32 - Rpcrt4 + ws2_32 + rpcrt4 ) endif () Modified: lldb/trunk/cmake/modules/AddLLDB.cmake URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/AddLLDB.cmake?rev=289821&r1=289820&r2=289821&view=diff ============================================================================== --- lldb/trunk/cmake/modules/AddLLDB.cmake (original) +++ lldb/trunk/cmake/modules/AddLLDB.cmake Thu Dec 15 09:00:41 2016 @@ -49,7 +49,7 @@ macro(add_lldb_library name) endif() #PIC not needed on Win - if (NOT MSVC) + if (NOT WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") endif() Modified: lldb/trunk/cmake/modules/LLDBConfig.cmake URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBConfig.cmake?rev=289821&r1=289820&r2=289821&view=diff ============================================================================== --- lldb/trunk/cmake/modules/LLDBConfig.cmake (original) +++ lldb/trunk/cmake/modules/LLDBConfig.cmake Thu Dec 15 09:00:41 2016 @@ -243,7 +243,7 @@ endif() # Use the Unicode (UTF-16) APIs by default on Win32 if (CMAKE_SYSTEM_NAME MATCHES "Windows") - add_definitions( /D _UNICODE /D UNICODE ) + add_definitions( -D_UNICODE -DUNICODE ) endif() set(LLDB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) Modified: lldb/trunk/include/lldb/Host/windows/windows.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/windows/windows.h?rev=289821&r1=289820&r2=289821&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/windows/windows.h (original) +++ lldb/trunk/include/lldb/Host/windows/windows.h Thu Dec 15 09:00:41 2016 @@ -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 Modified: lldb/trunk/source/API/SystemInitializerFull.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SystemInitializerFull.cpp?rev=289821&r1=289820&r2=289821&view=diff ============================================================================== --- lldb/trunk/source/API/SystemInitializerFull.cpp (original) +++ lldb/trunk/source/API/SystemInitializerFull.cpp Thu Dec 15 09:00:41 2016 @@ -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 @@ void SystemInitializerFull::Initialize() ObjCPlusPlusLanguage::Initialize(); OCamlLanguage::Initialize(); -#if defined(_MSC_VER) +#if defined(_WIN32) ProcessWindows::Initialize(); #endif #if defined(__FreeBSD__) Modified: lldb/trunk/source/Core/Mangled.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Mangled.cpp?rev=289821&r1=289820&r2=289821&view=diff ============================================================================== --- lldb/trunk/source/Core/Mangled.cpp (original) +++ lldb/trunk/source/Core/Mangled.cpp Thu Dec 15 09:00:41 2016 @@ -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 Modified: lldb/trunk/source/Host/common/File.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/File.cpp?rev=289821&r1=289820&r2=289821&view=diff ============================================================================== --- lldb/trunk/source/Host/common/File.cpp (original) +++ lldb/trunk/source/Host/common/File.cpp Thu Dec 15 09:00:41 2016 @@ -222,7 +222,7 @@ Error File::Open(const char *path, uint3 } do { -#ifdef _WIN32 +#ifdef _MSC_VER std::wstring wpath; if (!llvm::ConvertUTF8toWide(path, wpath)) { m_descriptor = -1; Modified: lldb/trunk/source/Host/windows/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Host.cpp?rev=289821&r1=289820&r2=289821&view=diff ============================================================================== --- lldb/trunk/source/Host/windows/Host.cpp (original) +++ lldb/trunk/source/Host/windows/Host.cpp Thu Dec 15 09:00:41 2016 @@ -29,7 +29,7 @@ #include "llvm/Support/ConvertUTF.h" // Windows includes -#include <TlHelp32.h> +#include <tlhelp32.h> using namespace lldb; using namespace lldb_private; Modified: lldb/trunk/source/Host/windows/HostProcessWindows.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/HostProcessWindows.cpp?rev=289821&r1=289820&r2=289821&view=diff ============================================================================== --- lldb/trunk/source/Host/windows/HostProcessWindows.cpp (original) +++ lldb/trunk/source/Host/windows/HostProcessWindows.cpp Thu Dec 15 09:00:41 2016 @@ -16,7 +16,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Support/ConvertUTF.h" -#include <Psapi.h> +#include <psapi.h> using namespace lldb_private; Modified: lldb/trunk/source/Host/windows/ProcessRunLock.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/ProcessRunLock.cpp?rev=289821&r1=289820&r2=289821&view=diff ============================================================================== --- lldb/trunk/source/Host/windows/ProcessRunLock.cpp (original) +++ lldb/trunk/source/Host/windows/ProcessRunLock.cpp Thu Dec 15 09:00:41 2016 @@ -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); } Modified: lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp?rev=289821&r1=289820&r2=289821&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp Thu Dec 15 09:00:41 2016 @@ -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 { Modified: lldb/trunk/source/Plugins/Process/Windows/Common/ExceptionRecord.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/ExceptionRecord.h?rev=289821&r1=289820&r2=289821&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Windows/Common/ExceptionRecord.h (original) +++ lldb/trunk/source/Plugins/Process/Windows/Common/ExceptionRecord.h Thu Dec 15 09:00:41 2016 @@ -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> Modified: lldb/trunk/source/Target/ProcessLaunchInfo.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ProcessLaunchInfo.cpp?rev=289821&r1=289820&r2=289821&view=diff ============================================================================== --- lldb/trunk/source/Target/ProcessLaunchInfo.cpp (original) +++ lldb/trunk/source/Target/ProcessLaunchInfo.cpp Thu Dec 15 09:00:41 2016 @@ -294,7 +294,7 @@ void ProcessLaunchInfo::FinalizeFileActi __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. Modified: lldb/trunk/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=289821&r1=289820&r2=289821&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Thu Dec 15 09:00:41 2016 @@ -1208,13 +1208,13 @@ void sigcont_handler(int signo) { } 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); Modified: lldb/trunk/tools/lldb-mi/MICmnStreamStdin.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnStreamStdin.cpp?rev=289821&r1=289820&r2=289821&view=diff ============================================================================== --- lldb/trunk/tools/lldb-mi/MICmnStreamStdin.cpp (original) +++ lldb/trunk/tools/lldb-mi/MICmnStreamStdin.cpp Thu Dec 15 09:00:41 2016 @@ -9,7 +9,7 @@ // Third Party Headers #ifdef _MSC_VER -#include <Windows.h> +#include <windows.h> #endif #include <string.h> // For std::strerror() Modified: lldb/trunk/tools/lldb-mi/MIUtilDebug.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MIUtilDebug.cpp?rev=289821&r1=289820&r2=289821&view=diff ============================================================================== --- lldb/trunk/tools/lldb-mi/MIUtilDebug.cpp (original) +++ lldb/trunk/tools/lldb-mi/MIUtilDebug.cpp Thu Dec 15 09:00:41 2016 @@ -9,7 +9,7 @@ // Third party headers: #ifdef _WIN32 -#include <Windows.h> +#include <windows.h> #endif // In-house headers: _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits