From d40459c280b28cfe84f7e590b7d10d344661df2d Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Thu, 13 Oct 2022 20:49:11 -0400 Subject: [PATCH] Simplify G_HAVE_GNUC_VISIBILITY definition There is no need of compiler checks, GNUC visibility should be used when __GNUC__ >= 4 but not on Windows. --- glib/glibconfig.h.in | 1 - glib/gmacros.h | 4 ++++ meson.build | 35 ----------------------------------- 3 files changed, 4 insertions(+), 36 deletions(-) diff --git a/glib/glibconfig.h.in b/glib/glibconfig.h.in index ffedee1d2..0632e0b2f 100644 --- a/glib/glibconfig.h.in +++ b/glib/glibconfig.h.in @@ -129,7 +129,6 @@ 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 diff --git a/glib/gmacros.h b/glib/gmacros.h index d4e5124cf..2ef7587ce 100644 --- a/glib/gmacros.h +++ b/glib/gmacros.h @@ -1190,6 +1190,10 @@ #define G_UNLIKELY(expr) (expr) #endif +#if __GNUC__ >= 4 && !defined(_WIN32) && !defined(__CYGWIN__) +#define G_HAVE_GNUC_VISIBILITY 1 +#endif + /* GLIB_CANNOT_IGNORE_DEPRECATIONS is defined above for compilers that do not * have a way to temporarily suppress deprecation warnings. In these cases, * suppress the deprecated attribute altogether (otherwise a simple #include diff --git a/meson.build b/meson.build index 43bb46832..4307c20dc 100644 --- a/meson.build +++ b/meson.build @@ -210,41 +210,6 @@ if host_system == 'windows' and cc.get_id() != 'msvc' and cc.get_id() != 'clang- glib_conf.set('_FILE_OFFSET_BITS', 64) 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 ("default"))) - f_default (void) - { - } - int main (void) - { - f_hidden(); - f_internal(); - 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'