The current version of the interfaces/libpgtcl/Makefile fails to build a
shared lib on platforms where the shlib needs to resolve symbols from 
the loading executable (tclsh) at link time. (only affects AIX?)

The current version of pl/tcl/Makefile fails to build on some platforms,
e.g. that use a packaged version of tcl that was built with a now
unavailable compiler or that need an exports file to build shlibs. 
The patch simplifies this Makefile considerably.

Makefile.shlib fails to clean correctly on some platforms.

I thus ask you again to consider applying this improved patch that fixes
above problems before RC1.
Else please keep it, to apply after release.

Thanks
Andreas
Wed, 9 Jan 2002 12:58:36 +0100
"Zeugswetter Andreas SB SD" <ZeugswetterA@spardat.at>
--with-tcl build on AIX (and others) fails
"Zeugswetter Andreas SB SD" <ZeugswetterA@spardat.at> writes:
> The current version of pl/tcl/Makefile fails to build on some platforms,
> e.g. that use a packaged version of tcl that was built with a now
> unavailable compiler or that need an exports file to build shlibs.
> The patch simplifies this Makefile considerably.

I don't think we dare risk a wholesale change in the way pltcl is built
for 7.2.  We're already through the ports testing process for 7.2, and
I don't want to start it over again.

This does look like the direction to go in for 7.3, however.  (I think
Peter had already muttered something about getting rid of the existing
pltcl build process in favor of using Makefile.shlib.)

As for the libpgtcl part of the patch, I don't understand why the Tcl
library should be linked into libpgtcl.  libpgtcl is supposed to be
loaded into a Tcl interpreter, not carry its own interpreter along with
it; but it sure looks like that's what will happen with this patch.

			regards, tom lane

Wed, 09 Jan 2002 11:05:10 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: --with-tcl build on AIX (and others) fails 
Saved for 7.3:

	http://candle.pha.pa.us/cgi-bin/pgpatches2

---------------------------------------------------------------------------

Zeugswetter Andreas SB SD wrote:
> 
> The current version of the interfaces/libpgtcl/Makefile fails to build a
> shared lib on platforms where the shlib needs to resolve symbols from 
> the loading executable (tclsh) at link time. (only affects AIX?)
> 
> The current version of pl/tcl/Makefile fails to build on some platforms,
> e.g. that use a packaged version of tcl that was built with a now
> unavailable compiler or that need an exports file to build shlibs. 
> The patch simplifies this Makefile considerably.
> 
> Makefile.shlib fails to clean correctly on some platforms.
> 
> I thus ask you again to consider applying this improved patch that fixes
> above problems before RC1.
> Else please keep it, to apply after release.
-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Wed, 9 Jan 2002 12:19:11 -0500 (EST)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: [HACKERS] --with-tcl build on AIX (and others) fails
I tried out the patch that Andreas sent in a couple weeks ago, and find
that as-is it fails on HPUX.  The attached version works okay on both
HPUX 10.20 and RH Linux 7.2, however.  Anyone want to try it on other
platforms?  (Note this only covers Andreas' proposed changes for pltcl,
not for libpgtcl.)

			regards, tom lane


*** src/Makefile.shlib.orig	Sun Nov 11 20:45:36 2001
--- src/Makefile.shlib	Sun Jan 20 17:03:25 2002
***************
*** 400,406 ****
  clean-lib:
  	rm -f lib$(NAME).a
  ifeq ($(enable_shared), yes)
! 	rm -f $(shlib) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) lib$(NAME)$(DLSUFFIX)
  endif
  ifeq ($(PORTNAME), win)
  	rm -rf $(NAME).def
--- 400,409 ----
  clean-lib:
  	rm -f lib$(NAME).a
  ifeq ($(enable_shared), yes)
! 	rm -f lib$(NAME)$(DLSUFFIX) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
! ifdef EXPSUFF
! 	rm -f lib$(NAME)$(EXPSUFF)
! endif
  endif
  ifeq ($(PORTNAME), win)
  	rm -rf $(NAME).def
