diff options
author | Ting-Wei Lan | 2020-08-26 23:15:33 +0800 |
---|---|---|
committer | Ting-Wei Lan | 2020-08-26 23:15:33 +0800 |
commit | d10df2b071235f17a254c9e07f1d164e6ef790f6 (patch) | |
tree | cf1b41d002cfc5ce412abfc15d7a31dbf1bcdc14 | |
parent | 49ff59261634e7998e0cd18ed8672d47461b67ed (diff) | |
download | aur-d10df2b071235f17a254c9e07f1d164e6ef790f6.tar.gz |
mingw-w64-gtk2: Fix GCC 10 build
Fix multiple definition of `gdk_threads_mutex' and undefined reference to
'IID_IUnknown' when building with GCC 10.
https://gitlab.gnome.org/GNOME/gtk/-/issues/2958
https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/2305
https://gitlab.gnome.org/GNOME/gtk/-/issues/3029
https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/2481
-rw-r--r-- | .SRCINFO | 8 | ||||
-rw-r--r-- | PKGBUILD | 27 | ||||
-rw-r--r-- | gtk2-fix-gcc-10-build.patch | 72 | ||||
-rw-r--r-- | gtk2-fix-out-of-source-build.patch | 98 |
4 files changed, 198 insertions, 7 deletions
@@ -1,9 +1,7 @@ -# Generated by mksrcinfo v8 -# Wed Jan 10 12:59:54 UTC 2018 pkgbase = mingw-w64-gtk2 pkgdesc = GObject-based multi-platform GUI toolkit (legacy) (mingw-w64) pkgver = 2.24.32 - pkgrel = 1 + pkgrel = 2 url = http://www.gtk.org arch = any license = LGPL @@ -22,7 +20,11 @@ pkgbase = mingw-w64-gtk2 options = !buildflags options = staticlibs source = https://download.gnome.org/sources/gtk+/2.24/gtk+-2.24.32.tar.xz + source = gtk2-fix-gcc-10-build.patch + source = gtk2-fix-out-of-source-build.patch sha256sums = b6c8a93ddda5eabe3bfee1eb39636c9a03d2a56c7b62828b359bf197943c582e + sha256sums = a3d347337b0aaa2b170b836c20070f758698949d0511b9a92528ab4926bdcfe6 + sha256sums = e88bb004767c95cd567f225995891f054218e2c806844a3e5c12b70ac3ea231e pkgname = mingw-w64-gtk2 @@ -1,6 +1,6 @@ pkgname=mingw-w64-gtk2 pkgver=2.24.32 -pkgrel=1 +pkgrel=2 pkgdesc="GObject-based multi-platform GUI toolkit (legacy) (mingw-w64)" arch=('any') url="http://www.gtk.org" @@ -19,16 +19,35 @@ depends=( 'mingw-w64-cairo>=1.6' 'mingw-w64-gdk-pixbuf2>=2.21.0') options=('!strip' '!buildflags' 'staticlibs') -source=("https://download.gnome.org/sources/gtk+/${pkgver%.*}/gtk+-${pkgver}.tar.xz") -sha256sums=("b6c8a93ddda5eabe3bfee1eb39636c9a03d2a56c7b62828b359bf197943c582e") +source=( + "https://download.gnome.org/sources/gtk+/${pkgver%.*}/gtk+-${pkgver}.tar.xz" + 'gtk2-fix-gcc-10-build.patch' + 'gtk2-fix-out-of-source-build.patch') +sha256sums=( + 'b6c8a93ddda5eabe3bfee1eb39636c9a03d2a56c7b62828b359bf197943c582e' + 'a3d347337b0aaa2b170b836c20070f758698949d0511b9a92528ab4926bdcfe6' + 'e88bb004767c95cd567f225995891f054218e2c806844a3e5c12b70ac3ea231e') _architectures=('i686-w64-mingw32' 'x86_64-w64-mingw32') +prepare() { + cd "${srcdir}/gtk+-${pkgver}" + local source_file + for source_file in "${source[@]}"; do + case "${source_file}" in + *.patch) + patch -p1 < "${srcdir}/${source_file}" + ;; + esac + done + rm "${srcdir}/gtk+-${pkgver}/gtk/gtk.def" +} + build() { cd "${srcdir}/gtk+-${pkgver}" + autoreconf -fi for _arch in "${_architectures[@]}"; do msg "Building for ${_arch}" - rm "${srcdir}/gtk+-${pkgver}/gtk/gtk.def" mkdir -p "build-${_arch}" cd "build-${_arch}" msg "Starting configure and make" diff --git a/gtk2-fix-gcc-10-build.patch b/gtk2-fix-gcc-10-build.patch new file mode 100644 index 000000000000..8cb040b8676d --- /dev/null +++ b/gtk2-fix-gcc-10-build.patch @@ -0,0 +1,72 @@ +From aae860fe3e9f25526a40734a01fa6eadefbe26e6 Mon Sep 17 00:00:00 2001 +From: Philip Zander <philip.zander@gmail.com> +Date: Tue, 28 Jul 2020 02:31:52 +0200 +Subject: [PATCH] Change `__declspec(dllexport)` to `extern + __declspec(dllexport)` + +As of 28 July 2020, building on MSYS2 fails with "multiple definition" +errors unless exported variables are explicitly marked as "extern". + +Closes #2958 +--- + gdk/gdktypes.h | 2 +- + gtk/gtkdebug.h | 2 +- + gtk/gtkmain.h | 2 +- + gtk/gtktexttypes.h | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/gdk/gdktypes.h b/gdk/gdktypes.h +index eed31243ba..c72b20b92e 100644 +--- a/gdk/gdktypes.h ++++ b/gdk/gdktypes.h +@@ -39,7 +39,7 @@ + + #ifdef G_OS_WIN32 + # ifdef GDK_COMPILATION +-# define GDKVAR __declspec(dllexport) ++# define GDKVAR extern __declspec(dllexport) + # else + # define GDKVAR extern __declspec(dllimport) + # endif +diff --git a/gtk/gtkdebug.h b/gtk/gtkdebug.h +index 05964f8dbe..623750301d 100644 +--- a/gtk/gtkdebug.h ++++ b/gtk/gtkdebug.h +@@ -64,7 +64,7 @@ typedef enum { + + #ifdef G_OS_WIN32 + # ifdef GTK_COMPILATION +-# define GTKVAR __declspec(dllexport) ++# define GTKVAR extern __declspec(dllexport) + # else + # define GTKVAR extern __declspec(dllimport) + # endif +diff --git a/gtk/gtkmain.h b/gtk/gtkmain.h +index 02a1daea9e..2f057e5478 100644 +--- a/gtk/gtkmain.h ++++ b/gtk/gtkmain.h +@@ -67,7 +67,7 @@ typedef gint (*GtkKeySnoopFunc) (GtkWidget *grab_widget, + */ + #ifdef G_PLATFORM_WIN32 + #ifdef GTK_COMPILATION +-#define GTKMAIN_C_VAR __declspec(dllexport) ++#define GTKMAIN_C_VAR extern __declspec(dllexport) + #else + #define GTKMAIN_C_VAR extern __declspec(dllimport) + #endif +diff --git a/gtk/gtktexttypes.h b/gtk/gtktexttypes.h +index c624aeaf3a..eb0db36e6d 100644 +--- a/gtk/gtktexttypes.h ++++ b/gtk/gtktexttypes.h +@@ -44,7 +44,7 @@ typedef struct _GtkTextMarkBody GtkTextMarkBody; + + #ifdef G_OS_WIN32 + #ifdef GTK_COMPILATION +-#define VARIABLE __declspec(dllexport) ++#define VARIABLE extern __declspec(dllexport) + #else + #define VARIABLE extern __declspec(dllimport) + #endif +-- +GitLab + diff --git a/gtk2-fix-out-of-source-build.patch b/gtk2-fix-out-of-source-build.patch new file mode 100644 index 000000000000..17e88caf4b10 --- /dev/null +++ b/gtk2-fix-out-of-source-build.patch @@ -0,0 +1,98 @@ +From f203b1a751accbc55526d2e49cddc90355718a4a Mon Sep 17 00:00:00 2001 +From: Ting-Wei Lan <lantw@src.gnome.org> +Date: Wed, 26 Aug 2020 01:01:56 +0800 +Subject: [PATCH] build: Move gtk.def to builddir + +GTK2 uses different gtk.def files on 32-bit and 64-bit Windows. GTK2 +source tarballs ship pre-generated gtk.def for 32-bit Windows. If the +user wants to build for 64-bit Windows, the pre-generated gtk.def must +be deleted before the build to force regeneration, or it will fail to +link with 'symbol not defined' errors because the 32-bit Windows build +includes more legacy functions than the 64-bit Windows build. + +While users who want to build for 64-bit Windows can delete gtk.def in +the build script, which is currently what most build scripts do, doing +so breaks out-of-source build. On AUR, MinGW packages are usually built +and packaged in the following order: + +1. Run 'configure' and 'make' to build for i686-w64-mingw32. +2. Run 'configure' and 'make' to build for x86_64-w64-mingw32. +3. Run 'make install' for i686-w64-mingw32. +4. Run 'make install' for x86_64-w64-mingw32. + +It fails because step 3 sees gtk.def left by step 2, which is generated +for a different build. In step 3, make sees the gtk.def change and runs +libtool to relink libgtk-win32-2.0-0.dll. libtool fails to find a lot of +necessary libraries, decides that it is not possible to build a DLL with +-no-undefined, and produces only the static library. It then tries to +relink executables with the static library, and fails with undefined +reference to 'IID_IUnknown' because -Wl,--start-group isn't used and +the use of -Wl,-luuid prevents libtool from using the correct order. + +To resolve the problem, move gtk.def to builddir so different builds can +have different gtk.def files while sharing the same source tree. This +also means that the source tarball will no longer include pre-generated +gtk.def file, which should be acceptable because it is already broken on +64-bit Windows. + +Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3029 +--- + gtk/Makefile.am | 13 ++++++------- + 1 file changed, 6 insertions(+), 7 deletions(-) + +diff --git a/gtk/Makefile.am b/gtk/Makefile.am +index cdbbd8c8d9..5b337da644 100644 +--- a/gtk/Makefile.am ++++ b/gtk/Makefile.am +@@ -71,7 +71,7 @@ endif + + if OS_WIN32 + gtk_def = gtk.def +-gtk_win32_symbols = -export-symbols $(srcdir)/gtk.def ++gtk_win32_symbols = -export-symbols gtk.def + + gtk_win32_res = gtk-win32-res.o + gtk_win32_res_ldflag = -Wl,gtk-win32-res.o +@@ -81,7 +81,7 @@ gtk-win32-res.o : gtk-win32.rc + + install-def-file: gtk.def + $(mkinstalldirs) $(DESTDIR)$(libdir) +- $(INSTALL) $(srcdir)/gtk.def $(DESTDIR)$(libdir)/gtk-win32-2.0.def ++ $(INSTALL) gtk.def $(DESTDIR)$(libdir)/gtk-win32-2.0.def + uninstall-def-file: + -rm $(DESTDIR)$(libdir)/gtk-win32-2.0.def + else +@@ -106,10 +106,10 @@ install-ms-lib: + uninstall-ms-lib: + endif + +-# This places the generated .def file in srcdir, since it is expected to be there. +-# (The one from a tarball is) ++# gtk.def has to be put in builddir and should not be included in a source ++# tarball because it differs in 32-bit and 64-bit Windows builds. + gtk.def: gtk.symbols +- (echo -e EXPORTS; $(CPP) -P -DINCLUDE_VARIABLES -DG_OS_WIN32 -DALL_FILES - <$(srcdir)/gtk.symbols | sed -e '/^$$/d' -e 's/^/ /' -e 's/G_GNUC_[^ ]*//g') > $(srcdir)/gtk.def ++ (echo -e EXPORTS; $(CPP) -P -DINCLUDE_VARIABLES -DG_OS_WIN32 -DALL_FILES - <$(srcdir)/gtk.symbols | sed -e '/^$$/d' -e 's/^/ /' -e 's/G_GNUC_[^ ]*//g') > gtk.def + + gtkalias.h: gtk.symbols + $(PERL) $(srcdir)/makegtkalias.pl < $(srcdir)/gtk.symbols > gtkalias.h +@@ -836,7 +836,7 @@ EXTRA_DIST += $(STOCK_ICONS) + # + # setup autogeneration dependencies + gen_sources = xgen-gdef xgen-gtbh xgen-gtic xgen-gmh xgen-gmc xgen-gmlh xgen-gmlc xgen-gtfsrc.c xgen-gtf +-CLEANFILES = $(gen_sources) ++CLEANFILES = $(gen_sources) $(gtk_def) + + BUILT_SOURCES = $(gtk_built_sources) + +@@ -1463,7 +1463,6 @@ EXTRA_DIST += \ + tree_minus.xbm \ + tree_minus.xpm \ + tree_plus.xpm \ +- gtk.def \ + gtk-builder-convert \ + gtk-win32.rc \ + gtk-win32.rc.in \ +-- +GitLab + |