about summary refs log tree commit diff
path: root/pkgs/development/libraries/glib/tests-skip-shared-libs-if-default_library-static.patch
blob: 106ba4f99a97c6cb8db1a59e204806eb74d12dac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
From b804e4b82cd8e85631112d935543c62ef56783e5 Mon Sep 17 00:00:00 2001
From: Alyssa Ross <hi@alyssa.is>
Date: Tue, 23 Aug 2022 13:13:44 +0000
Subject: [PATCH] tests: skip shared libs if default_library=static

Otherwise, the build will fail when the toolchain is static-only, even
with -Ddefault_library=static.  I talked to a Meson developer in their
IRC channel, who told me that the correct fix was to ensure that
shared_library is only used if default_library != static.

Part-of: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2867
[Backported to 2.72.3]
---
 gio/tests/meson.build  | 43 +++++++++++++++++++++++-------------------
 glib/tests/meson.build |  2 +-
 gmodule/tests/meson.build      | 30 +++++++++++++++--------------
 3 files changed, 41 insertions(+), 34 deletions(-)

diff --git a/gio/tests/meson.build b/gio/tests/meson.build
index 3ed23a5f2..7b1aba80d 100644
--- a/gio/tests/meson.build
+++ b/gio/tests/meson.build
@@ -203,7 +203,7 @@ if host_machine.system() != 'windows'
   }
 
   # LD_PRELOAD modules don't work so well with AddressSanitizer
-  if have_rtld_next and get_option('b_sanitize') == 'none'
+  if have_rtld_next and get_option('default_library') != 'static' and get_option('b_sanitize') == 'none'
     gio_tests += {
       'gsocketclient-slow' : {
         'depends' : [
@@ -607,24 +607,26 @@ if not meson.is_cross_build() or meson.has_exe_wrapper()
 
   compiler_type = '--compiler=@0@'.format(cc.get_id())
 
-  plugin_resources_c = custom_target('plugin-resources.c',
-    input : 'test4.gresource.xml',
-    output : 'plugin-resources.c',
-    command : [glib_compile_resources,
-               compiler_type,
-               '--target=@OUTPUT@',
-               '--sourcedir=' + meson.current_source_dir(),
-               '--internal',
-               '--generate-source',
-               '--c-name', '_g_plugin',
-               '@INPUT@'])
+  if get_option('default_library') != 'static'
+    plugin_resources_c = custom_target('plugin-resources.c',
+      input : 'test4.gresource.xml',
+      output : 'plugin-resources.c',
+      command : [glib_compile_resources,
+                 compiler_type,
+                 '--target=@OUTPUT@',
+                 '--sourcedir=' + meson.current_source_dir(),
+                 '--internal',
+                 '--generate-source',
+                 '--c-name', '_g_plugin',
+                 '@INPUT@'])
 
-  shared_module('resourceplugin', 'resourceplugin.c', plugin_resources_c,
-    link_args : export_dynamic_ldflags,
-    dependencies : common_gio_tests_deps,
-    install_dir : installed_tests_execdir,
-    install : installed_tests_enabled
-  )
+    shared_module('resourceplugin', 'resourceplugin.c', plugin_resources_c,
+      link_args : export_dynamic_ldflags,
+      dependencies : common_gio_tests_deps,
+      install_dir : installed_tests_execdir,
+      install : installed_tests_enabled
+    )
+  endif
 
   # referenced by test2.gresource.xml
   big_test_resource = custom_target(
@@ -917,4 +919,7 @@ if installed_tests_enabled
 endif
 
 subdir('services')
-subdir('modules')
+
+if get_option('default_library') != 'static'
+  subdir('modules')
+endif
diff --git a/glib/tests/meson.build b/glib/tests/meson.build
index 301158e0f..6203ff45e 100644
--- a/glib/tests/meson.build
+++ b/glib/tests/meson.build
@@ -172,7 +172,7 @@ else
     'include' : {},
     'unix' : {},
   }
-  if have_rtld_next
+  if have_rtld_next and get_option('default_library') != 'static'
     glib_tests += {
       'gutils-user-database' : {
         'depends' : [
diff --git a/gmodule/tests/meson.build b/gmodule/tests/meson.build
index c95fa1d00..25144c941 100644
--- a/gmodule/tests/meson.build
+++ b/gmodule/tests/meson.build
@@ -72,20 +72,22 @@ if ['darwin', 'ios'].contains(host_machine.system())
   module_suffix = 'so'
 endif
 
-foreach module : ['moduletestplugin_a', 'moduletestplugin_b']
-  shared_module(module + '_plugin', 'lib@0@.c'.format(module),
-    dependencies : [libglib_dep, libgmodule_dep],
-    install_dir : installed_tests_execdir,
-    install : installed_tests_enabled,
-    name_suffix : module_suffix
-  )
-  shared_library(module + '_library', 'lib@0@.c'.format(module),
-    dependencies : [libglib_dep, libgmodule_dep],
-    install_dir : installed_tests_execdir,
-    install : installed_tests_enabled,
-    name_suffix : module_suffix
-  )
-endforeach
+if get_option('default_library') != 'static'
+  foreach module : ['moduletestplugin_a', 'moduletestplugin_b']
+    shared_module(module + '_plugin', 'lib@0@.c'.format(module),
+      dependencies : [libglib_dep, libgmodule_dep],
+      install_dir : installed_tests_execdir,
+      install : installed_tests_enabled,
+      name_suffix : module_suffix
+    )
+    shared_library(module + '_library', 'lib@0@.c'.format(module),
+      dependencies : [libglib_dep, libgmodule_dep],
+      install_dir : installed_tests_execdir,
+      install : installed_tests_enabled,
+      name_suffix : module_suffix
+    )
+  endforeach
+endif
 
 common_c_args = test_cargs + ['-DGLIB_DISABLE_DEPRECATION_WARNINGS']
 common_deps = [libm, thread_dep, libglib_dep]
-- 
2.37.1