From b2bc2e5c9570843b7fa86be267d0d42c14e80bcb Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Tue, 15 Jan 2019 17:29:05 +0100 Subject: [PATCH] [sdks,mac] Remove dependency on MXE in favor of MinGW It turns out that homebrew now has a package for the MinGW gcc-based windows cross compiler which is awesome as it allows us to skip building MXE and use the latest version of the GCC suite pre-packaged for Mac. This commit removes almost all traces of MXE (except for `mxe.mk` itself, because I don't know if any bot or external tool, whatever, use targets in it) and adds the following brew packages to SDK bot provisioning as well as to the `provision-mxe` target of Mono SDKs: * mingw-w64 * xamarin/xamarin-android-windeps/mingw-zlib The latter package builds a Windows version of zlib using MinGW and it comes from Xamarin's own homebrew tap at https://github.com/xamarin/homebrew-xamarin-android-windeps/blob/mono/mono@f4cc90845ff1953800d8d71035566a12d9b7aa24/mingw-zlib.rb Additionally, this commit adds a new `configure` flag: `--with-static-zlib=PATH` which allows one to specify the static zlib archive to use when linking Mono. The static archive supersedes the otherwise indicated or detected zlib. This is the recommended mode of operation for MinGW builds as it avoids problems with `zlib.dll` versions on the target machine. Commit migrated from https://github.com/mono/mono/commit/acbeffd07339aea56f3157d2dd88d27e7f24d538 --- src/mono/configure.ac | 7 +++++++ src/mono/mono/metadata/Makefile.am | 4 ++++ src/mono/mono/metadata/icall.c | 8 ++++++++ src/mono/mono/profiler/Makefile.am | 4 ++++ 4 files changed, 23 insertions(+) diff --git a/src/mono/configure.ac b/src/mono/configure.ac index 25330ed..fb86bda 100644 --- a/src/mono/configure.ac +++ b/src/mono/configure.ac @@ -640,6 +640,13 @@ if test x$have_zlib = xyes; then ]) fi +AC_ARG_WITH(static-zlib, [ --with-static-zlib=PATH use the specified static zlib instead of -lz],[STATIC_ZLIB_PATH=$with_static_zlib],[STATIC_ZLIB_PATH=]) +if test "x$STATIC_ZLIB_PATH" != "x"; then + have_static_zlib=yes + AC_SUBST(STATIC_ZLIB_PATH) +fi + +AM_CONDITIONAL(HAVE_STATIC_ZLIB, test x$have_static_zlib = xyes) AM_CONDITIONAL(HAVE_ZLIB, test x$have_zlib = xyes) AC_DEFINE(HAVE_ZLIB,1,[Have system zlib]) diff --git a/src/mono/mono/metadata/Makefile.am b/src/mono/mono/metadata/Makefile.am index 540c4fb..add7f83 100644 --- a/src/mono/mono/metadata/Makefile.am +++ b/src/mono/mono/metadata/Makefile.am @@ -158,9 +158,13 @@ libmonoruntime_config_la_CPPFLAGS = $(AM_CPPFLAGS) -DMONO_BINDIR=\"$(bindir)/\" # libmonoruntime_support_la_SOURCES = $(support_sources) libmonoruntime_support_la_CFLAGS = $(filter-out @CXX_REMOVE_CFLAGS@, @CFLAGS@) +if HAVE_STATIC_ZLIB +libmonoruntime_support_la_LDFLAGS = $(STATIC_ZLIB_PATH) +else if HAVE_ZLIB libmonoruntime_support_la_LDFLAGS = -lz endif +endif # # This library contains the icall tables if the runtime was configured with --disable-icall-tables diff --git a/src/mono/mono/metadata/icall.c b/src/mono/mono/metadata/icall.c index e1dd07f..5924976 100644 --- a/src/mono/mono/metadata/icall.c +++ b/src/mono/mono/metadata/icall.c @@ -15,6 +15,13 @@ */ #include + +#if defined(TARGET_WIN32) || defined(HOST_WIN32) +/* Needed for _ecvt_s */ +#define MINGW_HAS_SECURE_API 1 +#include +#endif + #include #include #include @@ -31,6 +38,7 @@ #if defined (HAVE_WCHAR_H) #include #endif + #include "mono/metadata/icall-internals.h" #include "mono/utils/mono-membar.h" #include diff --git a/src/mono/mono/profiler/Makefile.am b/src/mono/mono/profiler/Makefile.am index 16b3dae..434ddc8 100644 --- a/src/mono/mono/profiler/Makefile.am +++ b/src/mono/mono/profiler/Makefile.am @@ -97,12 +97,16 @@ endif endif endif +if HAVE_STATIC_ZLIB +zlib_dep = $(STATIC_ZLIB_PATH) +else if HAVE_ZLIB # The log profiler uses zlib for output compression when available. zlib_dep = -lz else zlib_dep = endif +endif # We build a separate, static version of each profiler for use on targets # which do not support dynamic linking (e.g. iOS). We still want to build -- 2.7.4