build: Make .symbols file canonical on all platforms

Previously:
* On Unix, an -export-symbol-regex (g_)|(glib_) was used, and the .symbols
  files were used in "make check"
* On Windows, the .symbols files are massaged into a format which MSVC
  expects as an export list

Now:

* On both Unix and Windows, the .symbols file is used as the list of
  symbols to export, and code to generate the exported list per
  platform is unified.  Even symbols starting with g_ are not exported
  unless they are in the file.  The abicheck.sh tools are deleted.

https://bugzilla.gnome.org/show_bug.cgi?id=688681
This commit is contained in:
Colin Walters
2012-11-19 16:51:51 -05:00
parent 3e5214c15c
commit a2a8127338
12 changed files with 76 additions and 118 deletions

View File

@@ -209,16 +209,6 @@ AS_IF([test "$glib_native_win32" = "yes"], [
])
AM_CONDITIONAL(MS_LIB_AVAILABLE, [test x$ms_librarian = xyes])
if test "$glib_native_win32" != yes; then
# libtool option to control which symbols are exported
# right now, symbols starting with _ are not exported
LIBTOOL_EXPORT_OPTIONS='-export-symbols-regex "^g.*"'
else
# We currently use .def files on Windows
LIBTOOL_EXPORT_OPTIONS=
fi
AC_SUBST(LIBTOOL_EXPORT_OPTIONS)
AS_IF([test "x$glib_have_carbon" = "xyes"], [
AC_DEFINE(HAVE_CARBON, 1, [define to 1 if Carbon is available])
LDFLAGS="$LDFLAGS -Wl,-framework,Carbon"

View File

@@ -1,6 +1,7 @@
include $(top_srcdir)/Makefile.decl
NULL =
BUILT_SOURCES =
SUBDIRS = gdbus-2.0/codegen
@@ -23,15 +24,8 @@ install-ms-lib:
uninstall-ms-lib:
$(uninstall_ms_lib_cmd)
gio.def: gio.symbols
$(AM_V_GEN) (echo EXPORTS; $(CPP) -P -DINCLUDE_VARIABLES -DINCLUDE_INTERNAL_SYMBOLS -DG_OS_WIN32 -DALL_FILES - <$(srcdir)/gio.symbols | sed -e '/^$$/d' -e 's/^/ /' -e 's/G_GNUC_[^ ]*//g' | sort) > $(builddir)/gio.def.tmp && \
mv $(builddir)/gio.def.tmp $(builddir)/gio.def
if OS_LINUX
if HAVE_GNUC_VISIBILITY
TESTS = abicheck.sh
endif
endif
gio.def: gio.symbols $(top_builddir)/glib/glibconfig.h $(top_srcdir)/glib/process-symbol-file.sh Makefile
$(AM_V_GEN) env GLIB_DEBUG_FLAGS="$(GLIB_DEBUG_FLAGS)" $(top_srcdir)/glib/process-symbol-file.sh $< $@
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"GLib-GIO\" \
@@ -493,9 +487,6 @@ no_undefined = -no-undefined
endif
if OS_WIN32_AND_DLL_COMPILATION
export_symbols = -export-symbols $(builddir)/gio.def
gio_def = gio.def
gio_win32_res = gio-win32-res.o
gio_win32_res_ldflag = -Wl,$(gio_win32_res)
@@ -507,8 +498,6 @@ uninstall-def-file:
else
install-def-file:
uninstall-def-file:
export_symbols = $(LIBTOOL_EXPORT_OPTIONS)
endif
install-data-local: install-ms-lib install-def-file
@@ -519,7 +508,7 @@ uninstall-local: uninstall-ms-lib uninstall-def-file
libgio_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \
$(gio_win32_res_ldflag) \
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
-export-dynamic $(no_undefined) $(export_symbols)
-export-dynamic $(no_undefined) -export-symbols gio.def
if OS_COCOA
# This is dumb. The ObjC source file should be properly named .m
@@ -527,7 +516,7 @@ libgio_2_0_la_CFLAGS = -xobjective-c
libgio_2_0_la_LDFLAGS += -Wl,-framework,Foundation
endif
libgio_2_0_la_DEPENDENCIES = $(gio_win32_res) $(gio_def) $(platform_deps)
libgio_2_0_la_DEPENDENCIES = $(gio_win32_res) gio.def $(platform_deps)
gio-win32-res.o: gio.rc
$(WINDRES) gio.rc $@
@@ -637,7 +626,7 @@ gioinclude_HEADERS = \
gioenumtypes.h
# these sources (also mentioned above) are generated.
BUILT_SOURCES = \
BUILT_SOURCES += \
gconstructor_as_data.h \
gioenumtypes.h \
gioenumtypes.c \
@@ -651,7 +640,6 @@ EXTRA_DIST += \
gioenumtypes.h.template \
gioenumtypes.c.template \
makefile.msc \
abicheck.sh \
gio.rc.in \
gschema.dtd \
gconstructor_as_data.h \

View File

@@ -1,13 +0,0 @@
#! /bin/sh
egrep '^#([^i]|if).*[^\]$' "${top_builddir:-..}/glib/glibconfig.h" > glibconfig.cpp
INCLUDES="-include ${top_builddir:-..}/config.h"
INCLUDES="$INCLUDES -include glibconfig.cpp"
cpp -P $INCLUDES ${srcdir:-.}/gio.symbols | sed -e '/^$/d' -e 's/ PRIVATE$//' | sort > expected-abi
rm glibconfig.cpp
nm -D -g --defined-only .libs/libgio-2.0.so | cut -d ' ' -f 3 | egrep -v '^(__bss_start|_edata|_end)' | sort > actual-abi
diff -u expected-abi actual-abi && rm expected-abi actual-abi

View File

@@ -49,15 +49,8 @@ AM_CPPFLAGS = \
-DGLIB_COMPILATION \
-DPCRE_STATIC
glib.def: glib.symbols
$(AM_V_GEN) (echo EXPORTS; $(CPP) -P -DG_OS_WIN32 - <$(srcdir)/glib.symbols | sed -e '/^$$/d' -e 's/^/ /') > $(builddir)/glib.def
if OS_LINUX
if HAVE_GNUC_VISIBILITY
TESTS_ENVIRONMENT = GLIB_DEBUG_FLAGS="$(GLIB_DEBUG_FLAGS)"
TESTS = abicheck.sh
endif
endif
glib.def: glib.symbols $(top_builddir)/glib/glibconfig.h $(top_srcdir)/glib/process-symbol-file.sh Makefile
$(AM_V_GEN) env GLIB_DEBUG_FLAGS="$(GLIB_DEBUG_FLAGS)" $(top_srcdir)/glib/process-symbol-file.sh $< $@
MIRRORING_TAB_SOURCE = \
glib-mirroring-tab/Makefile \
@@ -74,7 +67,7 @@ EXTRA_DIST += \
gen-unicode-tables.pl \
gen-script-table.pl \
glibconfig.h.win32.in \
abicheck.sh \
process-symbol-file.sh \
glib.symbols \
gregex.c \
gregex.h \
@@ -349,13 +342,9 @@ no_undefined = -no-undefined
endif
if OS_WIN32_AND_DLL_COMPILATION
export_symbols = -export-symbols $(builddir)/glib.def
glib_win32_res = glib-win32-res.o
glib_win32_res_ldflag = -Wl,$(glib_win32_res)
glib_def = glib.def
install-def-file:
$(INSTALL) $(builddir)/glib.def $(DESTDIR)$(libdir)/glib-2.0.def
@@ -364,8 +353,6 @@ uninstall-def-file:
else
install-def-file:
uninstall-def-file:
export_symbols = $(LIBTOOL_EXPORT_OPTIONS)
endif
if USE_SYSTEM_PCRE
@@ -377,12 +364,12 @@ pcre_inc =
endif
libglib_2_0_la_LIBADD = libcharset/libcharset.la $(printf_la) @GIO@ @GSPAWN@ @PLATFORMDEP@ @ICONV_LIBS@ @G_LIBS_EXTRA@ $(pcre_lib) $(G_THREAD_LIBS_EXTRA) $(G_THREAD_LIBS_FOR_GTHREAD)
libglib_2_0_la_DEPENDENCIES = libcharset/libcharset.la $(printf_la) @GIO@ @GSPAWN@ @PLATFORMDEP@ $(glib_win32_res) $(glib_def)
libglib_2_0_la_DEPENDENCIES = libcharset/libcharset.la $(printf_la) @GIO@ @GSPAWN@ @PLATFORMDEP@ $(glib_win32_res) glib.def
libglib_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \
$(glib_win32_res_ldflag) \
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
-export-dynamic $(no_undefined) $(export_symbols)
-export-dynamic $(no_undefined) -export-symbols glib.def
INSTALL_PROGS=

View File

@@ -1,13 +0,0 @@
#! /bin/sh
egrep '^#([^i]|if).*[^\]$' "${builddir:-.}/glibconfig.h" > glibconfig.cpp
INCLUDES="-include ${top_builddir:-..}/config.h"
INCLUDES="$INCLUDES -include glibconfig.cpp $GLIB_DEBUG_FLAGS"
cpp -P -DG_STDIO_NO_WRAP_ON_UNIX $INCLUDES "${srcdir:-.}/glib.symbols" | sed -e '/^$/d' -e 's/ PRIVATE$//' | sort > expected-abi
rm -f glibconfig.cpp
nm -D -g --defined-only .libs/libglib-2.0.so | cut -d ' ' -f 3 | egrep -v '^(__bss_start|_edata|_end)' | sort > actual-abi
diff -u expected-abi actual-abi && rm -f expected-abi actual-abi

44
glib/process-symbol-file.sh Executable file
View File

@@ -0,0 +1,44 @@
#!/bin/sh
# Process a .symbol file which is a list of symbols, one per line,
# with C preprocessor conditionals. Some symbols maybe suffixed
# PRIVATE, which is ignored on Unix.
set -e
SYMBOLFILE=$1
OUTPUT=$2
usage () {
echo "$0: usage: [--win32] SYMBOLFILE OUTPUT"
exit 1
}
test -n "$SYMBOLFILE" || usage
test -n "$OUTPUT" || usage
egrep '^#([^i]|if).*[^\]$' "${top_builddir:-..}/glib/glibconfig.h" > glibconfig.cpp
if egrep '^#define G_OS_WIN32' glibconfig.cpp; then
win32_mode=true
else
win32_mode=false
fi
INCLUDES="-include ${top_builddir:-..}/config.h"
INCLUDES="$INCLUDES -include glibconfig.cpp $GLIB_DEBUG_FLAGS"
rm -f $OUTPUT.tmp
touch $OUTPUT.tmp
if $win32_mode; then
INCLUDES="$INCLUDES -DG_OS_WIN32"
SED_ARG='s/^/ /'
echo EXPORTS >> $OUTPUT.tmp
else
INCLUDES="$INCLUDES -DG_STDIO_NO_WRAP_ON_UNIX"
SED_ARG='s/ PRIVATE$//'
fi
cpp -P $INCLUDES $SYMBOLFILE | sed -e '/^$/d' -e "$SED_ARG" >> $OUTPUT.tmp && mv $OUTPUT.tmp $OUTPUT
rm -f glibconfig.cpp

View File

@@ -1,6 +1,8 @@
## Process this file with automake to produce Makefile.in
include $(top_srcdir)/Makefile.decl
BUILT_SOURCES =
AM_CPPFLAGS = \
$(glib_INCLUDES) \
-DG_LOG_DOMAIN=\"GModule\" \
@@ -8,7 +10,7 @@ AM_CPPFLAGS = \
-DG_DISABLE_DEPRECATED
gmodule.def: gmodule.symbols
$(AM_V_GEN) (echo EXPORTS; $(CPP) -P - <$(srcdir)/gmodule.symbols | sed -e '/^$$/d' -e 's/^/ /') > $(builddir)/gmodule.def
$(AM_V_GEN) env GLIB_DEBUG_FLAGS="$(GLIB_DEBUG_FLAGS)" $(top_srcdir)/glib/process-symbol-file.sh $< $@
EXTRA_DIST += \
makefile.msc.in \
@@ -28,7 +30,7 @@ BUILT_EXTRA_DIST = \
makefile.msc \
gmodule.rc
BUILT_SOURCES = gmoduleconf.h
BUILT_SOURCES += gmoduleconf.h
gmoduleconf.h: gmoduleconf.h.in
glibincludedir=$(includedir)/glib-2.0
@@ -61,9 +63,6 @@ no_undefined = -no-undefined
endif
if OS_WIN32_AND_DLL_COMPILATION
export_symbols = -export-symbols $(builddir)/gmodule.def
gmodule_def = gmodule.def
gmodule_win32_res = gmodule-win32-res.o
gmodule_win32_res_ldflag = -Wl,$(gmodule_win32_res)
@@ -82,11 +81,11 @@ libgmodule_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \
$(gmodule_win32_res_ldflag) \
$(G_MODULE_LDFLAGS) \
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
-export-dynamic $(no_undefined) $(export_symbols)
-export-dynamic $(no_undefined) -export-symbols gmodule.def
libgmodule_2_0_la_LIBADD = $(G_MODULE_LIBS_EXTRA) $(G_MODULE_LIBS) $(libglib)
libgmodule_2_0_la_DEPENDENCIES = $(gmodule_win32_res) $(gmodule_def)
libgmodule_2_0_la_DEPENDENCIES = $(gmodule_win32_res) gmodule.def
gmodule-win32-res.o: gmodule.rc
$(AM_V_GEN) $(WINDRES) gmodule.rc $@

View File

@@ -18,14 +18,8 @@ AM_CPPFLAGS = \
$(GLIB_DEBUG_FLAGS) \
-DGOBJECT_COMPILATION
gobject.def: gobject.symbols
$(AM_V_GEN) (echo EXPORTS; $(CPP) -P -DINCLUDE_VARIABLES -DINCLUDE_INTERNAL_SYMBOLS -DG_OS_WIN32 -DALL_FILES - <$(srcdir)/gobject.symbols | $(SED) -e '/^$$/d' -e 's/^/ /' -e 's/G_GNUC_[^ ]*//g' | sort) > $(builddir)/gobject.def
if OS_LINUX
if HAVE_GNUC_VISIBILITY
TESTS = abicheck.sh
endif
endif
gobject.def: gobject.symbols $(top_builddir)/glib/glibconfig.h $(top_srcdir)/glib/process-symbol-file.sh Makefile
$(AM_V_GEN) env GLIB_DEBUG_FLAGS="$(GLIB_DEBUG_FLAGS)" $(top_srcdir)/glib/process-symbol-file.sh $< $@
libglib = $(top_builddir)/glib/libglib-2.0.la
@@ -52,9 +46,6 @@ no_undefined = -no-undefined
endif
if OS_WIN32_AND_DLL_COMPILATION
export_symbols = -export-symbols $(builddir)/gobject.def
gobject_def = gobject.def
gobject_win32_res = gobject-win32-res.o
gobject_win32_res_ldflag = -Wl,$(gobject_win32_res)
@@ -66,8 +57,6 @@ uninstall-def-file:
else
install-def-file:
uninstall-def-file:
export_symbols = $(LIBTOOL_EXPORT_OPTIONS)
endif
# libtool stuff: set version and export symbols for resolving
@@ -75,13 +64,13 @@ libgobjectincludedir = $(includedir)/glib-2.0/gobject
libgobject_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \
$(gobject_win32_res_ldflag) \
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
-export-dynamic $(no_undefined) $(export_symbols)
-export-dynamic $(no_undefined) -export-symbols gobject.def
libgobject_2_0_la_CFLAGS = $(LIBFFI_CFLAGS)
libgobject_2_0_la_LIBADD = $(libglib) $(LIBFFI_LIBS)
libgobject_2_0_la_DEPENDENCIES = $(gobject_win32_res) $(gobject_def)
libgobject_2_0_la_DEPENDENCIES = $(gobject_win32_res) gobject.def
#
# setup source file variables
@@ -232,8 +221,7 @@ EXTRA_DIST += \
makefile.msc.in \
gobject.rc.in \
libgobject-gdb.py.in \
glib-mkenums.in \
abicheck.sh
glib-mkenums.in
CLEANFILES += libgobject-gdb.py

View File

@@ -1,13 +0,0 @@
#! /bin/sh
egrep '^#([^i]|if).*[^\]$' "${top_builddir:-..}/glib/glibconfig.h" > glibconfig.cpp
INCLUDES="-include ${top_builddir:-..}/config.h"
INCLUDES="$INCLUDES -include glibconfig.cpp"
cpp -DINCLUDE_VARIABLES -P $INCLUDES ${srcdir:-.}/gobject.symbols | sed -e '/^$/d' -e 's/ PRIVATE$//' | sort > expected-abi
rm glibconfig.cpp
nm -D -g --defined-only .libs/libgobject-2.0.so | cut -d ' ' -f 3 | egrep -v '^(__bss_start|_edata|_end)' | sort > actual-abi
diff -u expected-abi actual-abi && rm expected-abi actual-abi

View File

@@ -7,9 +7,12 @@ AM_CPPFLAGS = \
@GTHREAD_COMPILE_IMPL_DEFINES@ \
@GLIB_DEBUG_FLAGS@
gthread.def: gthread.symbols $(top_builddir)/glib/glibconfig.h $(top_srcdir)/glib/process-symbol-file.sh Makefile
$(AM_V_GEN) env GLIB_DEBUG_FLAGS="$(GLIB_DEBUG_FLAGS)" $(top_srcdir)/glib/process-symbol-file.sh $< $@
EXTRA_DIST += \
makefile.msc.in \
gthread.def \
gthread.symbols \
gthread.rc.in
BUILT_EXTRA_DIST = \
@@ -42,9 +45,6 @@ no_undefined = -no-undefined
endif
if OS_WIN32_AND_DLL_COMPILATION
export_symbols = -export-symbols $(srcdir)/gthread.def
gthread_def = gthread.def
install-def-file:
$(INSTALL) $(srcdir)/gthread.def $(DESTDIR)$(libdir)/gthread-2.0.def
@@ -64,11 +64,11 @@ libgthread_2_0_la_SOURCES = gthread-impl.c
libgthread_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \
$(gthread_win32_res_ldflag) \
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
-export-dynamic $(no_undefined) $(export_symbols)
-export-dynamic $(no_undefined) -export-symbols gthread.def
libgthread_2_0_la_LIBADD = $(G_THREAD_LIBS_EXTRA) $(G_THREAD_LIBS_FOR_GTHREAD) $(libglib)
libgthread_2_0_la_DEPENDENCIES = $(gthread_win32_res) $(gthread_def)
libgthread_2_0_la_DEPENDENCIES = $(gthread_win32_res) gthread.def
gthread-win32-res.o: gthread.rc
$(AM_V_GEN) $(WINDRES) gthread.rc $@

View File

@@ -1,3 +1,2 @@
EXPORTS
g_thread_init
g_thread_init_with_errorcheck_mutexes

2
gthread/gthread.symbols Normal file
View File

@@ -0,0 +1,2 @@
g_thread_init
g_thread_init_with_errorcheck_mutexes