*** src/pl/tcl/Makefile.orig	Sat Oct 13 00:23:50 2001
--- src/pl/tcl/Makefile	Sun Jan 20 17:20:56 2002
***************
*** 26,97 ****
  endif
  endif
  
! 
! # Change following to how shared library that contains references to
! # libtcl must get built on your system. Since these definitions come
! # from the tclConfig.sh script, they should work if the shared build
! # of tcl was successful on this system. However, tclConfig.sh lies to
! # us a little bit (at least in versions 7.6 through 8.0.4) --- it
! # doesn't mention -lc in TCL_LIBS, but you still need it on systems
! # that want to hear about dependent libraries...
  
  ifneq ($(TCL_SHLIB_LD_LIBS),)
  # link command for a shared lib must mention shared libs it uses
! SHLIB_EXTRA_LIBS=$(TCL_LIBS) -lc
  else
  ifeq ($(PORTNAME), hpux)
  # link command for a shared lib must mention shared libs it uses,
  # even though Tcl doesn't think so...
! SHLIB_EXTRA_LIBS=$(TCL_LIBS) -lc
  else
  # link command for a shared lib must NOT mention shared libs it uses
! SHLIB_EXTRA_LIBS=
! endif
  endif
- 
- %$(TCL_SHLIB_SUFFIX): %.o
- 	$(TCL_SHLIB_LD) -o $@ $< $(TCL_LIB_SPEC) $(SHLIB_EXTRA_LIBS)
- 
- 
- CC = $(TCL_CC)
- 
- # Since we are using Tcl's choice of C compiler, which might not be
- # the same one selected for Postgres, do NOT use CFLAGS from
- # Makefile.global. Instead use TCL's CFLAGS plus necessary -I
- # directives.
- 
- # Can choose either TCL_CFLAGS_OPTIMIZE or TCL_CFLAGS_DEBUG here, as
- # needed
- override CPPFLAGS += $(TCL_DEFS)
- override CFLAGS = $(TCL_CFLAGS_OPTIMIZE) $(TCL_SHLIB_CFLAGS)
- 
- 
- #
- # DLOBJS is the dynamically-loaded object file.
- #
- DLOBJS= pltcl$(DLSUFFIX)
- 
- INFILES= $(DLOBJS) 
- 
- #
- # plus exports files
- #
- ifdef EXPSUFF
- INFILES+= $(DLOBJS:.o=$(EXPSUFF))
  endif
  
  
! # Provide dummy targets for the case where we can't build the shared library.
  
  ifeq ($(TCL_SHARED_BUILD), 1)
  
! all: $(INFILES)
  	$(MAKE) -C modules $@
  
- pltcl$(DLSUFFIX): pltcl.o
- 
  install: all installdirs
! 	$(INSTALL_SHLIB) $(DLOBJS) $(DESTDIR)$(pkglibdir)/$(DLOBJS)
  	$(MAKE) -C modules $@
  
  installdirs:
--- 26,64 ----
  endif
  endif
  
! # Set up extra libs that must be mentioned in pltcl.so's link command.
! # Aside from libtcl.so, on many platforms we must mention the shared
! # libraries that libtcl.so depends on.  Don't forget -lc, which the
! # Tcl makefiles unaccountably exclude from $(TCL_LIBS).
  
  ifneq ($(TCL_SHLIB_LD_LIBS),)
  # link command for a shared lib must mention shared libs it uses
! SHLIB_LINK=$(TCL_LIB_SPEC) $(TCL_LIBS) -lc
  else
  ifeq ($(PORTNAME), hpux)
  # link command for a shared lib must mention shared libs it uses,
  # even though Tcl doesn't think so...
! SHLIB_LINK=$(TCL_LIB_SPEC) $(TCL_LIBS) -lc
  else
  # link command for a shared lib must NOT mention shared libs it uses
! SHLIB_LINK=$(TCL_LIB_SPEC)
  endif
  endif
  
+ NAME = pltcl
+ SO_MAJOR_VERSION = 2
+ SO_MINOR_VERSION = 0
+ OBJS = pltcl.o
  
