Commit 1e7bb2da authored by Tom Lane's avatar Tom Lane

Arrange to strip libpq.so of symbols that aren't officially supposed to

be exported on Linux and Darwin.  We already did this on Windows but
that's not enough, as evidenced by the fact that libecpg had an unexpected
dependency on one such symbol.  We should try to do it on more platforms.
Fix ecpg's oversight, and bump libpq's major .so version number to reflect
the unwanted but nonetheless real ABI break.
parent 35a0601d
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
# Copyright (c) 1998, Regents of the University of California # Copyright (c) 1998, Regents of the University of California
# #
# IDENTIFICATION # IDENTIFICATION
# $PostgreSQL: pgsql/src/Makefile.shlib,v 1.103 2006/04/19 16:32:08 tgl Exp $ # $PostgreSQL: pgsql/src/Makefile.shlib,v 1.104 2006/04/28 02:53:20 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -107,11 +107,11 @@ ifeq ($(PORTNAME), darwin) ...@@ -107,11 +107,11 @@ ifeq ($(PORTNAME), darwin)
ifeq ($(DLTYPE), library) ifeq ($(DLTYPE), library)
# linkable library # linkable library
DLSUFFIX := .dylib DLSUFFIX := .dylib
LINK.shared = $(COMPILER) -dynamiclib -install_name $(libdir)/lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX) $(version_link) -multiply_defined suppress LINK.shared = $(COMPILER) -dynamiclib -install_name $(libdir)/lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX) $(version_link) $(exported_symbols_list) -multiply_defined suppress
else else
# loadable module (default case) # loadable module (default case)
DLSUFFIX := .so DLSUFFIX := .so
LINK.shared = $(COMPILER) -bundle LINK.shared = $(COMPILER) -bundle -multiply_defined suppress
endif endif
shlib = lib$(NAME).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)$(DLSUFFIX) shlib = lib$(NAME).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)$(DLSUFFIX)
shlib_major = lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX) shlib_major = lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX)
...@@ -186,7 +186,7 @@ ifeq ($(PORTNAME), irix) ...@@ -186,7 +186,7 @@ ifeq ($(PORTNAME), irix)
endif endif
ifeq ($(PORTNAME), linux) ifeq ($(PORTNAME), linux)
LINK.shared = $(COMPILER) -shared -Wl,-soname,$(soname) LINK.shared = $(COMPILER) -shared -Wl,-soname,$(soname) $(exported_symbols_list)
endif endif
ifeq ($(PORTNAME), solaris) ifeq ($(PORTNAME), solaris)
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# #
# Copyright (c) 1994, Regents of the University of California # Copyright (c) 1994, Regents of the University of California
# #
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.38 2006/01/17 19:49:23 meskes Exp $ # $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.39 2006/04/28 02:53:20 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -25,7 +25,7 @@ override CFLAGS += $(PTHREAD_CFLAGS) ...@@ -25,7 +25,7 @@ override CFLAGS += $(PTHREAD_CFLAGS)
LIBS := $(filter-out -lpgport, $(LIBS)) LIBS := $(filter-out -lpgport, $(LIBS))
OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \ OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \
connect.o misc.o path.o exec.o \ connect.o misc.o path.o exec.o thread.o \
$(filter snprintf.o, $(LIBOBJS)) $(filter snprintf.o, $(LIBOBJS))
SHLIB_LINK = -L../pgtypeslib -lpgtypes $(libpq) \ SHLIB_LINK = -L../pgtypeslib -lpgtypes $(libpq) \
...@@ -46,7 +46,7 @@ include $(top_srcdir)/src/Makefile.shlib ...@@ -46,7 +46,7 @@ include $(top_srcdir)/src/Makefile.shlib
# necessarily use the same object files as the backend uses. Instead, # necessarily use the same object files as the backend uses. Instead,
# symlink the source files in here and build our own object file. # symlink the source files in here and build our own object file.
path.c exec.c snprintf.c: % : $(top_srcdir)/src/port/% path.c exec.c snprintf.c thread.c: % : $(top_srcdir)/src/port/%
rm -f $@ && $(LN_S) $< . rm -f $@ && $(LN_S) $< .
path.o: path.c $(top_builddir)/src/port/pg_config_paths.h path.o: path.c $(top_builddir)/src/port/pg_config_paths.h
...@@ -62,7 +62,7 @@ installdirs: ...@@ -62,7 +62,7 @@ installdirs:
uninstall: uninstall-lib uninstall: uninstall-lib
clean distclean maintainer-clean: clean-lib clean distclean maintainer-clean: clean-lib
rm -f $(OBJS) path.c exec.c snprintf.c rm -f $(OBJS) path.c exec.c snprintf.c thread.c
depend dep: depend dep:
$(CC) -MM $(CFLAGS) *.c >depend $(CC) -MM $(CFLAGS) *.c >depend
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group # Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California # Portions Copyright (c) 1994, Regents of the University of California
# #
# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.143 2006/04/11 20:26:40 neilc Exp $ # $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.144 2006/04/28 02:53:20 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -16,8 +16,8 @@ include $(top_builddir)/src/Makefile.global ...@@ -16,8 +16,8 @@ include $(top_builddir)/src/Makefile.global
# shared library parameters # shared library parameters
NAME= pq NAME= pq
SO_MAJOR_VERSION= 4 SO_MAJOR_VERSION= 5
SO_MINOR_VERSION= 2 SO_MINOR_VERSION= 0
DLTYPE= library DLTYPE= library
override CPPFLAGS := -DFRONTEND -I$(srcdir) $(CPPFLAGS) -I$(top_builddir)/src/port override CPPFLAGS := -DFRONTEND -I$(srcdir) $(CPPFLAGS) -I$(top_builddir)/src/port
...@@ -125,6 +125,31 @@ $(srcdir)/blibpqdll.def: exports.txt ...@@ -125,6 +125,31 @@ $(srcdir)/blibpqdll.def: exports.txt
echo '; Aliases for MS compatible names' >> $@ echo '; Aliases for MS compatible names' >> $@
sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/ \1= _\1/' < $< | sed 's/ *$$//' >> $@ sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/ \1= _\1/' < $< | sed 's/ *$$//' >> $@
# Where possible, restrict the symbols exported by the library to just the
# official list, so as to avoid unintentional ABI changes. On recent Darwin
# this also quiets multiply-defined-symbol warnings in programs that use
# libpgport along with libpq.
ifeq ($(PORTNAME), darwin)
$(shlib): exports.list
exports.list: exports.txt
$(AWK) '/^[^#]/ {printf "_%s\n",$$1}' $< >$@
exported_symbols_list = -exported_symbols_list exports.list
endif
ifeq ($(PORTNAME), linux)
$(shlib): exports.list
exports.list: exports.txt
echo '{ global:' >$@
$(AWK) '/^[^#]/ {printf "%s;\n",$$1}' $< >>$@
echo ' local: *; };' >>$@
exported_symbols_list = -Wl,--version-script=exports.list
endif
# depend on Makefile.global to force rebuild on re-run of configure # depend on Makefile.global to force rebuild on re-run of configure
$(srcdir)/libpq.rc: libpq.rc.in $(top_builddir)/src/Makefile.global $(srcdir)/libpq.rc: libpq.rc.in $(top_builddir)/src/Makefile.global
sed -e 's/\(VERSION.*\),0 *$$/\1,'`date '+%y%j' | sed 's/^0*//'`'/' < $< > $@ sed -e 's/\(VERSION.*\),0 *$$/\1,'`date '+%y%j' | sed 's/^0*//'`'/' < $< > $@
...@@ -147,7 +172,7 @@ uninstall: uninstall-lib ...@@ -147,7 +172,7 @@ uninstall: uninstall-lib
rm -f '$(DESTDIR)$(includedir)/libpq-fe.h' '$(DESTDIR)$(includedir_internal)/libpq-int.h' '$(DESTDIR)$(includedir_internal)/pqexpbuffer.h' '$(DESTDIR)$(datadir)/pg_service.conf.sample' rm -f '$(DESTDIR)$(includedir)/libpq-fe.h' '$(DESTDIR)$(includedir_internal)/libpq-int.h' '$(DESTDIR)$(includedir_internal)/pqexpbuffer.h' '$(DESTDIR)$(datadir)/pg_service.conf.sample'
clean distclean: clean-lib clean distclean: clean-lib
rm -f $(OBJS) pg_config_paths.h crypt.c getaddrinfo.c inet_aton.c noblock.c pgstrcasecmp.c snprintf.c strerror.c open.c thread.c md5.c ip.c encnames.c wchar.c pthread.h rm -f $(OBJS) pg_config_paths.h crypt.c getaddrinfo.c inet_aton.c noblock.c pgstrcasecmp.c snprintf.c strerror.c open.c thread.c md5.c ip.c encnames.c wchar.c pthread.h exports.list
rm -f pg_config_paths.h # Might be left over from a Win32 client-only build rm -f pg_config_paths.h # Might be left over from a Win32 client-only build
maintainer-clean: distclean maintainer-clean: distclean
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment