[glib/nirbheek/gmodule-symbol-uscore-static] gmodule: Use meson compiler method for symbol underscore checks
- From: Nirbheek Chauhan <nirbheekc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/nirbheek/gmodule-symbol-uscore-static] gmodule: Use meson compiler method for symbol underscore checks
- Date: Sat, 13 Jul 2019 05:40:17 +0000 (UTC)
commit d3ca245ddba772b77b3de00f7a8344311472b6b6
Author: Nirbheek Chauhan <nirbheek centricular com>
Date: Sat Jul 13 11:08:37 2019 +0530
gmodule: Use meson compiler method for symbol underscore checks
This is much simpler and also works when cross-compiling.
gmodule/meson.build | 45 +++++++--------------------------------------
1 file changed, 7 insertions(+), 38 deletions(-)
---
diff --git a/gmodule/meson.build b/gmodule/meson.build
index a7a2a5c87..5fd2c28dc 100644
--- a/gmodule/meson.build
+++ b/gmodule/meson.build
@@ -8,18 +8,8 @@ libdl_dep = [ ]
g_module_lib_args = [ ]
g_module_impl = ''
-dlopen_dlsym_test_code = '''
-#include <dlfcn.h>
-int glib_underscore_test (void) { return 42; }
-int main (int argc, char ** argv) {
- void *f1 = (void*)0, *f2 = (void*)0, *handle;
- handle = dlopen ((void*)0, 0);
- if (handle) {
- f1 = dlsym (handle, "glib_underscore_test");
- f2 = dlsym (handle, "_glib_underscore_test");
- }
- return (!f2 || f1);
-}'''
+# Check whether we need preceding underscores
+g_module_need_uscore = cc.symbols_have_underscore_prefix()
# On Windows force native WIN32 shared lib loader
if host_system == 'windows'
@@ -28,42 +18,21 @@ if host_system == 'windows'
# dlopen() filepath must be of the form /path/libname.a(libname.so)
elif host_system == 'aix'
g_module_impl = 'G_MODULE_IMPL_AR'
-elif cc.links(dlopen_dlsym_test_code, name : 'dlopen() and dlsym() in system libraries')
+elif cc.has_function('dlopen', prefix : '#include <dlfcn.h>')
g_module_impl = 'G_MODULE_IMPL_DL'
# NSLinkModule (dyld) in system libraries (Darwin)
elif cc.has_function('NSLinkModule')
g_module_impl = 'G_MODULE_IMPL_DYLD'
- g_module_need_uscore = 1
-elif cc.links(dlopen_dlsym_test_code, args : '-ldl', name : 'dlopen() and dlsym() in libdl')
+elif cc.has_function('dlopen', prefix : '#include <dlfcn.h>', args : '-ldl')
g_module_impl = 'G_MODULE_IMPL_DL'
libdl_dep = cc.find_library('dl')
g_module_lib_args = '-ldl'
endif
# additional checks for G_MODULE_IMPL_DL
-if g_module_impl == 'G_MODULE_IMPL_DL'
- # FIXME: check for OSF1/5.0 RTLD_GLOBAL brokenness (is this still relevant?)
-
- # Check whether we need preceding underscores
- if cc.get_id() == 'msvc'
- message('Building for MSVC: assuming that symbols are prefixed with underscore')
- g_module_need_uscore = 1
- elif meson.has_exe_wrapper()
- # FIXME: communicate result via stdout instead of return value, so non-0 return is not printed in bold
red
- rres = cc.run(dlopen_dlsym_test_code,
- args : g_module_lib_args,
- name : 'dlsym() preceding underscores')
- if host_system == 'windows' or rres.returncode() == 0
- g_module_need_uscore = 1
- endif
- else
- message('Cross-compiling: assuming that symbols aren\'t prefixed with underscore')
- g_module_need_uscore = 0
- endif
-
- if cc.has_function('dlerror', args : g_module_lib_args)
- g_module_have_dlerror = 1
- endif
+# FIXME: check for OSF1/5.0 RTLD_GLOBAL brokenness (is this still relevant?)
+if g_module_impl == 'G_MODULE_IMPL_DL' and cc.has_function('dlerror', args : g_module_lib_args)
+ g_module_have_dlerror = 1
endif
# Done, have we got an implementation?
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]