Re: static or dynamic libpgport - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: static or dynamic libpgport
Date
Msg-id 4EE6472A.70603@dunslane.net
Whole thread Raw
In response to Re: static or dynamic libpgport  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers

On 12/10/2011 08:26 PM, Tom Lane wrote:
>
>> The other
>> thing is we'd need to turn on flags that make the object suitable for a
>> dynamic library (e.g. -fpic).
> Right now, libpq laboriously rebuilds all the .o files it needs from
> src/port/ so as to get them with -fpic.  It would be nice if we could
> clean that up while we're doing this.  It might be all right to always
> build the client-side version of libpgport with -fpic, though I'd be sad
> if that leaked into the server-side build.
>

Here's a small diff that seems to build things the right way. No leakage 
of -fpic into the server side code. Still a deal of work to do, but it's 
a start.

Would we want to link our own non-backend executables against the shared 
lib? That would almost certainly break the buildfarm for Windows builds, 
as it only currently copies the libpq DLL into the bin directory. That's 
no reason on its own not to do it, of course, and there are only a 
couple of owners other than me anyway, so it would be easy to fix.

How do you want to proceed for libpq (and the ecpg library cases that do 
the same thing)? Just link in the object files directly?

cheers

andrew

*** Makefile    2011-12-03 17:21:59.944509111 -0500
--- GNUmakefile    2011-12-12 12:39:43.176260505 -0500
***************
*** 37,47 ****  # foo_srv.o and foo.o are both built from foo.c, but only foo.o has 
-DFRONTEND  OBJS_SRV = $(OBJS:%.o=%_srv.o)

! all: libpgport.a libpgport_srv.a

! # libpgport is needed by some contrib
! install: all installdirs
!     $(INSTALL_STLIB) libpgport.a '$(DESTDIR)$(libdir)/libpgport.a'
  installdirs:      $(MKDIR_P) '$(DESTDIR)$(libdir)'
--- 37,52 ----  # foo_srv.o and foo.o are both built from foo.c, but only foo.o has 
-DFRONTEND  OBJS_SRV = $(OBJS:%.o=%_srv.o)

! NAME = pgport
! SO_MAJOR_VERSION= 1
! SO_MINOR_VERSION= 1

! include $(top_srcdir)/src/Makefile.shlib
!
! all: all-lib libpgport_srv.a
!
! # libpgport is needed by any exe built with pgxs
! install: all installdirs install-lib
  installdirs:      $(MKDIR_P) '$(DESTDIR)$(libdir)'
***************
*** 49,57 ****  uninstall:      rm -f '$(DESTDIR)$(libdir)/libpgport.a'

- libpgport.a: $(OBJS)
-     $(AR) $(AROPT) $@ $^
-  # thread.o needs PTHREAD_CFLAGS (but thread_srv.o does not)  thread.o: thread.c      $(CC) $(CFLAGS) $(CPPFLAGS)
$(PTHREAD_CFLAGS)-c $<
 
--- 54,59 ----
***************
*** 64,70 ****      $(AR) $(AROPT) $@ $^
  %_srv.o: %.c
!     $(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@
  $(OBJS_SRV): | submake-errcodes

--- 66,72 ----      $(AR) $(AROPT) $@ $^
  %_srv.o: %.c
!     $(CC) $(subst $(CFLAGS_SL),,$(CFLAGS)) $(subst -DFRONTEND,, 
$(CPPFLAGS)) -c $< -o $@
  $(OBJS_SRV): | submake-errcodes

***************
*** 97,100 ****      echo "#define MANDIR \"$(mandir)\"" >>$@
  clean distclean maintainer-clean:
!     rm -f libpgport.a libpgport_srv.a $(OBJS) $(OBJS_SRV) 
pg_config_paths.h
--- 99,102 ----      echo "#define MANDIR \"$(mandir)\"" >>$@
  clean distclean maintainer-clean:
!     rm -f libpgport.so* libpgport.a libpgport_srv.a $(OBJS) 
$(OBJS_SRV) pg_config_paths.h



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Is anybody actually using XLR_BKP_REMOVABLE?
Next
From: Greg Smith
Date:
Subject: Re: Configuration include directory