mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-13 07:56:17 +01:00
Use a real test for G_HAVE_GNUC_VISIBILITY
Accurate G_HAVE_GNUC_VISIBILITY is needed to correctly define G_GNUC_INTERNAL later on. Autotools did that, meson currently doesn't and opts to just set G_HAVE_GNUC_VISIBILITY to 1 for all compilers except MSVC. This leads to MinGW GCC having G_HAVE_GNUC_VISIBILITY=1, which results in G_GNUC_INTERNAL being defined to __attribute__((visibility("hidden"))), which is not supported. Because cc.compiles() does not support override_options or anything like that, we just feed it '-Werror' as-is, since MSVC is known as not supporting visibility attributes anyway. https://bugzilla.gnome.org/show_bug.cgi?id=794636
This commit is contained in:
parent
6635922072
commit
a9c65317d3
@ -133,10 +133,10 @@ typedef unsigned @glib_intptr_type_define@ guintptr;
|
||||
#endif
|
||||
|
||||
#mesondefine G_HAVE_GROWING_STACK
|
||||
#mesondefine G_HAVE_GNUC_VISIBILITY
|
||||
|
||||
#ifndef _MSC_VER
|
||||
# define G_HAVE_GNUC_VARARGS 1
|
||||
# define G_HAVE_GNUC_VISIBILITY 1
|
||||
#endif
|
||||
|
||||
#if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
|
||||
|
41
meson.build
41
meson.build
@ -112,6 +112,47 @@ if host_system == 'windows'
|
||||
glib_conf.set('BROKEN_POLL', true)
|
||||
endif
|
||||
|
||||
# Check for GNU visibility attributes
|
||||
g_have_gnuc_visibility = cc.compiles('''
|
||||
void
|
||||
__attribute__ ((visibility ("hidden")))
|
||||
f_hidden (void)
|
||||
{
|
||||
}
|
||||
void
|
||||
__attribute__ ((visibility ("internal")))
|
||||
f_internal (void)
|
||||
{
|
||||
}
|
||||
void
|
||||
__attribute__ ((visibility ("protected")))
|
||||
f_protected (void)
|
||||
{
|
||||
}
|
||||
void
|
||||
__attribute__ ((visibility ("default")))
|
||||
f_default (void)
|
||||
{
|
||||
}
|
||||
int main (void)
|
||||
{
|
||||
f_hidden();
|
||||
f_internal();
|
||||
f_protected();
|
||||
f_default();
|
||||
return 0;
|
||||
}
|
||||
''',
|
||||
# Not supported by MSVC, but MSVC also won't support visibility,
|
||||
# so it's OK to pass -Werror explicitly. Replace with
|
||||
# override_options : 'werror=true' once that is supported
|
||||
args: ['-Werror'],
|
||||
name : 'GNU C visibility attributes test')
|
||||
|
||||
if g_have_gnuc_visibility
|
||||
glibconfig_conf.set('G_HAVE_GNUC_VISIBILITY', '1')
|
||||
endif
|
||||
|
||||
# Detect and set symbol visibility
|
||||
glib_hidden_visibility_args = []
|
||||
if get_option('default_library') != 'static'
|
||||
|
Loading…
Reference in New Issue
Block a user