summaryrefslogtreecommitdiff
path: root/recipes/glib
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2018-05-27 15:51:58 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2018-05-27 15:51:58 +0530
commit281f46238b2be4f7fce666dc5e3a19bfffcd3b84 (patch)
treeea232abc90118b4e40cbc005a1f3d41b8345c571 /recipes/glib
parent3b88d522b66e277aca380dc89ebc2a0afd9d5c8c (diff)
glib.recipe: Correctly detect G_HAVE_GNUC_VISIBILITY
Already fixed in master, this fixes compiler warnings about visibility attributes in the headers.
Diffstat (limited to 'recipes/glib')
-rw-r--r--recipes/glib/0001-Use-a-real-test-for-G_HAVE_GNUC_VISIBILITY.patch95
1 files changed, 95 insertions, 0 deletions
diff --git a/recipes/glib/0001-Use-a-real-test-for-G_HAVE_GNUC_VISIBILITY.patch b/recipes/glib/0001-Use-a-real-test-for-G_HAVE_GNUC_VISIBILITY.patch
new file mode 100644
index 00000000..173b7b46
--- /dev/null
+++ b/recipes/glib/0001-Use-a-real-test-for-G_HAVE_GNUC_VISIBILITY.patch
@@ -0,0 +1,95 @@
+From a9c65317d30dc1acacdcf4846b4d61e93ccf5e25 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?=
+ =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= <lrn1986@gmail.com>
+Date: Fri, 23 Mar 2018 18:26:01 +0000
+Subject: [PATCH] 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'
+--
+2.17.0
+