[glib/meson-for-merge] meson: add -fvisibility=hidden explicitly to selected targets



commit 2f29ee1735fe83e65505c47e1a68630d9f7e1032
Author: Tim-Philipp Müller <tim centricular com>
Date:   Thu Feb 16 09:52:58 2017 +0000

    meson: add -fvisibility=hidden explicitly to selected targets
    
    Don't use it project-wide for building everything. Otherwise
    symbols for shared modules won't be exposed, e.g. in the
    resourceplugin used by the gio resource unit test.

 gio/meson.build             |    3 +++
 gio/xdgmime/meson.build     |    2 +-
 glib/libcharset/meson.build |    2 +-
 glib/meson.build            |    2 +-
 glib/pcre/meson.build       |    2 +-
 gmodule/meson.build         |    3 +--
 gobject/meson.build         |    2 +-
 gthread/meson.build         |    3 +--
 meson.build                 |    5 +++--
 9 files changed, 13 insertions(+), 11 deletions(-)
---
diff --git a/gio/meson.build b/gio/meson.build
index 8535d07..c889900 100644
--- a/gio/meson.build
+++ b/gio/meson.build
@@ -4,6 +4,8 @@ gio_c_args = [
   '-DGIO_MODULE_DIR="@0@"'.format(glib_giomodulesdir),
 ]
 
+gio_c_args += glib_hidden_visibility_args
+
 # FIXME: Install empty glib_giomodulesdir
 
 gnetworking_h_conf = configuration_data()
@@ -747,6 +749,7 @@ gio_tool_sources = [
   'gio-tool-tree.c',
 ]
 
+# FIXME: are all these HAVE_CONFIG_H needed/used here?
 executable('gio', gio_tool_sources,
   install : true,
   c_args : ['-DHAVE_CONFIG_H=1'] + gio_c_args,
diff --git a/gio/xdgmime/meson.build b/gio/xdgmime/meson.build
index d32d83e..128d70d 100644
--- a/gio/xdgmime/meson.build
+++ b/gio/xdgmime/meson.build
@@ -13,4 +13,4 @@ xdgmime_lib = static_library('xdgmime',
   sources : xdgmime_sources,
   include_directories : [configinc],
   pic : true,
-  c_args : [ '-DHAVE_CONFIG_H', '-DXDG_PREFIX=_gio_xdg' ])
+  c_args : [ '-DHAVE_CONFIG_H', '-DXDG_PREFIX=_gio_xdg' ] + glib_hidden_visibility_args)
diff --git a/glib/libcharset/meson.build b/glib/libcharset/meson.build
index a53f639..e926f21 100644
--- a/glib/libcharset/meson.build
+++ b/glib/libcharset/meson.build
@@ -1,4 +1,4 @@
 charset_lib = static_library('charset', 'localcharset.c',
   include_directories : configinc,
   pic : true,
-  c_args : [ '-DLIBDIR="@0@"'.format(get_option('libdir')) ])
+  c_args : [ '-DLIBDIR="@0@"'.format(get_option('libdir')) ] + glib_hidden_visibility_args)
diff --git a/glib/meson.build b/glib/meson.build
index e531d1e..3872262 100644
--- a/glib/meson.build
+++ b/glib/meson.build
@@ -218,7 +218,7 @@ libglib = shared_library('glib-2.0',
   include_directories : configinc,
   link_with : charset_lib,
   dependencies : [pcre, thread_dep, libintl, librt] + libiconv + platform_deps,
-  c_args : ['-DG_LOG_DOMAIN="GLib"', '-DGLIB_COMPILATION', '-DPCRE_STATIC']
+  c_args : ['-DG_LOG_DOMAIN="GLib"', '-DGLIB_COMPILATION', '-DPCRE_STATIC'] + glib_hidden_visibility_args
 )
 
 libglib_dep = declare_dependency(link_with : libglib,
diff --git a/glib/pcre/meson.build b/glib/pcre/meson.build
index 56aecc8..5152ecd 100644
--- a/glib/pcre/meson.build
+++ b/glib/pcre/meson.build
@@ -44,7 +44,7 @@ libpcre = static_library('pcre',
     '-UBSR_ANYCRLF',
     '-UEBCDIC',
     '-DGLIB_COMPILATION'
-  ]
+  ] + glib_hidden_visibility_args
 )
 
 pcre = declare_dependency(link_with : libpcre)
diff --git a/gmodule/meson.build b/gmodule/meson.build
index 188b178..191bca2 100644
--- a/gmodule/meson.build
+++ b/gmodule/meson.build
@@ -91,8 +91,7 @@ libgmodule = shared_library('gmodule-2.0',
   install : true,
   include_directories : [configinc, gmoduleinc],
   dependencies : [libdl_dep, libglib_dep],
-  c_args : ['-DG_LOG_DOMAIN="GModule"', '-DG_DISABLE_DEPRECATED'],
-)
+  c_args : ['-DG_LOG_DOMAIN="GModule"', '-DG_DISABLE_DEPRECATED'] + glib_hidden_visibility_args)
 
 libgmodule_dep = declare_dependency(link_with : libgmodule,
   include_directories : gmoduleinc)
diff --git a/gobject/meson.build b/gobject/meson.build
index 043e15d..49f707a 100644
--- a/gobject/meson.build
+++ b/gobject/meson.build
@@ -61,7 +61,7 @@ libgobject = shared_library('gobject-2.0',
   install : true,
   include_directories : [configinc],
   dependencies : [libffi_dep, libglib_dep],
-  c_args : ['-DG_LOG_DOMAIN="GLib-GObject"', '-DGOBJECT_COMPILATION'])
+  c_args : ['-DG_LOG_DOMAIN="GLib-GObject"', '-DGOBJECT_COMPILATION'] + glib_hidden_visibility_args)
 
 libgobject_dep = declare_dependency(link_with : libgobject,
   include_directories : gobjectinc)
diff --git a/gthread/meson.build b/gthread/meson.build
index 1efe1e3..8ccac33 100644
--- a/gthread/meson.build
+++ b/gthread/meson.build
@@ -6,5 +6,4 @@ libgthread = shared_library('gthread-2.0',
   soversion : soversion,
   install : true,
   dependencies : [libglib_dep],
-  c_args : ['-DG_LOG_DOMAIN="GThread"' ],
-)
+  c_args : ['-DG_LOG_DOMAIN="GThread"' ] + glib_hidden_visibility_args)
diff --git a/meson.build b/meson.build
index 248daa1..3cbc7f0 100644
--- a/meson.build
+++ b/meson.build
@@ -99,6 +99,7 @@ if host_system == 'windows'
 endif
 
 # Detect and set symbol visibility
+glib_hidden_visibility_args = []
 if get_option('default_library') != 'static'
   if host_system == 'windows'
     glib_conf.set('DLL_EXPORT', true)
@@ -106,11 +107,11 @@ if get_option('default_library') != 'static'
       glib_conf.set('_GLIB_EXTERN', '__declspec(dllexport) extern')
     elif cc.has_argument('-fvisibility=hidden')
       glib_conf.set('_GLIB_EXTERN', '__attribute__((visibility("default"))) __declspec(dllexport) extern')
-      add_global_arguments('-fvisibility=hidden', language : 'c')
+      glib_hidden_visibility_args = ['-fvisibility=hidden']
     endif
   elif cc.has_argument('-fvisibility=hidden')
     glib_conf.set('_GLIB_EXTERN', '__attribute__((visibility("default"))) extern')
-    add_global_arguments('-fvisibility=hidden', language : 'c')
+    glib_hidden_visibility_args = ['-fvisibility=hidden']
   endif
 endif
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]