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.
This commit is contained in:
Tim-Philipp Müller 2017-02-16 09:52:58 +00:00 committed by Matthias Clasen
parent 1224ff0c39
commit 2f29ee1735
9 changed files with 13 additions and 11 deletions

View File

@ -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,

View File

@ -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)

View File

@ -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)

View File

@ -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,

View File

@ -44,7 +44,7 @@ libpcre = static_library('pcre',
'-UBSR_ANYCRLF',
'-UEBCDIC',
'-DGLIB_COMPILATION'
]
] + glib_hidden_visibility_args
)
pcre = declare_dependency(link_with : libpcre)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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