From 2d4b05bbf81680c00256a0cad0282667c56ebb95 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sat, 26 May 2018 08:09:26 -0400 Subject: [PATCH 1/4] Revert "Fix build error when compiling with mingw" This reverts commit 00178f8c8e864d7efa7670720d25d4f3759da105. --- gobject/gclosure.c | 2 +- gobject/gtype.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/gobject/gclosure.c b/gobject/gclosure.c index 31aa50fb1..b42af60bb 100644 --- a/gobject/gclosure.c +++ b/gobject/gclosure.c @@ -22,6 +22,7 @@ #include "config.h" +#include "../glib/valgrind.h" #include #include @@ -34,7 +35,6 @@ #include "gvaluetypes.h" #include "gtype-private.h" -#include "../glib/valgrind.h" /** * SECTION:gclosure diff --git a/gobject/gtype.c b/gobject/gtype.c index faf8e38f7..275a8b60b 100644 --- a/gobject/gtype.c +++ b/gobject/gtype.c @@ -21,6 +21,7 @@ #include "config.h" +#include "../glib/valgrind.h" #include #include "gtype.h" @@ -37,8 +38,6 @@ #include #endif -#include "../glib/valgrind.h" - #ifdef G_ENABLE_DEBUG #define IF_DEBUG(debug_type) if (_g_type_debug_flags & G_TYPE_DEBUG_ ## debug_type) #endif From f9dc091e379494fcad5af532dc7db62b79294416 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Fri, 25 May 2018 09:22:43 -0400 Subject: [PATCH 2/4] Revert "glib/valgrind.h: Disable inline ASM on MSVC x64 builds" Better not modify copy/paster files otherwise this will regress again later. It's better to not include valgrind.h at all when using MSVC. This reverts commit bbcce75d4e09f74894684b18222170eef97e8b2c. --- glib/valgrind.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/glib/valgrind.h b/glib/valgrind.h index cddc38deb..5aed0dfca 100644 --- a/glib/valgrind.h +++ b/glib/valgrind.h @@ -171,16 +171,6 @@ # endif #endif -/* XXX: Unfortunately x64 Visual C++ does not suport inline asms, - * so disable the use of valgrind's inline asm's for x64 Visual C++ - * builds, so that x64 Visual C++ builds of GLib can be maintained - */ -#if defined (PLAT_amd64_win64) && defined (_MSC_VER) -# if !defined(NVALGRIND) -# define NVALGRIND 1 -# endif -#endif - /* ------------------------------------------------------------------ */ /* ARCHITECTURE SPECIFICS for SPECIAL INSTRUCTIONS. There is nothing */ From 707106c7a5d13d7d81f8870146411f4d75bcf84b Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Fri, 25 May 2018 21:30:57 -0400 Subject: [PATCH 3/4] Fix Windows build errors in valgrind.h valgrind.h is a verbatim copy taken from Valgrind project. Previously that file had local changes that got dropped by last update. To avoid regressing again, do not edit valgrind.h anymore and instead add a gvalgrind.h wrapper that gets included instead. This fix 2 errors: - uintptr_t is not defined when including valgrind.h on mingw. - MSVC compiler is not supported on amd64-Win64 platform. --- glib/Makefile.am | 1 + glib/gslice.c | 4 +++- glib/gvalgrind.h | 32 ++++++++++++++++++++++++++++++++ gobject/gclosure.c | 6 +++++- gobject/gtype.c | 6 +++++- 5 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 glib/gvalgrind.h diff --git a/glib/Makefile.am b/glib/Makefile.am index 8da549c7f..97861b8d7 100644 --- a/glib/Makefile.am +++ b/glib/Makefile.am @@ -188,6 +188,7 @@ libglib_2_0_la_SOURCES = \ gurifuncs.c \ gutils.c \ guuid.c \ + gvalgrind.h \ gvariant.h \ gvariant.c \ gvariant-core.h \ diff --git a/glib/gslice.c b/glib/gslice.c index 034d888e1..48e4c5a33 100644 --- a/glib/gslice.c +++ b/glib/gslice.c @@ -52,7 +52,7 @@ #include "glib_trace.h" #include "gprintf.h" -#include "valgrind.h" +#include "gvalgrind.h" /** * SECTION:memory_slices @@ -389,8 +389,10 @@ slice_config_init (SliceConfig *config) * This way it's possible to force gslice to be enabled under * valgrind just by setting G_SLICE to the empty string. */ +#ifdef ENABLE_VALGRIND if (RUNNING_ON_VALGRIND) config->always_malloc = TRUE; +#endif } } diff --git a/glib/gvalgrind.h b/glib/gvalgrind.h new file mode 100644 index 000000000..053c75a98 --- /dev/null +++ b/glib/gvalgrind.h @@ -0,0 +1,32 @@ +/* + * Copyright 2018 Collabora ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Author: Xavier Claessens + */ + +#ifndef __G_VALGRIND_H__ +#define __G_VALGRIND_H__ + +#if HAVE_STDINT_H +#include +#endif + +#ifndef _MSC_VER +#include "valgrind.h" +#define ENABLE_VALGRIND 1 +#endif + +#endif /* __G_VALGRIND_H__ */ diff --git a/gobject/gclosure.c b/gobject/gclosure.c index b42af60bb..188c74ad8 100644 --- a/gobject/gclosure.c +++ b/gobject/gclosure.c @@ -22,7 +22,7 @@ #include "config.h" -#include "../glib/valgrind.h" +#include "../glib/gvalgrind.h" #include #include @@ -200,6 +200,7 @@ g_closure_new_simple (guint sizeof_closure, private_size = sizeof (GRealClosure) - sizeof (GClosure); +#ifdef ENABLE_VALGRIND /* See comments in gtype.c about what's going on here... */ if (RUNNING_ON_VALGRIND) { @@ -213,6 +214,7 @@ g_closure_new_simple (guint sizeof_closure, VALGRIND_MALLOCLIKE_BLOCK (allocated + sizeof (gpointer), private_size - sizeof (gpointer), 0, TRUE); } else +#endif allocated = g_malloc0 (private_size + sizeof_closure); closure = (GClosure *) (allocated + private_size); @@ -613,6 +615,7 @@ g_closure_unref (GClosure *closure) closure_invoke_notifiers (closure, FNOTIFY); g_free (closure->notifiers); +#ifdef ENABLE_VALGRIND /* See comments in gtype.c about what's going on here... */ if (RUNNING_ON_VALGRIND) { @@ -627,6 +630,7 @@ g_closure_unref (GClosure *closure) VALGRIND_FREELIKE_BLOCK (closure, 0); } else +#endif g_free (G_REAL_CLOSURE (closure)); } } diff --git a/gobject/gtype.c b/gobject/gtype.c index 275a8b60b..84f3c9a1c 100644 --- a/gobject/gtype.c +++ b/gobject/gtype.c @@ -21,7 +21,7 @@ #include "config.h" -#include "../glib/valgrind.h" +#include "../glib/gvalgrind.h" #include #include "gtype.h" @@ -1831,6 +1831,7 @@ g_type_create_instance (GType type) private_size = node->data->instance.private_size; ivar_size = node->data->instance.instance_size; +#ifdef ENABLE_VALGRIND if (private_size && RUNNING_ON_VALGRIND) { private_size += ALIGN_STRUCT (1); @@ -1845,6 +1846,7 @@ g_type_create_instance (GType type) VALGRIND_MALLOCLIKE_BLOCK (allocated + ALIGN_STRUCT (1), private_size - ALIGN_STRUCT (1), 0, TRUE); } else +#endif allocated = g_slice_alloc0 (private_size + ivar_size); instance = (GTypeInstance *) (allocated + private_size); @@ -1923,6 +1925,7 @@ g_type_free_instance (GTypeInstance *instance) memset (allocated, 0xaa, ivar_size + private_size); #endif +#ifdef ENABLE_VALGRIND /* See comment in g_type_create_instance() about what's going on here. * We're basically unwinding what we put into motion there. */ @@ -1940,6 +1943,7 @@ g_type_free_instance (GTypeInstance *instance) VALGRIND_FREELIKE_BLOCK (instance, 0); } else +#endif g_slice_free1 (private_size + ivar_size, allocated); #ifdef G_ENABLE_DEBUG From 3145d88f4b961df1e971e7068da0bacbbd60299a Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sun, 20 May 2018 15:17:48 -0400 Subject: [PATCH 4/4] Add mingw64 cross build CI Fixes #1387. --- .gitlab-ci.yml | 14 +++++++++++++- .gitlab-ci/Dockerfile | 7 +++++++ .gitlab-ci/cross_file_mingw64.txt | 17 +++++++++++++++++ docs/reference/glib/Makefile.am | 4 +++- docs/reference/glib/meson.build | 1 + 5 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 .gitlab-ci/cross_file_mingw64.txt diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7df974b3b..cfabdcd62 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: registry.gitlab.gnome.org/gnome/glib/master:v2 +image: registry.gitlab.gnome.org/gnome/glib/master:v3 stages: - build @@ -44,6 +44,18 @@ fedora-meson-android_ndk_r16_api21_arm64: paths: - "${CI_PROJECT_DIR}/_build/meson-logs" +fedora-meson-mingw64: + stage: build + except: + - tags + script: + # FIXME: Add --werror + - meson --cross-file=/opt/cross_file_mingw64.txt --buildtype debug _build + - ninja -C _build + artifacts: + paths: + - "${CI_PROJECT_DIR}/_build/meson-logs" + msys2-mingw32: stage: build tags: diff --git a/.gitlab-ci/Dockerfile b/.gitlab-ci/Dockerfile index 713cf095a..56585d8a1 100644 --- a/.gitlab-ci/Dockerfile +++ b/.gitlab-ci/Dockerfile @@ -28,6 +28,11 @@ RUN dnf -y install \ wget \ unzip \ make \ + mingw64-gcc \ + mingw64-gcc-c++ \ + mingw64-gettext \ + mingw64-zlib \ + mingw64-libffi \ && dnf clean all RUN pip3 install meson @@ -35,6 +40,8 @@ RUN pip3 install meson COPY setup-android-ndk.sh . RUN ./setup-android-ndk.sh +COPY cross_file_mingw64.txt /opt + ARG HOST_USER_ID=5555 ENV HOST_USER_ID ${HOST_USER_ID} RUN useradd -u $HOST_USER_ID -ms /bin/bash user diff --git a/.gitlab-ci/cross_file_mingw64.txt b/.gitlab-ci/cross_file_mingw64.txt new file mode 100644 index 000000000..1897b686a --- /dev/null +++ b/.gitlab-ci/cross_file_mingw64.txt @@ -0,0 +1,17 @@ +[host_machine] +system = 'windows' +cpu_family = 'x86_64' +cpu = 'x86_64' +endian = 'little' + +[properties] +c_args = [] +c_link_args = [] + +[binaries] +c = 'x86_64-w64-mingw32-gcc' +cpp = 'x86_64-w64-mingw32-g++' +ar = 'x86_64-w64-mingw32-ar' +strip = 'x86_64-w64-mingw32-strip' +pkgconfig = 'x86_64-w64-mingw32-pkg-config' +windres = 'x86_64-w64-mingw32-windres' diff --git a/docs/reference/glib/Makefile.am b/docs/reference/glib/Makefile.am index 44536cf21..b485a9135 100644 --- a/docs/reference/glib/Makefile.am +++ b/docs/reference/glib/Makefile.am @@ -61,7 +61,9 @@ IGNORE_HFILES = \ gtranslit-data.h \ glib-init.h \ gconstructor.h \ - valgrind.h + valgrind.h \ + gvalgrind.h \ + $(NULL) # Images to copy into HTML directory HTML_IMAGES = \ diff --git a/docs/reference/glib/meson.build b/docs/reference/glib/meson.build index f0f915e96..319c2679f 100644 --- a/docs/reference/glib/meson.build +++ b/docs/reference/glib/meson.build @@ -34,6 +34,7 @@ if get_option('gtk_doc') 'glib-init.h', 'gconstructor.h', 'valgrind.h', + 'gvalgrind.h', ] ignore_decorators = [