[gspell] build: add visibility handling
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gspell] build: add visibility handling
- Date: Thu, 13 Apr 2017 17:36:02 +0000 (UTC)
commit 74d5a68cf3eabcc7a2cb3fef9848794f80fc23c9
Author: Sébastien Wilmet <swilmet gnome org>
Date: Thu Apr 13 18:38:26 2017 +0200
build: add visibility handling
The -export-dynamic LDFLAG was not sufficient.
Code copied from libsoup.
Running:
$ nm -D libgspell-1.so | grep T
before and after this commit shows that the only difference is that
gspell_get_resource() is no longer exported. It was exported by mistake,
it's for the internal GResources.
https://bugzilla.gnome.org/show_bug.cgi?id=761921
configure.ac | 31 +++++++++++++++++++++++++++++++
gspell/Makefile.am | 4 +++-
2 files changed, 34 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 23e0ef8..b93e0e8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -155,6 +155,37 @@ AX_CODE_COVERAGE
AX_REQUIRE_DEFINED([AX_VALGRIND_CHECK])
AX_VALGRIND_CHECK
+# Visibility handling
+# This requires that every gspell/*.c file #includes config.h.
+GSPELL_HIDDEN_VISIBILITY_CFLAGS=""
+case "$host" in
+ *-*-mingw*)
+ dnl on mingw32 we do -fvisibility=hidden and __declspec(dllexport)
+ AC_DEFINE([_GSPELL_EXTERN], [__attribute__((visibility("default"))) __declspec(dllexport) extern],
+ [defines how to decorate public symbols while building])
+ GSPELL_HIDDEN_VISIBILITY_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([_GSPELL_EXTERN], [__attribute__((visibility("default"))) extern],
+ [defines how to decorate public symbols while building])
+ GSPELL_HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden"
+ ])
+ ;;
+esac
+AC_SUBST(GSPELL_HIDDEN_VISIBILITY_CFLAGS)
+
# Check for Mac OS X platform
AC_MSG_CHECKING([for Mac OS X platform])
case "$host" in
diff --git a/gspell/Makefile.am b/gspell/Makefile.am
index 009bad7..88f6577 100644
--- a/gspell/Makefile.am
+++ b/gspell/Makefile.am
@@ -94,7 +94,8 @@ nodist_libgspell_core_la_SOURCES = \
libgspell_core_la_LIBADD = \
$(CODE_COVERAGE_LIBS)
-libgspell_core_la_CFLAGS = \
+libgspell_core_la_CFLAGS = \
+ $(GSPELL_HIDDEN_VISIBILITY_CFLAGS) \
$(CODE_COVERAGE_CFLAGS)
libgspell_core_la_LDFLAGS = \
@@ -113,6 +114,7 @@ libgspell_@GSPELL_API_VERSION@_la_LIBADD = \
$(CODE_COVERAGE_LIBS)
libgspell_@GSPELL_API_VERSION@_la_CFLAGS = \
+ $(GSPELL_HIDDEN_VISIBILITY_CFLAGS) \
$(CODE_COVERAGE_CFLAGS)
libgspell_@GSPELL_API_VERSION@_la_LDFLAGS = \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]