[glib] Use a real test for G_HAVE_GNUC_VISIBILITY
- From: LRN <ruslanizhb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Use a real test for G_HAVE_GNUC_VISIBILITY
- Date: Wed, 28 Mar 2018 11:56:35 +0000 (UTC)
commit a9c65317d30dc1acacdcf4846b4d61e93ccf5e25
Author: Руслан Ижбулатов <lrn1986 gmail com>
Date: Fri Mar 23 18:26:01 2018 +0000
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
glib/glibconfig.h.in | 2 +-
meson.build | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 1 deletion(-)
---
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'
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]