! include $(top_srcdir)/src/Makefile.shlib
  
  ifeq ($(TCL_SHARED_BUILD), 1)
  
! all: all-lib
  	$(MAKE) -C modules $@
  
  install: all installdirs
! 	$(INSTALL_SHLIB) $(shlib) $(DESTDIR)$(pkglibdir)/$(NAME)$(DLSUFFIX)
  	$(MAKE) -C modules $@
  
  installdirs:
***************
*** 99,105 ****
  	$(MAKE) -C modules $@
  
  uninstall:
! 	rm -f $(DESTDIR)$(pkglibdir)/$(DLOBJS)
  	$(MAKE) -C modules $@
  
  else # TCL_SHARED_BUILD = 0
--- 66,72 ----
  	$(MAKE) -C modules $@
  
  uninstall:
! 	rm -f $(DESTDIR)$(pkglibdir)/$(NAME)$(DLSUFFIX)
  	$(MAKE) -C modules $@
  
  else # TCL_SHARED_BUILD = 0
***************
*** 114,119 ****
  Makefile.tcldefs: mkMakefile.tcldefs.sh
  	$(SHELL) $< '$(TCL_CONFIG_SH)' '$@'
  
! clean distclean maintainer-clean:
! 	rm -f $(INFILES) pltcl.o Makefile.tcldefs
  	$(MAKE) -C modules $@
--- 81,86 ----
  Makefile.tcldefs: mkMakefile.tcldefs.sh
  	$(SHELL) $< '$(TCL_CONFIG_SH)' '$@'
  
! clean distclean maintainer-clean: clean-lib
! 	rm -f $(OBJS) Makefile.tcldefs
  	$(MAKE) -C modules $@
Sun, 20 Jan 2002 17:55:46 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: --with-tcl build on AIX (and others) fails 
Tom Lane writes:

> I tried out the patch that Andreas sent in a couple weeks ago, and find
> that as-is it fails on HPUX.  The attached version works okay on both
> HPUX 10.20 and RH Linux 7.2, however.  Anyone want to try it on other
> platforms?  (Note this only covers Andreas' proposed changes for pltcl,
> not for libpgtcl.)

Back to this one...

I think we're hung up on this part:

> ! # Set up extra libs that must be mentioned in pltcl.so's link command.
> ! # Aside from libtcl.so, on many platforms we must mention the shared
> ! # libraries that libtcl.so depends on.  Don't forget -lc, which the
> ! # Tcl makefiles unaccountably exclude from $(TCL_LIBS).
>
>   ifneq ($(TCL_SHLIB_LD_LIBS),)
>   # link command for a shared lib must mention shared libs it uses
> ! SHLIB_LINK=$(TCL_LIB_SPEC) $(TCL_LIBS) -lc
>   else
>   ifeq ($(PORTNAME), hpux)
>   # link command for a shared lib must mention shared libs it uses,
>   # even though Tcl doesn't think so...
> ! SHLIB_LINK=$(TCL_LIB_SPEC) $(TCL_LIBS) -lc
>   else
>   # link command for a shared lib must NOT mention shared libs it uses
> ! SHLIB_LINK=$(TCL_LIB_SPEC)
>   endif
>   endif

This is still wrong because it depends on information that Tcl generated
during its build using its compiler and linker configuration.

Also, if you use GCC to link, specifying -lc is almost certainly wrong in
any case.

I think what should work is this:  Assign

SHLIB_LINK = $(TCL_LIB_SPEC) $(TCL_LIBS)

unconditionally.  If the port doesn't like mention of shared lib
dependencies, it should ignore SHLIB_LINK in Makefile.shlib.  If the port
wants to have -lc, it should add it to SHLIB_LINK in Makefile.shlib.

-- 
Peter Eisentraut   peter_e@gmx.net


Fri, 22 Feb 2002 23:42:05 -0500 (EST)
Peter Eisentraut <peter_e@gmx.net>
Re: --with-tcl build on AIX (and others) fails 