git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #42570 from dtzWill/fix/glib-musl-quark_init

glib: patch to fix w/musl, static ctor order assumptions (quark/gobject)

commit656dc516662d29221ea228857892fa78cbe4b1eb authorWill Dietz <github@wdtz.org> dateMon 25 Jun 2018, 11:55 (8 years ago) parentd92f73e3a6b91f
3 files changed+124−1
pkgs/development/libraries/glib/default.nix+4−1 pkgs/development/libraries/glib/gobject_init_on_demand.patch+87 pkgs/development/libraries/glib/quark_init_on_demand.patch+33
pkgs/development/libraries/glib/default.nix+4−1
@@ -54,7 +54,10 @@ stdenv.mkDerivation rec {
5454
5555 patches = optional stdenv.isDarwin ./darwin-compilation.patch
5656 ++ optional doCheck ./skip-timer-test.patch
57− ++ [ ./schema-override-variable.patch ];
57+ ++ optionals stdenv.hostPlatform.isMusl [
58+ ./quark_init_on_demand.patch
59+ ./gobject_init_on_demand.patch
60+ ] ++ [ ./schema-override-variable.patch ];
5861
5962 outputs = [ "out" "dev" "devdoc" ];
6063 outputBin = "dev";
pkgs/development/libraries/glib/gobject_init_on_demand.patchnew file+87
@@ -0,0 +1,87 @@
1+--- glib-source/gobject/gtype.c 2016-08-17 17:20:47.000000000 +0200
2++++ glib-source/gobject/gtype.c 2016-09-01 21:56:31.777406646 +0200
3+@@ -209,6 +209,9 @@
4+ static gboolean type_node_is_a_L (TypeNode *node,
5+ TypeNode *iface_node);
6+
7++#if !defined(__GLIBC__)
8++static void gobject_init (void);
9++#endif
10+
11+ /* --- enumeration --- */
12+
13+@@ -2631,7 +2634,10 @@
14+ GTypeFlags flags)
15+ {
16+ TypeNode *node;
17+-
18++
19++#if !defined(__GLIBC__)
20++ gobject_init();
21++#endif
22+ g_assert_type_system_initialized ();
23+ g_return_val_if_fail (type_id > 0, 0);
24+ g_return_val_if_fail (type_name != NULL, 0);
25+@@ -2749,6 +2755,9 @@
26+ TypeNode *pnode, *node;
27+ GType type = 0;
28+
29++#if !defined(__GLIBC__)
30++ gobject_init();
31++#endif
32+ g_assert_type_system_initialized ();
33+ g_return_val_if_fail (parent_type > 0, 0);
34+ g_return_val_if_fail (type_name != NULL, 0);
35+@@ -2804,6 +2813,9 @@
36+ TypeNode *pnode, *node;
37+ GType type;
38+
39++#if !defined(__GLIBC__)
40++ gobject_init();
41++#endif
42+ g_assert_type_system_initialized ();
43+ g_return_val_if_fail (parent_type > 0, 0);
44+ g_return_val_if_fail (type_name != NULL, 0);
45+@@ -3319,6 +3331,9 @@
46+ {
47+ TypeNode *node;
48+
49++#if !defined(__GLIBC__)
50++ gobject_init();
51++#endif
52+ g_assert_type_system_initialized ();
53+
54+ node = lookup_type_node_I (type);
55+@@ -4343,6 +4358,9 @@
56+ void
57+ g_type_init_with_debug_flags (GTypeDebugFlags debug_flags)
58+ {
59++#if !defined(__GLIBC__)
60++ gobject_init();
61++#endif
62+ g_assert_type_system_initialized ();
63+
64+ if (debug_flags)
65+@@ -4361,6 +4379,9 @@
66+ void
67+ g_type_init (void)
68+ {
69++#if !defined(__GLIBC__)
70++ gobject_init();
71++#endif
72+ g_assert_type_system_initialized ();
73+ }
74+
75+@@ -4372,6 +4393,12 @@
76+ TypeNode *node;
77+ GType type;
78+
79++#if !defined(__GLIBC__)
80++ static int gobject_initialized = 0;
81++ if (gobject_initialized)
82++ return;
83++ gobject_initialized = 1;
84++#endif
85+ /* Ensure GLib is initialized first, see
86+ * https://bugzilla.gnome.org/show_bug.cgi?id=756139
87+ */
pkgs/development/libraries/glib/quark_init_on_demand.patchnew file+33
@@ -0,0 +1,33 @@
1+--- glib-source/glib/gquark.c 2016-08-17 17:20:47.000000000 +0200
2++++ glib-source/glib/gquark.c 2016-08-30 07:49:13.298234757 +0200
3+@@ -57,6 +57,9 @@
4+ void
5+ g_quark_init (void)
6+ {
7++ if (quark_ht)
8++ return;
9++
10+ g_assert (quark_seq_id == 0);
11+ quark_ht = g_hash_table_new (g_str_hash, g_str_equal);
12+ quarks = g_new (gchar*, QUARK_BLOCK_SIZE);
13+@@ -138,9 +141,12 @@
14+ return 0;
15+
16+ G_LOCK (quark_global);
17++#if !defined(__GLIBC__)
18++ g_quark_init ();
19++#endif
20+ quark = GPOINTER_TO_UINT (g_hash_table_lookup (quark_ht, string));
21+ G_UNLOCK (quark_global);
22+
23+ return quark;
24+ }
25+
26+@@ -280,6 +286,7 @@
27+ GQuark quark;
28+ gchar **quarks_new;
29+
30++ g_quark_init ();
31+ if (quark_seq_id % QUARK_BLOCK_SIZE == 0)
32+ {
33+ quarks_new = g_new (gchar*, quark_seq_id + QUARK_BLOCK_SIZE);