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
This commit is contained in:
Ryan Lortie 2013-01-14 23:24:53 -05:00
parent 7e00f38191
commit 5d42fdd068
10 changed files with 30 additions and 35 deletions

View File

@ -3570,6 +3570,7 @@ dnl
dnl Check for -fvisibility=hidden to determine if we can do GNU-style dnl Check for -fvisibility=hidden to determine if we can do GNU-style
dnl visibility attributes for symbol export control dnl visibility attributes for symbol export control
dnl dnl
GLIB_HIDDEN_VISIBILITY_CFLAGS=""
case "$host" in case "$host" in
*-*-mingw*) *-*-mingw*)
dnl on mingw32 we do -fvisibility=hidden and __declspec(dllexport) dnl on mingw32 we do -fvisibility=hidden and __declspec(dllexport)
@ -3592,10 +3593,11 @@ case "$host" in
AS_IF([test "${enable_fvisibility_hidden}" = "yes"], [ AS_IF([test "${enable_fvisibility_hidden}" = "yes"], [
AC_DEFINE([_GLIB_EXTERN], [__attribute__((visibility("default"))) extern], AC_DEFINE([_GLIB_EXTERN], [__attribute__((visibility("default"))) extern],
[defines how to decorate public symbols while building]) [defines how to decorate public symbols while building])
CFLAGS="${CFLAGS} -fvisibility=hidden" GLIB_HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden"
]) ])
;; ;;
esac esac
AC_SUBST(GLIB_HIDDEN_VISIBILITY_CFLAGS)
dnl Compiler flags; macro originates from systemd dnl Compiler flags; macro originates from systemd
dnl See https://bugzilla.gnome.org/show_bug.cgi?id=608953 dnl See https://bugzilla.gnome.org/show_bug.cgi?id=608953

View File

@ -501,6 +501,7 @@ install-data-local: install-ms-lib
uninstall-local: uninstall-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) \ libgio_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \
$(gio_win32_res_ldflag) \ $(gio_win32_res_ldflag) \
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
@ -508,7 +509,7 @@ libgio_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \
if OS_COCOA if OS_COCOA
# This is dumb. The ObjC source file should be properly named .m # 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 libgio_2_0_la_LDFLAGS += -Wl,-framework,Foundation
endif endif

View File

@ -1,18 +1,16 @@
#include "config.h"
#include <gio/gio.h> #include <gio/gio.h>
_GLIB_EXTERN void void
g_io_module_load (GIOModule *module) g_io_module_load (GIOModule *module)
{ {
} }
_GLIB_EXTERN void void
g_io_module_unload (GIOModule *module) g_io_module_unload (GIOModule *module)
{ {
} }
_GLIB_EXTERN char ** char **
g_io_module_query (void) g_io_module_query (void)
{ {
return NULL; return NULL;

View File

@ -360,6 +360,7 @@ pcre_lib = pcre/libpcre.la
pcre_inc = pcre_inc =
endif 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_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) libglib_2_0_la_DEPENDENCIES = libcharset/libcharset.la $(printf_la) @GIO@ @GSPAWN@ @PLATFORMDEP@ $(glib_win32_res) $(glib_def)

View File

@ -62,6 +62,7 @@ gmodule_win32_res = gmodule-win32-res.o
gmodule_win32_res_ldflag = -Wl,$(gmodule_win32_res) gmodule_win32_res_ldflag = -Wl,$(gmodule_win32_res)
endif endif
libgmodule_2_0_la_CFLAGS = $(AM_CFLAGS) $(GLIB_HIDDEN_VISIBILITY_CFLAGS)
libgmodule_2_0_la_SOURCES = gmodule.c libgmodule_2_0_la_SOURCES = gmodule.c
libgmodule_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \ libgmodule_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \
$(gmodule_win32_res_ldflag) \ $(gmodule_win32_res_ldflag) \

View File

@ -62,7 +62,7 @@ libgobject_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
-export-dynamic $(no_undefined) $(export_symbols) -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) libgobject_2_0_la_LIBADD = $(libglib) $(LIBFFI_LIBS)

View File

@ -60,6 +60,7 @@ gthread_win32_res = gthread-win32-res.o
gthread_win32_res_ldflag = -Wl,$(gthread_win32_res) gthread_win32_res_ldflag = -Wl,$(gthread_win32_res)
endif endif
libgthread_2_0_la_CFLAGS = $(AM_CFLAGS) $(GLIB_HIDDEN_VISIBILITY_CFLAGS)
libgthread_2_0_la_SOURCES = gthread-impl.c libgthread_2_0_la_SOURCES = gthread-impl.c
libgthread_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \ libgthread_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \
$(gthread_win32_res_ldflag) \ $(gthread_win32_res_ldflag) \

