[libsoup] Properly handle the visibility of the methods



commit e849cc10b9d61ae3749bc0d498c29dcf252d90e3
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Tue Oct 27 08:45:30 2015 +0100

    Properly handle the visibility of the methods
    
    https://bugzilla.gnome.org/show_bug.cgi?id=757146

 configure.ac                  |   33 +++
 libsoup/Makefile.am           |   24 +--
 libsoup/libsoup-2.4.sym       |  567 -----------------------------------------
 libsoup/libsoup-gnome-2.4.sym |    5 -
 4 files changed, 39 insertions(+), 590 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 582ed49..7ddd039 100644
--- a/configure.ac
+++ b/configure.ac
@@ -340,6 +340,39 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
                -Werror=declaration-after-statement"
 fi
 
+##################################################
+# Visibility handling
+##################################################
+
+SOUP_HIDDEN_VISIBILITY_CFLAGS=""
+case "$host" in
+    *-*-mingw*)
+        dnl on mingw32 we do -fvisibility=hidden and __declspec(dllexport)
+        AC_DEFINE([_SOUP_EXTERN], [__attribute__((visibility("default"))) __declspec(dllexport) extern],
+                  [defines how to decorate public symbols while building])
+        SOUP_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([_SOUP_EXTERN], [__attribute__((visibility("default"))) extern],
+                      [defines how to decorate public symbols while building])
+            SOUP_HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden"
+        ])
+        ;;
+esac
+AC_SUBST(SOUP_HIDDEN_VISIBILITY_CFLAGS)
+
 dnl *************************
 dnl *** Output Everything ***
 dnl *************************
diff --git a/libsoup/Makefile.am b/libsoup/Makefile.am
index 2f8079c..235ef50 100644
--- a/libsoup/Makefile.am
+++ b/libsoup/Makefile.am
@@ -86,14 +86,14 @@ nodist_libsoupinclude_HEADERS =     \
 
 lib_LTLIBRARIES = libsoup-2.4.la
 
+libsoup_2_4_la_CFLAGS = $(AM_CFLAGS) $(SOUP_HIDDEN_VISIBILITY_CFLAGS)
+
 libsoup_2_4_la_LDFLAGS =       \
        -version-info $(SOUP_CURRENT):$(SOUP_REVISION):$(SOUP_AGE) \
        -no-undefined \
-       -export-symbols $(srcdir)/libsoup-2.4.sym \
+       -export-dynamic \
        $(CODE_COVERAGE_LDFLAGS)
 
-EXTRA_DIST += libsoup-2.4.sym
-
 libsoup_2_4_la_LIBADD =                        \
        $(GLIB_LIBS)                    \
        $(LIBWS2_32)                    \
@@ -221,12 +221,12 @@ libsoupgnomeinclude_HEADERS =     \
 
 lib_LTLIBRARIES += libsoup-gnome-2.4.la
 
+libsoup_gnome_2_4_la_CFLAGS = $(AM_CFLAGS) $(SOUP_HIDDEN_VISIBILITY_CFLAGS)
+
 libsoup_gnome_2_4_la_LDFLAGS = \
        -version-info $(SOUP_CURRENT):$(SOUP_REVISION):$(SOUP_AGE) \
        -no-undefined \
-       -export-symbols $(srcdir)/libsoup-gnome-2.4.sym
-
-EXTRA_DIST += libsoup-gnome-2.4.sym
+       -export-dynamic
 
 libsoup_gnome_2_4_la_LIBADD =          \
        libsoup-2.4.la                  \
@@ -322,15 +322,3 @@ typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
 CLEANFILES+= $(gir_DATA) $(typelib_DATA) $(BUILT_SOURCES)
 
 endif
-
-# We only do this check on Linux, so we don't have to worry about
-# different "nm" output on other platforms
-if OS_LINUX
-check-local:
-       @echo Checking libsoup-2.4.so symbols
-       @nm $(builddir)/.libs/libsoup-2.4.so | \
-               grep "^[[:xdigit:]]\+ [BGTRS] " | \
-               sed "s/^[[:xdigit:]]\+ [BGTRS] //" | \
-               env LC_ALL=C sort -u | \
-               diff -U0 $(srcdir)/libsoup-2.4.sym - >&2
-endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]