mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-23 18:52:09 +01:00
Use -fvisibility=hidden by default on Unix
Now that we have all symbols annotated as GLIB_PUBLIC, we can switch the build to default to hiding symbols. The major advantage of this is that it's much harder to accidentally leak symbols. This patch only adds it to CFLAGS for the sublibraries; we don't want to affect things like gio/fam, nor the executables. However, this patch only changes Unix - on Windows, we keep the .symbols file because we still ultimately need a .def file in order to generate a .dll. To unify both Unix and Windows again, we need to do what cairo does and parse the headers at build time. https://bugzilla.gnome.org/show_bug.cgi?id=688681
This commit is contained in:
parent
0b2cafb2b0
commit
5195ddefba
17
configure.ac
17
configure.ac
@ -858,6 +858,12 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if defined(__SUNPRO_C) || (__SUNPRO_C >= 0
|
||||
AC_MSG_RESULT($g_have_sunstudio_visibility)
|
||||
AM_CONDITIONAL(HAVE_SUNSTUDIO_VISIBILITY, [test x$g_have_sunstudio_visibility = xyes])
|
||||
|
||||
dnl See https://bugzilla.gnome.org/show_bug.cgi?id=688681
|
||||
dnl First half of symbol visibility; search for "Second half of symbol
|
||||
dnl visibility" below to find the second part.
|
||||
AS_IF([test x$g_have_gnuc_visibility = x && test x$g_have_sunstudio_visibility = x], [
|
||||
AC_MSG_ERROR([GLib does not know how to control symbol visibility on this platform])])
|
||||
|
||||
# check for bytesex stuff
|
||||
AC_C_BIGENDIAN
|
||||
if test x$ac_cv_c_bigendian = xuniversal ; then
|
||||
@ -3532,6 +3538,17 @@ fi
|
||||
|
||||
AC_SUBST(GLIB_LINK_FLAGS)
|
||||
|
||||
dnl See https://bugzilla.gnome.org/show_bug.cgi?id=688681
|
||||
dnl Second half of symbol visibility; search for "First half of symbol
|
||||
dnl visibility" above to find the first part. They are separated for
|
||||
dnl the same reason the -Werror bits below are last - so we don't affect
|
||||
dnl any autoconf tests.
|
||||
GLIB_HIDDEN_VISIBILITY_CFLAGS=""
|
||||
AS_IF([test x$GCC = xyes], [GLIB_HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden"],
|
||||
[test x$g_have_sunstudio_visibility != x], [GLIB_HIDDEN_VISIBILITY_CFLAGS="-xldscope=hidden"],
|
||||
[AC_MSG_ERROR([GLib does not know how to make symbols hidden by default with this compiler])])
|
||||
AC_SUBST(GLIB_HIDDEN_VISIBILITY_CFLAGS)
|
||||
|
||||
dnl Compiler flags; macro originates from systemd
|
||||
dnl See https://bugzilla.gnome.org/show_bug.cgi?id=608953
|
||||
CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
|
||||
|
@ -10,6 +10,8 @@ SUBDIRS += xdgmime
|
||||
endif
|
||||
|
||||
if OS_WIN32_AND_DLL_COMPILATION
|
||||
gio_def = gio.def
|
||||
export_symbols = -export-symbols $(gio_def)
|
||||
if MS_LIB_AVAILABLE
|
||||
noinst_DATA = gio-2.0.lib
|
||||
|
||||
@ -507,18 +509,19 @@ install-data-local: install-ms-lib install-def-file
|
||||
|
||||
uninstall-local: uninstall-ms-lib uninstall-def-file
|
||||
|
||||
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) \
|
||||
-export-dynamic $(no_undefined) -export-symbols gio.def
|
||||
-export-dynamic $(no_undefined) $(export_symbols)
|
||||
|
||||
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
|
||||
|
||||
libgio_2_0_la_DEPENDENCIES = $(gio_win32_res) gio.def $(platform_deps)
|
||||
libgio_2_0_la_DEPENDENCIES = $(gio_win32_res) $(gio_def) $(platform_deps)
|
||||
|
||||
gio-win32-res.o: gio.rc
|
||||
$(WINDRES) gio.rc $@
|
||||
|
@ -90,6 +90,8 @@ BUILT_EXTRA_DIST = \
|
||||
lib_LTLIBRARIES = libglib-2.0.la
|
||||
|
||||
if OS_WIN32_AND_DLL_COMPILATION
|
||||
glib_def = glib.def
|
||||
export_symbols = -export-symbols $(glib_def)
|
||||
if MS_LIB_AVAILABLE
|
||||
noinst_DATA = glib-2.0.lib
|
||||
|
||||
@ -365,13 +367,14 @@ 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
|
||||
libglib_2_0_la_DEPENDENCIES = libcharset/libcharset.la $(printf_la) @GIO@ @GSPAWN@ @PLATFORMDEP@ $(glib_win32_res) $(glib_def)
|
||||
|
||||
libglib_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \
|
||||
$(glib_win32_res_ldflag) \
|
||||
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
|
||||
-export-dynamic $(no_undefined) -export-symbols glib.def
|
||||
-export-dynamic $(no_undefined) $(export_symbols)
|
||||
|
||||
INSTALL_PROGS=
|
||||
|
||||
|
@ -65,6 +65,8 @@ no_undefined = -no-undefined
|
||||
endif
|
||||
|
||||
if OS_WIN32_AND_DLL_COMPILATION
|
||||
gmodule_def = gmodule.def
|
||||
export_symbols = -export-symbols $(gmodule_def)
|
||||
gmodule_win32_res = gmodule-win32-res.o
|
||||
gmodule_win32_res_ldflag = -Wl,$(gmodule_win32_res)
|
||||
|
||||
@ -78,12 +80,13 @@ install-def-file:
|
||||
uninstall-def-file:
|
||||
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) \
|
||||
$(G_MODULE_LDFLAGS) \
|
||||
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
|
||||
-export-dynamic $(no_undefined) -export-symbols gmodule.def
|
||||
-export-dynamic $(no_undefined) $(export_symbols)
|
||||
|
||||
libgmodule_2_0_la_LIBADD = $(G_MODULE_LIBS_EXTRA) $(G_MODULE_LIBS) $(libglib)
|
||||
|
||||
|
@ -30,6 +30,8 @@ libglib = $(top_builddir)/glib/libglib-2.0.la
|
||||
lib_LTLIBRARIES = libgobject-2.0.la
|
||||
|
||||
if OS_WIN32_AND_DLL_COMPILATION
|
||||
gobject_def = gobject.def
|
||||
export_symbols = -export-symbols $(gobject_def)
|
||||
if MS_LIB_AVAILABLE
|
||||
noinst_DATA = gobject-2.0.lib
|
||||
|
||||
@ -67,13 +69,13 @@ libgobjectincludedir = $(includedir)/glib-2.0/gobject
|
||||
libgobject_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \
|
||||
$(gobject_win32_res_ldflag) \
|
||||
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
|
||||
-export-dynamic $(no_undefined) -export-symbols gobject.def
|
||||
-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_DEPENDENCIES = $(gobject_win32_res) gobject.def
|
||||
libgobject_2_0_la_DEPENDENCIES = $(gobject_win32_res) $(gobject_def)
|
||||
|
||||
#
|
||||
# setup source file variables
|
||||
|
@ -28,6 +28,8 @@ top_builddir_full=`cd \$(top_builddir); pwd`
|
||||
lib_LTLIBRARIES = libgthread-2.0.la
|
||||
|
||||
if OS_WIN32_AND_DLL_COMPILATION
|
||||
gthread_def = gthread.def
|
||||
export_symbols = -export-symbols $(gthread_def)
|
||||
if MS_LIB_AVAILABLE
|
||||
noinst_DATA = gthread-2.0.lib
|
||||
|
||||
@ -62,15 +64,16 @@ 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) \
|
||||
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
|
||||
-export-dynamic $(no_undefined) -export-symbols gthread.def
|
||||
-export-dynamic $(no_undefined) $(export_symbols)
|
||||
|
||||
libgthread_2_0_la_LIBADD = $(G_THREAD_LIBS_EXTRA) $(G_THREAD_LIBS_FOR_GTHREAD) $(libglib)
|
||||
|
||||
libgthread_2_0_la_DEPENDENCIES = $(gthread_win32_res) gthread.def
|
||||
libgthread_2_0_la_DEPENDENCIES = $(gthread_win32_res) $(gthread_def)
|
||||
|
||||
gthread-win32-res.o: gthread.rc
|
||||
$(AM_V_GEN) $(WINDRES) gthread.rc $@
|
||||
|
Loading…
x
Reference in New Issue
Block a user