summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2013-01-14 23:24:53 -0500
committerRyan Lortie <desrt@desrt.ca>2013-01-14 23:31:59 -0500
commit5d42fdd068bddaaf7e42b7aaca2c15e931ebf3c5 (patch)
treec0d7a9e960a1ad6dbb522818ee9b04e54c8cf18c
parent7e00f381916cab6ba13f1d430310802cf6b9c726 (diff)
visibility: Use a separate CFLAGS variable
We only want to control the default visibility for our five main installable libraries: libglib, libgthread, libgmodule, libgobject, libgio. We should therefore only set -fvisibility=hidden when building those. Use a separate substitution variable for this purpose. Using CFLAGS directly leads to some modules built in testcases not exporting their symbols (and then the tests fail). It also affects the fam file monitoring module. Colin had originally done it this way in his visibility patch series but I failed to understand why so I didn't copy it. Now I do. Also: revert changes made to two testcases in an attempt to work around this issue. https://bugzilla.gnome.org/show_bug.cgi?id=691756
-rw-r--r--configure.ac4
-rw-r--r--gio/Makefile.am3
-rw-r--r--gio/tests/resourceplugin.c8
-rw-r--r--glib/Makefile.am1
-rw-r--r--gmodule/Makefile.am1
-rw-r--r--gobject/Makefile.am2
-rw-r--r--gthread/Makefile.am1
-rw-r--r--tests/libmoduletestplugin_a.c20
-rw-r--r--tests/libmoduletestplugin_b.c19
-rw-r--r--tests/module-test.c6
10 files changed, 30 insertions, 35 deletions
diff --git a/configure.ac b/configure.ac
index 9e48f9079..eb9a5050d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3570,6 +3570,7 @@ dnl
dnl Check for -fvisibility=hidden to determine if we can do GNU-style
dnl visibility attributes for symbol export control
dnl
+GLIB_HIDDEN_VISIBILITY_CFLAGS=""
case "$host" in
*-*-mingw*)
dnl on mingw32 we do -fvisibility=hidden and __declspec(dllexport)
@@ -3592,10 +3593,11 @@ case "$host" in
AS_IF([test "${enable_fvisibility_hidden}" = "yes"], [
AC_DEFINE([_GLIB_EXTERN], [__attribute__((visibility("default"))) extern],
[defines how to decorate public symbols while building])
- CFLAGS="${CFLAGS} -fvisibility=hidden"
+ GLIB_HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden"
])
;;
esac
+AC_SUBST(GLIB_HIDDEN_VISIBILITY_CFLAGS)
dnl Compiler flags; macro originates from systemd
dnl See https://bugzilla.gnome.org/show_bug.cgi?id=608953
diff --git a/gio/Makefile.am b/gio/Makefile.am
index b4edecf59..7d6f91591 100644
--- a/gio/Makefile.am
+++ b/gio/Makefile.am
@@ -501,6 +501,7 @@ install-data-local: install-ms-lib
uninstall-local: uninstall-ms-lib
+libgio_2_0_la_CFLAGS = $(AM_CFLAGS) $(GLIB_HIDDEN_VISIBILITY_CFLAGS)
libgio_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \
$(gio_win32_res_ldflag) \
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
@@ -508,7 +509,7 @@ libgio_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \
if OS_COCOA
# This is dumb. The ObjC source file should be properly named .m
-libgio_2_0_la_CFLAGS = -xobjective-c
+libgio_2_0_la_CFLAGS += -xobjective-c
libgio_2_0_la_LDFLAGS += -Wl,-framework,Foundation
endif
diff --git a/gio/tests/resourceplugin.c b/gio/tests/resourceplugin.c
index 9e3b7048e..b66d54142 100644
--- a/gio/tests/resourceplugin.c
+++ b/gio/tests/resourceplugin.c
@@ -1,18 +1,16 @@
-#include "config.h"
-
#include <gio/gio.h>
-_GLIB_EXTERN void
+void
g_io_module_load (GIOModule *module)
{
}
-_GLIB_EXTERN void
+void
g_io_module_unload (GIOModule *module)
{
}
-_GLIB_EXTERN char **
+char **
g_io_module_query (void)
{
return NULL;
diff --git a/glib/Makefile.am b/glib/Makefile.am
index 951d102e9..98c597801 100644
--- a/glib/Makefile.am
+++ b/glib/Makefile.am
@@ -360,6 +360,7 @@ pcre_lib = pcre/libpcre.la
pcre_inc =
endif
+libglib_2_0_la_CFLAGS = $(AM_CFLAGS) $(GLIB_HIDDEN_VISIBILITY_CFLAGS)
libglib_2_0_la_LIBADD = libcharset/libcharset.la $(printf_la) @GIO@ @GSPAWN@ @PLATFORMDEP@ @ICONV_LIBS@ @G_LIBS_EXTRA@ $(pcre_lib) $(G_THREAD_LIBS_EXTRA) $(G_THREAD_LIBS_FOR_GTHREAD)
libglib_2_0_la_DEPENDENCIES = libcharset/libcharset.la $(printf_la) @GIO@ @GSPAWN@ @PLATFORMDEP@ $(glib_win32_res) $(glib_def)
diff --git a/gmodule/Makefile.am b/gmodule/Makefile.am
index 19737fa3f..92b844a41 100644
--- a/gmodule/Makefile.am
+++ b/gmodule/Makefile.am
@@ -62,6 +62,7 @@ gmodule_win32_res = gmodule-win32-res.o
gmodule_win32_res_ldflag = -Wl,$(gmodule_win32_res)
endif
+libgmodule_2_0_la_CFLAGS = $(AM_CFLAGS) $(GLIB_HIDDEN_VISIBILITY_CFLAGS)
libgmodule_2_0_la_SOURCES = gmodule.c
libgmodule_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \
$(gmodule_win32_res_ldflag) \
diff --git a/gobject/Makefile.am b/gobject/Makefile.am
index 24143f780..615a78030 100644
--- a/gobject/Makefile.am
+++ b/gobject/Makefile.am
@@ -62,7 +62,7 @@ libgobject_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
-export-dynamic $(no_undefined) $(export_symbols)
-libgobject_2_0_la_CFLAGS = $(LIBFFI_CFLAGS)
+libgobject_2_0_la_CFLAGS = $(AM_CFLAGS) $(LIBFFI_CFLAGS) $(GLIB_HIDDEN_VISIBILITY_CFLAGS)
libgobject_2_0_la_LIBADD = $(libglib) $(LIBFFI_LIBS)
diff --git a/gthread/Makefile.am b/gthread/Makefile.am
index 325fec44a..2aa507827 100644
--- a/gthread/Makefile.am
+++ b/gthread/Makefile.am
@@ -60,6 +60,7 @@ gthread_win32_res = gthread-win32-res.o
gthread_win32_res_ldflag = -Wl,$(gthread_win32_res)
endif
+libgthread_2_0_la_CFLAGS = $(AM_CFLAGS) $(GLIB_HIDDEN_VISIBILITY_CFLAGS)
libgthread_2_0_la_SOURCES = gthread-impl.c
libgthread_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \
$(gthread_win32_res_ldflag) \
diff --git a/tests/libmoduletestplugin_a.c b/tests/libmoduletestplugin_a.c
index 3ce43dad0..69fdd0f70 100644
--- a/tests/libmoduletestplugin_a.c
+++ b/tests/libmoduletestplugin_a.c
@@ -27,11 +27,8 @@
#undef G_DISABLE_ASSERT
#undef G_LOG_DOMAIN
-#include "config.h"
-
-#include <glib.h>
-#include <gmodule.h>
-#include <stdlib.h>
+#include <gmodule.h>
+#include <stdlib.h>
void gplugin_a_func (void);
void gplugin_clash_func (void);
@@ -39,34 +36,33 @@ void g_clash_func (void);
void gplugin_say_boo_func (void);
void gplugin_a_module_func (GModule *module);
-_GLIB_EXTERN gchar* gplugin_a_state;
-gchar* gplugin_a_state;
+G_MODULE_EXPORT gchar* gplugin_a_state;
-_GLIB_EXTERN void
+G_MODULE_EXPORT void
gplugin_a_func (void)
{
gplugin_a_state = "Hello world";
}
-_GLIB_EXTERN void
+G_MODULE_EXPORT void
gplugin_clash_func (void)
{
gplugin_a_state = "plugin clash";
}
-_GLIB_EXTERN void
+G_MODULE_EXPORT void
g_clash_func (void)
{
gplugin_a_state = "global clash";
}
-_GLIB_EXTERN void
+G_MODULE_EXPORT void
gplugin_say_boo_func (void)
{
gplugin_a_state = "BOOH";
}
-_GLIB_EXTERN void
+G_MODULE_EXPORT void
gplugin_a_module_func (GModule *module)
{
void *f = NULL;
diff --git a/tests/libmoduletestplugin_b.c b/tests/libmoduletestplugin_b.c
index 11e3ccfe1..26cc33fc9 100644
--- a/tests/libmoduletestplugin_b.c
+++ b/tests/libmoduletestplugin_b.c
@@ -27,12 +27,9 @@
#undef G_DISABLE_ASSERT
#undef G_LOG_DOMAIN
-#include "config.h"
+#include <gmodule.h>
-#include <gmodule.h>
-
-_GLIB_EXTERN gchar* gplugin_b_state;
-gchar* gplugin_b_state;
+G_MODULE_EXPORT gchar* gplugin_b_state;
const gchar* g_module_check_init (GModule *module);
void g_module_unload (GModule *module);
@@ -42,7 +39,7 @@ void gplugin_clash_func (void);
void g_clash_func (void);
void gplugin_say_boo_func (void);
-_GLIB_EXTERN const gchar*
+G_MODULE_EXPORT const gchar*
g_module_check_init (GModule *module)
{
gplugin_b_state = "check-init";
@@ -50,31 +47,31 @@ g_module_check_init (GModule *module)
return NULL;
}
-_GLIB_EXTERN void
+G_MODULE_EXPORT void
g_module_unload (GModule *module)
{
gplugin_b_state = "unloaded";
}
-_GLIB_EXTERN void
+G_MODULE_EXPORT void
gplugin_b_func (void)
{
gplugin_b_state = "Hello world";
}
-_GLIB_EXTERN void
+G_MODULE_EXPORT void
gplugin_clash_func (void)
{
gplugin_b_state = "plugin clash";
}
-_GLIB_EXTERN void
+G_MODULE_EXPORT void
g_clash_func (void)
{
gplugin_b_state = "global clash";
}
-_GLIB_EXTERN void
+G_MODULE_EXPORT void
gplugin_say_boo_func (void)
{
gplugin_b_state = "BOOH";
diff --git a/tests/module-test.c b/tests/module-test.c
index 4b195d3f1..dd99b710f 100644
--- a/tests/module-test.c
+++ b/tests/module-test.c
@@ -27,16 +27,14 @@
#undef G_DISABLE_ASSERT
#undef G_LOG_DOMAIN
-#include "config.h"
-
#include <gmodule.h>
#include <string.h>
gchar* global_state;
-_GLIB_EXTERN void g_clash_func (void);
+G_MODULE_EXPORT void g_clash_func (void);
-_GLIB_EXTERN void
+G_MODULE_EXPORT void
g_clash_func (void)
{
global_state = "global clash";