Magnus Hagander wrote:
> > It turns out the problem is that port/pipe.c is compiled with 
> > -DFRONTEND and include/port/win32.h wraps the recv to 
> > pgwin32_recv macro in a #ifndef FRONTEND.  We've actually 
> > been using the WinSock recv function directly (verified with gcc -E).
> 
> That's definitly wrong. 
> Looks like this file needs a _srv version in the Makefile.  Bruce?

Wow!  That is disturbing.  I tried to minimize the affect of FRONTEND,
but obviously I never though about the affect on include files that use
FRONTEND.  Seems it is only Win32 that used FRONTEND in includes (except
for pg_wchar.h, which is used by libpq and already built independently).

> Just a thought - might this affect more things that rely on FRONTEND 
> defines in the headers? How bad would it be to just make libpgport build
> two complete sets of object files, one for server and one for frontend,
> instead of special-casing which files are rebuilt? 

The attached patch does exactly what you suggest.  I think it has to be
patched to 8.0.X, 8.1.X, and HEAD.  I will apply in 24-48 hours.

-- 
  Bruce Momjian   http://candle.pha.pa.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: src/port/Makefile
===================================================================
RCS file: /cvsroot/pgsql/src/port/Makefile,v
retrieving revision 1.30
diff -c -c -r1.30 Makefile
*** src/port/Makefile   9 Dec 2005 21:19:36 -0000       1.30
--- src/port/Makefile   7 May 2006 01:05:32 -0000
***************
*** 26,37 ****
  override CPPFLAGS := -I$(top_builddir)/src/port -DFRONTEND $(CPPFLAGS)
  LIBS += $(PTHREAD_LIBS)
  
! # Replace object files that use FRONTEND define
! LIBOBJS_SRV := $(LIBOBJS)
! LIBOBJS_SRV := $(patsubst dirmod.o,dirmod_srv.o, $(LIBOBJS_SRV))
! LIBOBJS_SRV := $(patsubst exec.o,exec_srv.o, $(LIBOBJS_SRV))
! LIBOBJS_SRV := $(patsubst getaddrinfo.o,getaddrinfo_srv.o, $(LIBOBJS_SRV))
! LIBOBJS_SRV := $(patsubst thread.o,thread_srv.o, $(LIBOBJS_SRV))
  
  all: libpgport.a libpgport_srv.a
  
--- 26,33 ----
  override CPPFLAGS := -I$(top_builddir)/src/port -DFRONTEND $(CPPFLAGS)
  LIBS += $(PTHREAD_LIBS)
  
! # Replace all object files so they use FRONTEND define
! LIBOBJS_SRV := $(LIBOBJS:%.o=%_srv.o)
  
  all: libpgport.a libpgport_srv.a
  
***************
*** 60,72 ****
  libpgport_srv.a: $(LIBOBJS_SRV)
        $(AR) $(AROPT) $@ $^
  
! dirmod_srv.o: dirmod.c
!       $(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@
! 
! exec_srv.o: exec.c
!       $(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@
! 
! getaddrinfo_srv.o: getaddrinfo.c
        $(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@
  
  # No thread flags for server version
--- 56,62 ----
  libpgport_srv.a: $(LIBOBJS_SRV)
        $(AR) $(AROPT) $@ $^
  
! %_srv.o: %.c
        $(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@
  
  # No thread flags for server version
---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Reply via email to