conan-recipes/recipes/breakpad/all/patches/0005-Fix-building-minidump-processor-for-MinGW.patch
2020-10-19 07:52:36 +10:00

184 lines
5.3 KiB
Diff

From e3a6eefeef6d7873fee61a37ef38f34caf5c3d1c Mon Sep 17 00:00:00 2001
From: Jon Turney <jon.turney@dronecode.org.uk>
Date: Fri, 11 Jul 2014 23:37:02 +0100
Subject: [PATCH 05/19] Fix building minidump processor for MinGW
- Link minidump_stackwalk, minidump_dump, microdump_stackwalk with
PTHREAD_LIBS as pthread_cancel is used
- Link minidump_stackwalk, microdump_stackwalk, binarystream_unittest with
ws2_32 as ntoh functions are used
- _s function variants should only be used if _MSC_VER, use _r variants with
MinGW (and define _POSIX_C_SOURCE to ensure they are prototyped)
- Don't try to build upload tools, dump_syms_dwarf for MinGW
(Part of https://breakpad.appspot.com/548002 was commited as svn r1399 to
fix breakpad client compilation for MinGW
This is mainly the configure.ac and Makefile.am changes left over from
https://breakpad.appspot.com/548002/ with a bit of updating, to fix building
of the minidump processor library and tools for MinGW)
v2:
Use _POSIX_C_SOURCE not _POSIX to enable *_r() prototypes in headers
The headers seem to have changed so localtime_r() prototype is now guarded
by _POSIX_C_SOURCE
This seems right anyhow as _POSIX_C_SOURCE is what SUS defines, whereas I
think _POSIX is some left-over Interix thing?
v3:
Drop _snprintf fix, now dealt with centrally and correctly since 48673cdb
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
---
Makefile.am | 20 +++++++++++++++++---
configure.ac | 6 ++++++
src/processor/logging.cc | 2 +-
src/processor/minidump.cc | 2 +-
4 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 0f6388f1..f3b1fc6c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -56,6 +56,11 @@ if WINDOWS_HOST
AM_CPPFLAGS += -DNO_STABS_SUPPORT
endif
+if MINGW_HOST
+SOCKET_LIBS = -lws2_32
+AM_CPPFLAGS += -D_POSIX_C_SOURCE
+endif
+
# Specify include paths for ac macros
ACLOCAL_AMFLAGS = -I m4
@@ -351,11 +356,13 @@ bin_PROGRAMS += \
src/processor/minidump_stackwalk
endif !DISABLE_PROCESSOR
+if !MINGW_HOST
if !DISABLE_TOOLS
bin_PROGRAMS += \
src/tools/linux/symupload/minidump_upload \
src/tools/linux/symupload/sym_upload
endif
+endif
if LINUX_HOST
EXTRA_PROGRAMS += \
@@ -376,11 +383,13 @@ endif
endif LINUX_HOST
if WINDOWS_HOST
+if !MINGW_HOST
if !DISABLE_TOOLS
bin_PROGRAMS += \
src/tools/windows/dump_syms_dwarf/dump_syms
endif
endif
+endif
## Tests
if !DISABLE_PROCESSOR
@@ -794,6 +803,7 @@ src_tools_linux_md2core_minidump_2_core_unittest_LDADD = \
endif LINUX_HOST
if WINDOWS_HOST
+if !MINGW_HOST
if !DISABLE_TOOLS
src_tools_windows_dump_syms_dwarf_dump_syms_SOURCES = \
src/common/dwarf_cfi_to_module.cc \
@@ -811,6 +821,7 @@ src_tools_windows_dump_syms_dwarf_dump_syms_SOURCES = \
src/tools/windows/dump_syms_dwarf/dump_syms.cc
endif
endif
+endif
if !DISABLE_PROCESSOR
src_processor_address_map_unittest_SOURCES = \
@@ -1250,7 +1261,8 @@ src_processor_minidump_dump_LDADD = \
src/processor/logging.o \
src/processor/minidump.o \
src/processor/pathname_stripper.o \
- src/processor/proc_maps_linux.o
+ src/processor/proc_maps_linux.o \
+ $(PTHREAD_CFLAGS) $(PTHREAD_LIBS)
src_processor_microdump_stackwalk_SOURCES = \
src/processor/microdump_stackwalk.cc
@@ -1285,7 +1297,8 @@ src_processor_microdump_stackwalk_LDADD = \
src/processor/stackwalker_sparc.o \
src/processor/stackwalker_x86.o \
src/processor/tokenize.o \
- src/third_party/libdisasm/libdisasm.a
+ src/third_party/libdisasm/libdisasm.a \
+ $(PTHREAD_CFLAGS) $(PTHREAD_LIBS) $(SOCKET_LIBS)
src_processor_minidump_stackwalk_SOURCES = \
src/processor/minidump_stackwalk.cc
@@ -1325,7 +1338,8 @@ src_processor_minidump_stackwalk_LDADD = \
src/processor/stackwalker_x86.o \
src/processor/symbolic_constants_win.o \
src/processor/tokenize.o \
- src/third_party/libdisasm/libdisasm.a
+ src/third_party/libdisasm/libdisasm.a \
+ $(PTHREAD_CFLAGS) $(PTHREAD_LIBS) $(SOCKET_LIBS)
endif !DISABLE_PROCESSOR
diff --git a/configure.ac b/configure.ac
index 63b32bdd..e50d2c22 100644
--- a/configure.ac
+++ b/configure.ac
@@ -113,10 +113,16 @@ case $host in
*-*-cygwin* )
WINDOWS_HOST=true
;;
+ *-*-mingw* )
+ WINDOWS_HOST=true
+ MINGW_HOST=true
+ ;;
esac
AM_CONDITIONAL(LINUX_HOST, test x$LINUX_HOST = xtrue)
+# WINDOWS_HOST means MINGW or CYGWIN
AM_CONDITIONAL(WINDOWS_HOST, test x$WINDOWS_HOST = xtrue)
+AM_CONDITIONAL(MINGW_HOST, test x$MINGW_HOST = xtrue)
# Only use Android support headers when compiling for Android
case $host in
diff --git a/src/processor/logging.cc b/src/processor/logging.cc
index d59175a7..96772eb1 100644
--- a/src/processor/logging.cc
+++ b/src/processor/logging.cc
@@ -53,7 +53,7 @@ LogStream::LogStream(std::ostream &stream, Severity severity,
time_t clock;
time(&clock);
struct tm tm_struct;
-#ifdef _WIN32
+#ifdef _MSC_VER
localtime_s(&tm_struct, &clock);
#else
localtime_r(&clock, &tm_struct);
diff --git a/src/processor/minidump.cc b/src/processor/minidump.cc
index 78faf77a..f6b31db5 100644
--- a/src/processor/minidump.cc
+++ b/src/processor/minidump.cc
@@ -387,7 +387,7 @@ void PrintValueOrInvalid(bool valid,
// Converts a time_t to a string showing the time in UTC.
string TimeTToUTCString(time_t tt) {
struct tm timestruct;
-#ifdef _WIN32
+#ifdef _MSC_VER
gmtime_s(&timestruct, &tt);
#else
gmtime_r(&tt, &timestruct);
--
2.28.0