View File

@ -27,9 +27,6 @@
#undef G_DISABLE_ASSERT #undef G_DISABLE_ASSERT
#undef G_LOG_DOMAIN #undef G_LOG_DOMAIN
#include "config.h"
#include <glib.h>
#include <gmodule.h> #include <gmodule.h>
#include <stdlib.h> #include <stdlib.h>
@ -39,34 +36,33 @@ void g_clash_func (void);
void gplugin_say_boo_func (void); void gplugin_say_boo_func (void);
void gplugin_a_module_func (GModule *module); void gplugin_a_module_func (GModule *module);
_GLIB_EXTERN gchar* gplugin_a_state; G_MODULE_EXPORT gchar* gplugin_a_state;
gchar* gplugin_a_state;
_GLIB_EXTERN void G_MODULE_EXPORT void
gplugin_a_func (void) gplugin_a_func (void)
{ {
gplugin_a_state = "Hello world"; gplugin_a_state = "Hello world";
} }
_GLIB_EXTERN void G_MODULE_EXPORT void
gplugin_clash_func (void) gplugin_clash_func (void)
{ {
gplugin_a_state = "plugin clash"; gplugin_a_state = "plugin clash";
} }
_GLIB_EXTERN void G_MODULE_EXPORT void
g_clash_func (void) g_clash_func (void)
{ {
gplugin_a_state = "global clash"; gplugin_a_state = "global clash";
} }
_GLIB_EXTERN void G_MODULE_EXPORT void
gplugin_say_boo_func (void) gplugin_say_boo_func (void)
{ {
gplugin_a_state = "BOOH"; gplugin_a_state = "BOOH";
} }
_GLIB_EXTERN void G_MODULE_EXPORT void
gplugin_a_module_func (GModule *module) gplugin_a_module_func (GModule *module)
{ {
void *f = NULL; void *f = NULL;

View File

@ -27,12 +27,9 @@
#undef G_DISABLE_ASSERT #undef G_DISABLE_ASSERT
#undef G_LOG_DOMAIN #undef G_LOG_DOMAIN
#include "config.h"
#include <gmodule.h> #include <gmodule.h>
_GLIB_EXTERN gchar* gplugin_b_state; G_MODULE_EXPORT gchar* gplugin_b_state;
gchar* gplugin_b_state;
const gchar* g_module_check_init (GModule *module); const gchar* g_module_check_init (GModule *module);
void g_module_unload (GModule *module); void g_module_unload (GModule *module);
@ -42,7 +39,7 @@ void gplugin_clash_func (void);
void g_clash_func (void); void g_clash_func (void);
void gplugin_say_boo_func (void); void gplugin_say_boo_func (void);
_GLIB_EXTERN const gchar* G_MODULE_EXPORT const gchar*
g_module_check_init (GModule *module) g_module_check_init (GModule *module)
{ {
gplugin_b_state = "check-init"; gplugin_b_state = "check-init";
@ -50,31 +47,31 @@ g_module_check_init (GModule *module)
return NULL; return NULL;
} }
_GLIB_EXTERN void G_MODULE_EXPORT void
g_module_unload (GModule *module) g_module_unload (GModule *module)
{ {
gplugin_b_state = "unloaded"; gplugin_b_state = "unloaded";
} }
_GLIB_EXTERN void G_MODULE_EXPORT void
gplugin_b_func (void) gplugin_b_func (void)
{ {
gplugin_b_state = "Hello world"; gplugin_b_state = "Hello world";
} }
_GLIB_EXTERN void G_MODULE_EXPORT void
gplugin_clash_func (void) gplugin_clash_func (void)
{ {
gplugin_b_state = "plugin clash"; gplugin_b_state = "plugin clash";
} }
_GLIB_EXTERN void G_MODULE_EXPORT void
g_clash_func (void) g_clash_func (void)
{ {
gplugin_b_state = "global clash"; gplugin_b_state = "global clash";
} }
_GLIB_EXTERN void G_MODULE_EXPORT void
gplugin_say_boo_func (void) gplugin_say_boo_func (void)
{ {
gplugin_b_state = "BOOH"; gplugin_b_state = "BOOH";

View File

@ -27,16 +27,14 @@
#undef G_DISABLE_ASSERT #undef G_DISABLE_ASSERT
#undef G_LOG_DOMAIN #undef G_LOG_DOMAIN
#include "config.h"
#include <gmodule.h> #include <gmodule.h>
#include <string.h> #include <string.h>
gchar* global_state; 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) g_clash_func (void)
{ {
global_state = "global clash"; global_state = "global clash";