fix-static-build-589.diff 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. diff --git a/gio/tests/giomodule.c b/gio/tests/giomodule.c
  2. index e832e95d37b6c19c9a7fce2adbc6eb47aced4256..893357110e0d74e94fd7f40b5f3172964b545daa 100644
  3. --- a/gio/tests/giomodule.c
  4. +++ b/gio/tests/giomodule.c
  5. @@ -76,51 +76,57 @@ test_extension_point (void)
  6. static void
  7. test_module_scan_all (void)
  8. {
  9. - if (g_test_subprocess ())
  10. + if (g_module_supported ())
  11. {
  12. - GIOExtensionPoint *ep;
  13. - GIOExtension *ext;
  14. - GList *list;
  15. - ep = g_io_extension_point_register ("test-extension-point");
  16. - g_io_modules_scan_all_in_directory (g_test_get_filename (G_TEST_BUILT, "modules", NULL));
  17. - g_io_modules_scan_all_in_directory (g_test_get_filename (G_TEST_BUILT, "modules/.libs", NULL));
  18. - list = g_io_extension_point_get_extensions (ep);
  19. - g_assert_cmpint (g_list_length (list), ==, 2);
  20. - ext = list->data;
  21. - g_assert_cmpstr (g_io_extension_get_name (ext), ==, "test-b");
  22. - ext = list->next->data;
  23. - g_assert_cmpstr (g_io_extension_get_name (ext), ==, "test-a");
  24. - return;
  25. + if (g_test_subprocess ())
  26. + {
  27. + GIOExtensionPoint *ep;
  28. + GIOExtension *ext;
  29. + GList *list;
  30. + ep = g_io_extension_point_register ("test-extension-point");
  31. + g_io_modules_scan_all_in_directory (g_test_get_filename (G_TEST_BUILT, "modules", NULL));
  32. + g_io_modules_scan_all_in_directory (g_test_get_filename (G_TEST_BUILT, "modules/.libs", NULL));
  33. + list = g_io_extension_point_get_extensions (ep);
  34. + g_assert_cmpint (g_list_length (list), ==, 2);
  35. + ext = list->data;
  36. + g_assert_cmpstr (g_io_extension_get_name (ext), ==, "test-b");
  37. + ext = list->next->data;
  38. + g_assert_cmpstr (g_io_extension_get_name (ext), ==, "test-a");
  39. + return;
  40. + }
  41. + g_test_trap_subprocess (NULL, 0, 7);
  42. + g_test_trap_assert_passed ();
  43. }
  44. - g_test_trap_subprocess (NULL, 0, 7);
  45. - g_test_trap_assert_passed ();
  46. }
  47. static void
  48. test_module_scan_all_with_scope (void)
  49. {
  50. - if (g_test_subprocess ())
  51. + if (g_module_supported ())
  52. {
  53. - GIOExtensionPoint *ep;
  54. - GIOModuleScope *scope;
  55. - GIOExtension *ext;
  56. - GList *list;
  57. + if (g_test_subprocess ())
  58. + {
  59. + GIOExtensionPoint *ep;
  60. + GIOModuleScope *scope;
  61. + GIOExtension *ext;
  62. + GList *list;
  63. - ep = g_io_extension_point_register ("test-extension-point");
  64. - scope = g_io_module_scope_new (G_IO_MODULE_SCOPE_BLOCK_DUPLICATES);
  65. - g_io_module_scope_block (scope, "libtestmoduleb." G_MODULE_SUFFIX);
  66. - g_io_modules_scan_all_in_directory_with_scope (g_test_get_filename (G_TEST_BUILT, "modules", NULL), scope);
  67. - list = g_io_extension_point_get_extensions (ep);
  68. - g_io_modules_scan_all_in_directory_with_scope (g_test_get_filename (G_TEST_BUILT, "modules/.libs", NULL), scope);
  69. - list = g_io_extension_point_get_extensions (ep);
  70. - g_assert_cmpint (g_list_length (list), ==, 1);
  71. - ext = list->data;
  72. - g_assert_cmpstr (g_io_extension_get_name (ext), ==, "test-a");
  73. - g_io_module_scope_free (scope);
  74. - return;
  75. + ep = g_io_extension_point_register ("test-extension-point");
  76. + scope = g_io_module_scope_new (G_IO_MODULE_SCOPE_BLOCK_DUPLICATES);
  77. + g_io_module_scope_block (scope, "libtestmoduleb." G_MODULE_SUFFIX);
  78. + g_io_modules_scan_all_in_directory_with_scope (g_test_get_filename (G_TEST_BUILT, "modules", NULL), scope);
  79. + list = g_io_extension_point_get_extensions (ep);
  80. + g_io_modules_scan_all_in_directory_with_scope (g_test_get_filename (G_TEST_BUILT, "modules/.libs", NULL), scope);
  81. + list = g_io_extension_point_get_extensions (ep);
  82. + g_assert_cmpint (g_list_length (list), ==, 1);
  83. + ext = list->data;
  84. + g_assert_cmpstr (g_io_extension_get_name (ext), ==, "test-a");
  85. + g_io_module_scope_free (scope);
  86. + return;
  87. + }
  88. + g_test_trap_subprocess (NULL, 0, 7);
  89. + g_test_trap_assert_passed ();
  90. }
  91. - g_test_trap_subprocess (NULL, 0, 7);
  92. - g_test_trap_assert_passed ();
  93. }
  94. int
  95. diff --git a/gmodule/meson.build b/gmodule/meson.build
  96. index e4a6a1c811c97ea32e27c79a766dd31205e7789b..77ffdc476a631eed8403a88b08006e6fb4b16494 100644
  97. --- a/gmodule/meson.build
  98. +++ b/gmodule/meson.build
  99. @@ -8,7 +8,8 @@ libdl_dep = [ ]
  100. g_module_lib_args = [ ]
  101. g_module_impl = ''
  102. -dlopen_dlsym_test_code = '''
  103. +if get_option('default_library') != 'static'
  104. + dlopen_dlsym_test_code = '''
  105. #include <dlfcn.h>
  106. int glib_underscore_test (void) { return 42; }
  107. int main (int argc, char ** argv) {
  108. @@ -21,48 +22,49 @@ int main (int argc, char ** argv) {
  109. return (!f2 || f1);
  110. }'''
  111. -# On Windows force native WIN32 shared lib loader
  112. -if host_system == 'windows'
  113. - g_module_impl = 'G_MODULE_IMPL_WIN32'
  114. -# Force native AIX library loader
  115. -# dlopen() filepath must be of the form /path/libname.a(libname.so)
  116. -elif host_system == 'aix'
  117. - g_module_impl = 'G_MODULE_IMPL_AR'
  118. -elif cc.links(dlopen_dlsym_test_code, name : 'dlopen() and dlsym() in system libraries')
  119. - g_module_impl = 'G_MODULE_IMPL_DL'
  120. -# NSLinkModule (dyld) in system libraries (Darwin)
  121. -elif cc.has_function('NSLinkModule')
  122. - g_module_impl = 'G_MODULE_IMPL_DYLD'
  123. - g_module_need_uscore = 1
  124. -elif cc.links(dlopen_dlsym_test_code, args : '-ldl', name : 'dlopen() and dlsym() in libdl')
  125. - g_module_impl = 'G_MODULE_IMPL_DL'
  126. - libdl_dep = cc.find_library('dl')
  127. - g_module_lib_args = '-ldl'
  128. -endif
  129. + # On Windows force native WIN32 shared lib loader
  130. + if host_system == 'windows'
  131. + g_module_impl = 'G_MODULE_IMPL_WIN32'
  132. + # Force native AIX library loader
  133. + # dlopen() filepath must be of the form /path/libname.a(libname.so)
  134. + elif host_system == 'aix'
  135. + g_module_impl = 'G_MODULE_IMPL_AR'
  136. + elif cc.links(dlopen_dlsym_test_code, name : 'dlopen() and dlsym() in system libraries')
  137. + g_module_impl = 'G_MODULE_IMPL_DL'
  138. + # NSLinkModule (dyld) in system libraries (Darwin)
  139. + elif cc.has_function('NSLinkModule')
  140. + g_module_impl = 'G_MODULE_IMPL_DYLD'
  141. + g_module_need_uscore = 1
  142. + elif cc.links(dlopen_dlsym_test_code, args : '-ldl', name : 'dlopen() and dlsym() in libdl')
  143. + g_module_impl = 'G_MODULE_IMPL_DL'
  144. + libdl_dep = cc.find_library('dl')
  145. + g_module_lib_args = '-ldl'
  146. + endif
  147. -# additional checks for G_MODULE_IMPL_DL
  148. -if g_module_impl == 'G_MODULE_IMPL_DL'
  149. - # FIXME: check for OSF1/5.0 RTLD_GLOBAL brokenness (is this still relevant?)
  150. + # additional checks for G_MODULE_IMPL_DL
  151. + if g_module_impl == 'G_MODULE_IMPL_DL'
  152. + # FIXME: check for OSF1/5.0 RTLD_GLOBAL brokenness (is this still relevant?)
  153. - # Check whether we need preceding underscores
  154. - if cc.get_id() == 'msvc'
  155. - message('Building for MSVC: assuming that symbols are prefixed with underscore')
  156. - g_module_need_uscore = 1
  157. - elif meson.has_exe_wrapper()
  158. - # FIXME: communicate result via stdout instead of return value, so non-0 return is not printed in bold red
  159. - rres = cc.run(dlopen_dlsym_test_code,
  160. - args : g_module_lib_args,
  161. - name : 'dlsym() preceding underscores')
  162. - if host_system == 'windows' or rres.returncode() == 0
  163. + # Check whether we need preceding underscores
  164. + if cc.get_id() == 'msvc'
  165. + message('Building for MSVC: assuming that symbols are prefixed with underscore')
  166. g_module_need_uscore = 1
  167. + elif meson.has_exe_wrapper()
  168. + # FIXME: communicate result via stdout instead of return value, so non-0 return is not printed in bold red
  169. + rres = cc.run(dlopen_dlsym_test_code,
  170. + args : g_module_lib_args,
  171. + name : 'dlsym() preceding underscores')
  172. + if host_system == 'windows' or rres.returncode() == 0
  173. + g_module_need_uscore = 1
  174. + endif
  175. + else
  176. + message('Cross-compiling: assuming that symbols aren\'t prefixed with underscore')
  177. + g_module_need_uscore = 0
  178. endif
  179. - else
  180. - message('Cross-compiling: assuming that symbols aren\'t prefixed with underscore')
  181. - g_module_need_uscore = 0
  182. - endif
  183. - if cc.has_function('dlerror', args : g_module_lib_args)
  184. - g_module_have_dlerror = 1
  185. + if cc.has_function('dlerror', args : g_module_lib_args)
  186. + g_module_have_dlerror = 1
  187. + endif
  188. endif
  189. endif
  190. diff --git a/tests/module-test.c b/tests/module-test.c
  191. index fbf23169f730f3ecf2f24c1071f6ee1869fdc2fe..04a12128923258fe0ab0b37e618fe89b11cb0327 100644
  192. --- a/tests/module-test.c
  193. +++ b/tests/module-test.c
  194. @@ -82,7 +82,7 @@ main (int argc,
  195. g_test_init (&argc, &argv, NULL);
  196. if (!g_module_supported ())
  197. - g_error ("dynamic modules not supported");
  198. + return 0;
  199. plugin_a = g_test_build_filename (G_TEST_BUILT, "libmoduletestplugin_a", NULL);
  200. plugin_b = g_test_build_filename (G_TEST_BUILT, "libmoduletestplugin_b", NULL);