[glib] configure.ac: change our visibility policy
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] configure.ac: change our visibility policy
- Date: Mon, 14 Jan 2013 04:00:29 +0000 (UTC)
commit 2e7669f5cc46927602108c328fbbeb846bd09218
Author: Ryan Lortie <desrt desrt ca>
Date: Thu Dec 6 13:42:06 2012 -0500
configure.ac: change our visibility policy
Check for -fvisibility=hidden as a supported CFLAG.
If it is supported, use it and emit an AC_DEFINE to change the meaning
of _GLIB_EXTERN to include the GNU attribute for marking symbols as
public: __attribute((visibility("default"))).
This will override the public definition of _GLIB_EXTERN for any file
which does #include "config.h" (forcing all our .c files to do so, as a
side effect).
If we're on mingw, assume that -fvisibility will work and also throw in
a __declspec(dllexport) for good measure. This will allow us to move
away from using a .def file to create the the various DLLs.
It's possible that there may be compilers that accept
-fvisibility=hidden but don't accept the GNU attribute for making
symbols public again -- we will hopefully receive bugs if any of those
exist.
https://bugzilla.gnome.org/show_bug.cgi?id=688681
configure.ac | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 5cb21df..9e48f90 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3566,6 +3566,37 @@ fi
AC_SUBST(GLIB_LINK_FLAGS)
+dnl
+dnl Check for -fvisibility=hidden to determine if we can do GNU-style
+dnl visibility attributes for symbol export control
+dnl
+case "$host" in
+ *-*-mingw*)
+ dnl on mingw32 we do -fvisibility=hidden and __declspec(dllexport)
+ AC_DEFINE([_GLIB_EXTERN], [__attribute__((visibility("default"))) __declspec(dllexport) extern],
+ [defines how to decorate public symbols while building])
+ CFLAGS="${CFLAGS} -fvisibility=hidden"
+ ;;
+ *)
+ dnl on other compilers, check if we can do -fvisibility=hidden
+ SAVED_CFLAGS="${CFLAGS}"
+ CFLAGS="-fvisibility=hidden"
+ AC_MSG_CHECKING([for -fvisibility=hidden compiler flag])
+ AC_TRY_COMPILE([], [int main (void) { return 0; }],
+ AC_MSG_RESULT(yes)
+ enable_fvisibility_hidden=yes,
+ AC_MSG_RESULT(no)
+ enable_fvisibility_hidden=no)
+ CFLAGS="${SAVED_CFLAGS}"
+
+ 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"
+ ])
+ ;;
+esac
+
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], [\
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]