Skip to content

Commit

Permalink
Fix build for mingw.
Browse files Browse the repository at this point in the history
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

llvm-svn: 289821
  • Loading branch information
abidh committed Dec 15, 2016
1 parent 91b5cf8 commit f6ee79c
Show file tree
Hide file tree
Showing 16 changed files with 20 additions and 28 deletions.
4 changes: 2 additions & 2 deletions lldb/cmake/LLDBDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()

Expand Down
2 changes: 1 addition & 1 deletion lldb/cmake/modules/AddLLDB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion lldb/cmake/modules/LLDBConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/Host/windows/windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/API/SystemInitializerFull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -332,7 +332,7 @@ void SystemInitializerFull::Initialize() {
ObjCPlusPlusLanguage::Initialize();
OCamlLanguage::Initialize();

#if defined(_MSC_VER)
#if defined(_WIN32)
ProcessWindows::Initialize();
#endif
#if defined(__FreeBSD__)
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Core/Mangled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Host/common/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ Error File::Open(const char *path, uint32_t options, uint32_t permissions) {
}

do {
#ifdef _WIN32
#ifdef _MSC_VER
std::wstring wpath;
if (!llvm::ConvertUTF8toWide(path, wpath)) {
m_descriptor = -1;
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Host/windows/Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "llvm/Support/ConvertUTF.h"

// Windows includes
#include <TlHelp32.h>
#include <tlhelp32.h>

using namespace lldb;
using namespace lldb_private;
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Host/windows/HostProcessWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/ConvertUTF.h"

#include <Psapi.h>
#include <psapi.h>

using namespace lldb_private;

Expand Down
10 changes: 0 additions & 10 deletions lldb/source/Host/windows/ProcessRunLock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Target/ProcessLaunchInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ void ProcessLaunchInfo::FinalizeFileActions(Target *target,
__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.
Expand Down
4 changes: 2 additions & 2 deletions lldb/tools/driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lldb/tools/lldb-mi/MICmnStreamStdin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

// Third Party Headers
#ifdef _MSC_VER
#include <Windows.h>
#include <windows.h>
#endif
#include <string.h> // For std::strerror()

Expand Down
2 changes: 1 addition & 1 deletion lldb/tools/lldb-mi/MIUtilDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

// Third party headers:
#ifdef _WIN32
#include <Windows.h>
#include <windows.h>
#endif

// In-house headers:
Expand Down

0 comments on commit f6ee79c

Please sign in to comment.