[gobject-introspection] build: Export Symbols Using Compiler Directives



commit d281b07c4aba18d30c4365ef3cba2df85ac4ab6f
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Mon Jul 7 18:04:14 2014 +0800

    build: Export Symbols Using Compiler Directives
    
    Use compiler directives for exporting symbols for the build of
    libgirepository and also for the test libraries, like what is now done
    in GLib and GTK+ so that maintaining a separate .symbols (and .def files)
    would not be needed, in which the correct compiler directive is determined
    during configure time.  Drop all the .def files and the .symbols file as
    we would not be using them anymore.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=732669

 Makefile-girepository.am           |   15 +-
 Makefile-msvcproj.am               |    1 -
 build/win32/Makefile.am            |   11 -
 build/win32/Regress.def            |  272 -----------------
 build/win32/annotation.def         |   48 ---
 build/win32/everything.def         |  106 -------
 build/win32/foo.def                |   48 ---
 build/win32/gettype.def            |    6 -
 build/win32/gimarshallingtests.def |  588 ------------------------------------
 build/win32/gtkfrob.def            |    2 -
 build/win32/sletter.def            |    4 -
 build/win32/testinherit.def        |    6 -
 build/win32/utility.def            |    4 -
 configure.ac                       |   33 ++
 girepository/girepository.symbols  |  197 ------------
 tests/Makefile.am                  |    2 +-
 tests/offsets/Makefile.am          |    2 +-
 17 files changed, 46 insertions(+), 1299 deletions(-)
---
diff --git a/Makefile-girepository.am b/Makefile-girepository.am
index 19db3e0..8a857d6 100644
--- a/Makefile-girepository.am
+++ b/Makefile-girepository.am
@@ -44,7 +44,11 @@ libgirepository_internals_la_SOURCES =                               \
        girepository/girwriter.c                                \
        girepository/girwriter.h
 
-libgirepository_internals_la_CFLAGS = $(GIREPO_CFLAGS) -I$(top_srcdir)/girepository
+libgirepository_internals_la_CFLAGS =  \
+       $(GIREPO_CFLAGS)        \
+       $(GI_HIDDEN_VISIBILITY_CFLAGS)  \
+       -I$(top_srcdir)/girepository
+
 libgirepository_internals_la_LIBADD = libgirepository-gthash.la $(GIREPO_LIBS)
 
 libgirepository_1_0_la_SOURCES =                       \
@@ -73,12 +77,15 @@ libgirepository_1_0_la_SOURCES =                    \
        girepository/giunioninfo.c                      \
        girepository/givfuncinfo.c
 
-libgirepository_1_0_la_CPPFLAGS = $(GIREPO_CFLAGS) -I$(top_srcdir)/girepository -DG_IREPOSITORY_COMPILATION
+libgirepository_1_0_la_CPPFLAGS =      \
+       $(GIREPO_CFLAGS)        \
+       $(GI_HIDDEN_VISIBILITY_CFLAGS)  \
+       -I$(top_srcdir)/girepository    \
+       -DG_IREPOSITORY_COMPILATION
 libgirepository_1_0_la_LIBADD = libgirepository-gthash.la $(GIREPO_LIBS)
 libgirepository_1_0_la_LDFLAGS = \
        $(EXTRA_LINK_FLAGS) \
-       -no-undefined -version-number 1:0:0 \
-       -export-symbols $(srcdir)/girepository/girepository.symbols
+       -no-undefined -version-number 1:0:0
 
 gdumpdir = $(datadir)/gobject-introspection-1.0/
 gdump_DATA = girepository/gdump.c
diff --git a/Makefile-msvcproj.am b/Makefile-msvcproj.am
index 6e5b796..cdfbd48 100644
--- a/Makefile-msvcproj.am
+++ b/Makefile-msvcproj.am
@@ -199,7 +199,6 @@ GENERATED_MSVC_FILES =      \
        config.h.win32
 
 EXTRA_DIST +=  \
-       ./girepository/girepository.symbols     \
        $(GENERATED_MSVC_FILES)
 
 CLEANFILES += $(GENERATED_MSVC_FILES)
diff --git a/build/win32/Makefile.am b/build/win32/Makefile.am
index cfebe0c..31f582f 100644
--- a/build/win32/Makefile.am
+++ b/build/win32/Makefile.am
@@ -4,14 +4,3 @@ SUBDIRS =      \
        vs11    \
        vs12
 
-EXTRA_DIST = \
-       annotation.def  \
-       everything.def  \
-       foo.def \
-       gettype.def     \
-       gimarshallingtests.def  \
-       gtkfrob.def     \
-       Regress.def     \
-       sletter.def     \
-       testinherit.def \
-       utility.def
diff --git a/configure.ac b/configure.ac
index b863220..5add902 100644
--- a/configure.ac
+++ b/configure.ac
@@ -292,6 +292,39 @@ AC_SUBST(GLIBSRC)
 AC_MSG_RESULT([$GLIBSRC])
 
 dnl
+dnl Check for -fvisibility=hidden to determine if we can do GNU-style
+dnl visibility attributes for symbol export control
+dnl
+GI_HIDDEN_VISIBILITY_CFLAGS=""
+case "$host" in
+  *-*-mingw*)
+    dnl on mingw32 we do -fvisibility=hidden and __declspec(dllexport)
+    AC_DEFINE([_GI_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([_GI_EXTERN], [__attribute__((visibility("default"))) extern],
+                [defines how to decorate public symbols while building])
+      GI_HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden"
+    ])
+    ;;
+esac
+AC_SUBST(GI_HIDDEN_VISIBILITY_CFLAGS)
+
+dnl
 dnl Check for -Bsymbolic-functions linker flag used to avoid
 dnl intra-library PLT jumps, if available.
 dnl
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8bcf74e..adeba76 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -6,7 +6,7 @@ EXTRA_DIST=
 BUILT_SOURCES=
 CLEANFILES=
 
-AM_CFLAGS = $(GOBJECT_CFLAGS)
+AM_CFLAGS = $(GOBJECT_CFLAGS) $(GI_HIDDEN_VISIBILITY_CFLAGS)
 LIBADD = $(GOBJECT_LIBS)
 
 testsdir = $(datadir)/gobject-introspection-1.0/tests
diff --git a/tests/offsets/Makefile.am b/tests/offsets/Makefile.am
index a3ec78b..9608ad0 100644
--- a/tests/offsets/Makefile.am
+++ b/tests/offsets/Makefile.am
@@ -16,7 +16,7 @@ EXTRA_LTLIBRARIES += liboffsets.la
 liboffsets_la_SOURCES = \
        offsets.h       \
        offsets.c
-liboffsets_la_CPPFLAGS = $(GIREPO_CFLAGS)
+liboffsets_la_CPPFLAGS = $(GIREPO_CFLAGS) $(GI_HIDDEN_VISIBILITY_CFLAGS)
 # dummy rpath to get built dynamically (huh?)
 liboffsets_la_LDFLAGS = -avoid-version -rpath $(libdir)
 


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