mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 07:26:15 +01:00
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
This commit is contained in:
parent
f13d3c075f
commit
2e7669f5cc
31
configure.ac
31
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], [\
|
||||
|
Loading…
Reference in New Issue
Block a user