[mingw-glib2] Prefer the use of GCC constructors over DllMain
Erik van Pienbroek
epienbro at fedoraproject.org
Sat Mar 23 13:28:50 UTC 2013
commit fba82fe33fd50b11e4561596736629714dea569d
Author: Erik van Pienbroek <epienbro at fedoraproject.org>
Date: Sat Mar 23 14:28:07 2013 +0100
Prefer the use of GCC constructors over DllMain
This removes the DllMain symbol from the static libraries
glib-prefer-constructors-over-DllMain.patch | 52 +++++++++++++++++++++++++++
mingw-glib2.spec | 8 ++++
2 files changed, 60 insertions(+), 0 deletions(-)
---
diff --git a/glib-prefer-constructors-over-DllMain.patch b/glib-prefer-constructors-over-DllMain.patch
new file mode 100644
index 0000000..256e8e7
--- /dev/null
+++ b/glib-prefer-constructors-over-DllMain.patch
@@ -0,0 +1,52 @@
+--- glib/glib-init.c.orig 2013-03-23 12:07:27.009718160 +0100
++++ glib/glib-init.c 2013-03-23 13:00:24.460030271 +0100
+@@ -223,12 +223,14 @@
+
+ #if defined (G_OS_WIN32)
+
++HMODULE glib_dll = NULL;
++
++#if defined (DLL_EXPORT)
++
+ BOOL WINAPI DllMain (HINSTANCE hinstDLL,
+ DWORD fdwReason,
+ LPVOID lpvReserved);
+
+-HMODULE glib_dll;
+-
+ BOOL WINAPI
+ DllMain (HINSTANCE hinstDLL,
+ DWORD fdwReason,
+@@ -238,9 +240,6 @@
+ {
+ case DLL_PROCESS_ATTACH:
+ glib_dll = hinstDLL;
+- g_clock_win32_init ();
+- g_thread_win32_init ();
+- glib_init ();
+ break;
+
+ case DLL_THREAD_DETACH:
+@@ -255,7 +254,10 @@
+ return TRUE;
+ }
+
+-#elif defined (G_HAS_CONSTRUCTORS)
++#endif /* defined (DLL_EXPORT) */
++#endif /* defined (G_OS_WIN32) */
++
++#if defined (G_HAS_CONSTRUCTORS)
+
+ #ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
+ #pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(glib_init_ctor)
+@@ -265,6 +267,10 @@
+ static void
+ glib_init_ctor (void)
+ {
++#if defined (G_OS_WIN32)
++ g_clock_win32_init ();
++ g_thread_win32_init ();
++#endif
+ glib_init ();
+ }
+
diff --git a/mingw-glib2.spec b/mingw-glib2.spec
index f2677a2..e124c2d 100644
--- a/mingw-glib2.spec
+++ b/mingw-glib2.spec
@@ -58,6 +58,11 @@ Patch3: glib-send-log-messages-to-correct-stdout-and-stderr.patch
# https://bugzilla.gnome.org/show_bug.cgi?id=694506
Patch4: glib-formatstring.patch
+# Prefer the use of GCC constructors over DllMain
+# This prevents having to depend on DllMain in static libraries
+# http://lists.fedoraproject.org/pipermail/fedora-mingw/2013-March/006429.html
+Patch5: glib-prefer-constructors-over-DllMain.patch
+
%description
MinGW Windows Glib2 library.
@@ -104,6 +109,7 @@ Static version of the MinGW Windows GLib2 library.
%patch2 -p1
%patch3 -p0
%patch4 -p0
+%patch5 -p0
autoreconf -i --force
@@ -287,6 +293,8 @@ find $RPM_BUILD_ROOT -name "*.la" -delete
* Sat Mar 23 2013 Erik van Pienbroek <epienbro at fedoraproject.org> - 2.35.9-1
- Update to 2.35.9
- Added R: mingw{32,64}-gettext-static to the -static subpackages
+- Prefer the use of GCC constructors over DllMain
+ This removes the DllMain symbol from the static libraries
* Fri Feb 22 2013 Thomas Sailer <t.sailer at alumni.ethz.ch> - 2.35.8-1
- update to 2.35.8
More information about the mingw
mailing list