diff --git a/glib/glibconfig.h.in b/glib/glibconfig.h.in index fb456a972..2bf6c43c1 100644 --- a/glib/glibconfig.h.in +++ b/glib/glibconfig.h.in @@ -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) diff --git a/meson.build b/meson.build index 9f08db92b..26689a6e4 100644 --- a/meson.build +++ b/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'