OK, this is what I'm seeing on FreeBSD/Alpha for libpq++.  I haven't figured
out how to build libpqxx yet.:

gmake[3]: Entering directory
`/home/chriskl/pgsql-head/src/interfaces/libpq++'
g++ -O2 -g -Wall -fpic -DPIC -I../../../src/interfaces/libpq -I../../../src/
include   -c -o pgconnection.o pgconnection.cc -MMD
cc1plus: warning:
***
***     The -O2 flag TRIGGERS KNOWN OPTIMIZER BUGS ON THIS PLATFORM
***

g++ -O2 -g -Wall -fpic -DPIC -I../../../src/interfaces/libpq -I../../../src/
include   -c -o pgdatabase.o pgdatabase.cc -MMD
cc1plus: warning:
***
***     The -O2 flag TRIGGERS KNOWN OPTIMIZER BUGS ON THIS PLATFORM
***

g++ -O2 -g -Wall -fpic -DPIC -I../../../src/interfaces/libpq -I../../../src/
include   -c -o pgtransdb.o pgtransdb.cc -MMD
cc1plus: warning:
***
***     The -O2 flag TRIGGERS KNOWN OPTIMIZER BUGS ON THIS PLATFORM
***

g++ -O2 -g -Wall -fpic -DPIC -I../../../src/interfaces/libpq -I../../../src/
include   -c -o pgcursordb.o pgcursordb.cc -MMD
cc1plus: warning:
***
***     The -O2 flag TRIGGERS KNOWN OPTIMIZER BUGS ON THIS PLATFORM
***

g++ -O2 -g -Wall -fpic -DPIC -I../../../src/interfaces/libpq -I../../../src/
include   -c -o pglobject.o pglobject.cc -MMD
cc1plus: warning:
***
***     The -O2 flag TRIGGERS KNOWN OPTIMIZER BUGS ON THIS PLATFORM
***

ar cr libpq++.a `lorder pgconnection.o pgdatabase.o pgtransdb.o pgcursordb.o
pglobject.o | tsort`
ranlib libpq++.a
g++ -O2 -g -Wall -fpic -DPIC -shared -Wl,-x,-soname,libpq++.so.4
pgconnection.o pgdatabase.o pgtransdb.o pgcursordb.o
lobject.o   -L../../../src/interfaces/libpq -lpq -R/home/chriskl/local/lib -
o libpq++.so.4
rm -f libpq++.so
ln -s libpq++.so.4 libpq++.so
gmake[3]: Leaving directory
`/home/chriskl/pgsql-head/src/interfaces/libpq++'





Wed, 3 Jul 2002 14:25:46 +0800
"Christopher Kings-Lynne" <chriskl@familyhealth.com.au>
libpq++ build problems
On Wed, Jul 03, 2002 at 02:25:46PM +0800, Christopher Kings-Lynne wrote:
> OK, this is what I'm seeing on FreeBSD/Alpha for libpq++.  

[cut]
[paste]

> cc1plus: warning:
> ***
> ***     The -O2 flag TRIGGERS KNOWN OPTIMIZER BUGS ON THIS PLATFORM
> ***

Doesn't say it doesn't work though...  Have you tried running the
resulting code?


> I haven't figured out how to build libpqxx yet.:

Basically, ./configure; make; make check; make install.  You may have to
use configure options --with-postgres=/your/postgres/dir or its cousins.
Plus, you'll also run into the same gcc warning so you may have to set
the environment variable CXXFLAGS to something like -O before running 
configure.  The same will probably help with libpq++ as well BTW.


Jeroen





Wed, 3 Jul 2002 17:28:34 +0200
jtv <jtv@xs4all.nl>
Re: libpq++ build problems

And the problem is, what?  Except for the -O2 warnings, looks fine to
me.


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

Christopher Kings-Lynne wrote:
> OK, this is what I'm seeing on FreeBSD/Alpha for libpq++.  I haven't figured
> out how to build libpqxx yet.:
> 
> gmake[3]: Entering directory
> `/home/chriskl/pgsql-head/src/interfaces/libpq++'
> g++ -O2 -g -Wall -fpic -DPIC -I../../../src/interfaces/libpq -I../../../src/
> include   -c -o pgconnection.o pgconnection.cc -MMD
> cc1plus: warning:
> ***
> ***     The -O2 flag TRIGGERS KNOWN OPTIMIZER BUGS ON THIS PLATFORM
> ***
> 
> g++ -O2 -g -Wall -fpic -DPIC -I../../../src/interfaces/libpq -I../../../src/
> include   -c -o pgdatabase.o pgdatabase.cc -MMD
> cc1plus: warning:
> ***
> ***     The -O2 flag TRIGGERS KNOWN OPTIMIZER BUGS ON THIS PLATFORM
> ***
> 
> g++ -O2 -g -Wall -fpic -DPIC -I../../../src/interfaces/libpq -I../../../src/
> include   -c -o pgtransdb.o pgtransdb.cc -MMD
> cc1plus: warning:
> ***
> ***     The -O2 flag TRIGGERS KNOWN OPTIMIZER BUGS ON THIS PLATFORM
> ***
> 
> g++ -O2 -g -Wall -fpic -DPIC -I../../../src/interfaces/libpq -I../../../src/
> include   -c -o pgcursordb.o pgcursordb.cc -MMD
> cc1plus: warning:
> ***
> ***     The -O2 flag TRIGGERS KNOWN OPTIMIZER BUGS ON THIS PLATFORM
> ***
> 
> g++ -O2 -g -Wall -fpic -DPIC -I../../../src/interfaces/libpq -I../../../src/
> include   -c -o pglobject.o pglobject.cc -MMD
> cc1plus: warning:
> ***
> ***     The -O2 flag TRIGGERS KNOWN OPTIMIZER BUGS ON THIS PLATFORM
> ***
> 
> ar cr libpq++.a `lorder pgconnection.o pgdatabase.o pgtransdb.o pgcursordb.o
> pglobject.o | tsort`
> ranlib libpq++.a
> g++ -O2 -g -Wall -fpic -DPIC -shared -Wl,-x,-soname,libpq++.so.4
> pgconnection.o pgdatabase.o pgtransdb.o pgcursordb.o
> lobject.o   -L../../../src/interfaces/libpq -lpq -R/home/chriskl/local/lib -
> o libpq++.so.4
> rm -f libpq++.so
> ln -s libpq++.so.4 libpq++.so
> gmake[3]: Leaving directory
> `/home/chriskl/pgsql-head/src/interfaces/libpq++'
> 
> 
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
> 
> http://archives.postgresql.org
> 
> 
> 

-- 
  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, 3 Jul 2002 11:46:12 -0400 (EDT)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: libpq++ build problems

Actually, I am confused. In src/template/freebsd I see:
	
	CFLAGS='-pipe'
	
	case $host_cpu in
	  alpha*)   CFLAGS="$CFLAGS -O";;
	  i386*)    CFLAGS="$CFLAGS -O2";;
	esac

so why is he seeing the -O2 flag on FreeBSD/alpha?

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

jtv wrote:
> On Wed, Jul 03, 2002 at 02:25:46PM +0800, Christopher Kings-Lynne wrote:
> > OK, this is what I'm seeing on FreeBSD/Alpha for libpq++.  
> 
> [cut]
> [paste]
> 
> > cc1plus: warning:
> > ***
> > ***     The -O2 flag TRIGGERS KNOWN OPTIMIZER BUGS ON THIS PLATFORM
> > ***
> 
> Doesn't say it doesn't work though...  Have you tried running the
> resulting code?
> 
> 
> > I haven't figured out how to build libpqxx yet.:
> 
> Basically, ./configure; make; make check; make install.  You may have to
> use configure options --with-postgres=/your/postgres/dir or its cousins.
> Plus, you'll also run into the same gcc warning so you may have to set
> the environment variable CXXFLAGS to something like -O before running 
> configure.  The same will probably help with libpq++ as well BTW.
> 
> 
> Jeroen
> 
> 
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
> 
> 
> 

-- 
  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, 3 Jul 2002 13:45:56 -0400 (EDT)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: libpq++ build problems
On Wed, Jul 03, 2002 at 01:45:56PM -0400, Bruce Momjian wrote:
> 
> Actually, I am confused. In src/template/freebsd I see:
> 	
> 	CFLAGS='-pipe'
> 	
> 	case $host_cpu in
> 	  alpha*)   CFLAGS="$CFLAGS -O";;
> 	  i386*)    CFLAGS="$CFLAGS -O2";;
> 	esac
> 
> so why is he seeing the -O2 flag on FreeBSD/alpha?

Probably because CXXFLAGS still has -O2 set.


Jeroen




Wed, 3 Jul 2002 20:51:46 +0200
jtv <jtv@xs4all.nl>
Re: libpq++ build problems
jtv wrote:
> On Wed, Jul 03, 2002 at 01:45:56PM -0400, Bruce Momjian wrote:
> > 
> > Actually, I am confused. In src/template/freebsd I see:
> > 	
> > 	CFLAGS='-pipe'
> > 	
> > 	case $host_cpu in
> > 	  alpha*)   CFLAGS="$CFLAGS -O";;
> > 	  i386*)    CFLAGS="$CFLAGS -O2";;
> > 	esac
> > 
> > so why is he seeing the -O2 flag on FreeBSD/alpha?
> 
> Probably because CXXFLAGS still has -O2 set.

Interesting.  I thought -O2 was only set in /template files, but I now
see it is set in configure too.  The following patch fixes the libpqxx
compile problem on FreeBSD/alpha.  The old code set -O2 for
FreeBSD/i386, but that is already set earlier.  The new patch just
updates the FreeBSD/alpha compile.

-- 
  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

Index: src/template/freebsd
===================================================================
RCS file: /cvsroot/pgsql/src/template/freebsd,v
retrieving revision 1.10
diff -c -r1.10 freebsd
*** src/template/freebsd	16 Nov 2000 05:51:07 -0000	1.10
--- src/template/freebsd	3 Jul 2002 19:45:14 -0000
***************
*** 1,7 ****
  CFLAGS='-pipe'
  
! case $host_cpu in
!   alpha*)   CFLAGS="$CFLAGS -O";;
!   i386*)    CFLAGS="$CFLAGS -O2";;
! esac
! 
--- 1,6 ----
  CFLAGS='-pipe'
  
! if [ `expr "$host_cpu" : "alpha"` -ge 5 ]
! then	CFLAGS="$CFLAGS -O"
! 	CXXFLAGS="$CFLAGS -O"
! fi
Wed, 3 Jul 2002 15:47:47 -0400 (EDT)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: libpq++ build problems
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> ... The following patch fixes the libpqxx
> compile problem on FreeBSD/alpha.  The old code set -O2 for
> FreeBSD/i386, but that is already set earlier.  The new patch just
> updates the FreeBSD/alpha compile.

As a general rule, anything that affects one *BSD affects them all.
I am always very suspicious of any patch that changes only one of
the *BSD templates or makefiles.  I'm not even convinced we should
have separate makefiles/templates for 'em ...

			regards, tom lane



Thu, 04 Jul 2002 00:52:17 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: libpq++ build problems 
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > ... The following patch fixes the libpqxx
> > compile problem on FreeBSD/alpha.  The old code set -O2 for
> > FreeBSD/i386, but that is already set earlier.  The new patch just
> > updates the FreeBSD/alpha compile.
> 
> As a general rule, anything that affects one *BSD affects them all.
> I am always very suspicious of any patch that changes only one of
> the *BSD templates or makefiles.  I'm not even convinced we should
> have separate makefiles/templates for 'em ...

Well, in this case FreeBSD/alpha -O2 thows that warning.  Hard to miss
that one.  It _is_ a unique case for that platform.

-- 
  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



Thu, 4 Jul 2002 01:32:06 -0400 (EDT)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: libpq++ build problems
Bruce Momjian writes:

> jtv wrote:
> > On Wed, Jul 03, 2002 at 01:45:56PM -0400, Bruce Momjian wrote:
> > >
> > > Actually, I am confused. In src/template/freebsd I see:
> > >
> > > 	CFLAGS='-pipe'
> > >
> > > 	case $host_cpu in
> > > 	  alpha*)   CFLAGS="$CFLAGS -O";;
> > > 	  i386*)    CFLAGS="$CFLAGS -O2";;
> > > 	esac
> > >
> > > so why is he seeing the -O2 flag on FreeBSD/alpha?
> >
> > Probably because CXXFLAGS still has -O2 set.
>
> Interesting.  I thought -O2 was only set in /template files, but I now
> see it is set in configure too.  The following patch fixes the libpqxx
> compile problem on FreeBSD/alpha.  The old code set -O2 for
> FreeBSD/i386, but that is already set earlier.  The new patch just
> updates the FreeBSD/alpha compile.

Except that it now fails to set CFLAGS correctly.  Please avoid "expr"
too.  "case" is fine.

Actually, you can't really set CXXFLAGS in the template file, because at
that point you don't know what kind of C++ compiler is going to be used
yet.  That's why it's handled in configure later.

-- 
Peter Eisentraut   peter_e@gmx.net




Sun, 7 Jul 2002 12:58:37 +0200 (CEST)
Peter Eisentraut <peter_e@gmx.net>
Re: libpq++ build problems
Tom Lane writes:

> As a general rule, anything that affects one *BSD affects them all.
> I am always very suspicious of any patch that changes only one of
> the *BSD templates or makefiles.  I'm not even convinced we should
> have separate makefiles/templates for 'em ...

If they could retroactively agree on a way to build shared libraries, we
might have a shot.

-- 
Peter Eisentraut   peter_e@gmx.net




Sun, 7 Jul 2002 12:58:57 +0200 (CEST)
Peter Eisentraut <peter_e@gmx.net>
Re: libpq++ build problems 
Peter Eisentraut wrote:
> > Interesting.  I thought -O2 was only set in /template files, but I now
> > see it is set in configure too.  The following patch fixes the libpqxx
> > compile problem on FreeBSD/alpha.  The old code set -O2 for
> > FreeBSD/i386, but that is already set earlier.  The new patch just
> > updates the FreeBSD/alpha compile.
> 
> Except that it now fails to set CFLAGS correctly.  Please avoid "expr"
> too.  "case" is fine.

Changed, I assume for portability.

> Actually, you can't really set CXXFLAGS in the template file, because at
> that point you don't know what kind of C++ compiler is going to be used
> yet.  That's why it's handled in configure later.

Looking at configure.in, it looks pretty safe:

  if test "$ac_env_CXXFLAGS" != set; then
    if test "$GXX" = yes; then
      CXXFLAGS=-O2
    else
      case $template in
        osf)            CXXFLAGS='-O4 -Olimit 2000' ;;
        unixware)       CXXFLAGS='-O' ;;
        *)              CXXFLAGS= ;;
      esac
    fi
  fi

Because CXXFLAGS is already set for freebsd/alpha, it falls through,
missing the -O2 setting.

-- 
  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



Sun, 7 Jul 2002 10:26:12 -0400 (EDT)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: libpq++ build problems
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Looking at configure.in, it looks pretty safe:

>   if test "$ac_env_CXXFLAGS" != set; then
>     if test "$GXX" = yes; then
>       CXXFLAGS=-O2
>     else
>       case $template in
>         osf)            CXXFLAGS='-O4 -Olimit 2000' ;;
>         unixware)       CXXFLAGS='-O' ;;
>         *)              CXXFLAGS= ;;
>       esac
>     fi
>   fi

> Because CXXFLAGS is already set for freebsd/alpha, it falls through,

I don't think so; the ac_env_ flag presumably indicates whether
configure inherited CXXFLAGS from its environment, not whether it
set it internally.

But even if setting CXXFLAGS in the template did override this code,
it would be a mistake, because the point of this code is to allow a
choice between g++-specific and vendor's-compiler-specific CXXFLAGS.

Perhaps we could do something like this:

	# set defaults for most platforms
	GCC_CXXFLAGS="-O2"
	VENDOR_CXXFLAGS=

	# now include template, which may override either of the above

	# now select proper CXXFLAGS
	if test "$ac_env_CXXFLAGS" != set; then
	    if test "$GXX" = yes; then
	      CXXFLAGS="$GCC_CXXFLAGS"
	    else
	      CXXFLAGS="$VENDOR_CXXFLAGS"
	    fi
	fi

This would allow us to push the special cases for osf and unixware out
into their template files, which would be a Good Thing.

			regards, tom lane



Sun, 07 Jul 2002 12:03:08 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: libpq++ build problems 
Good idea.  Patch attached.  autoconf run.

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

Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Looking at configure.in, it looks pretty safe:
> 
> >   if test "$ac_env_CXXFLAGS" != set; then
> >     if test "$GXX" = yes; then
> >       CXXFLAGS=-O2
> >     else
> >       case $template in
> >         osf)            CXXFLAGS='-O4 -Olimit 2000' ;;
> >         unixware)       CXXFLAGS='-O' ;;
> >         *)              CXXFLAGS= ;;
> >       esac
> >     fi
> >   fi
> 
> > Because CXXFLAGS is already set for freebsd/alpha, it falls through,
> 
> I don't think so; the ac_env_ flag presumably indicates whether
> configure inherited CXXFLAGS from its environment, not whether it
> set it internally.
> 
> But even if setting CXXFLAGS in the template did override this code,
> it would be a mistake, because the point of this code is to allow a
> choice between g++-specific and vendor's-compiler-specific CXXFLAGS.
> 
> Perhaps we could do something like this:
> 
> 	# set defaults for most platforms
> 	GCC_CXXFLAGS="-O2"
> 	VENDOR_CXXFLAGS=
> 
> 	# now include template, which may override either of the above
> 
> 	# now select proper CXXFLAGS
> 	if test "$ac_env_CXXFLAGS" != set; then
> 	    if test "$GXX" = yes; then
> 	      CXXFLAGS="$GCC_CXXFLAGS"
> 	    else
> 	      CXXFLAGS="$VENDOR_CXXFLAGS"
> 	    fi
> 	fi
> 
> This would allow us to push the special cases for osf and unixware out
> into their template files, which would be a Good Thing.
> 
> 			regards, tom lane
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
> 
> 
> 

-- 
  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

Index: configure.in
===================================================================
RCS file: /cvsroot/pgsql/configure.in,v
retrieving revision 1.186
diff -c -r1.186 configure.in
*** configure.in	28 May 2002 16:57:53 -0000	1.186
--- configure.in	7 Jul 2002 20:05:54 -0000
***************
*** 243,248 ****
--- 243,252 ----
  # variable.
  PGAC_ARG_REQ(with, CC, [], [CC=$with_CC])
  
+ # Set here so it can be over-ridden in the template file
+ GCC_CXXFLAGS="-O2"
+ VENDOR_CXXFLAGS=""
+ 
  case $template in
    aix) pgac_cc_list="gcc xlc";;
   irix) pgac_cc_list="cc";; # no gcc
***************
*** 593,605 ****
    AC_PROG_CXX
    if test "$ac_env_CXXFLAGS" != set; then
      if test "$GXX" = yes; then
!       CXXFLAGS=-O2
      else
!       case $template in
! 	osf)		CXXFLAGS='-O4 -Olimit 2000' ;;
!         unixware)	CXXFLAGS='-O' ;;
! 	*)		CXXFLAGS= ;;
!       esac
      fi
    fi
    if test "$enable_debug" = yes && test "$ac_cv_prog_cxx_g" = yes; then
--- 597,605 ----
    AC_PROG_CXX
    if test "$ac_env_CXXFLAGS" != set; then
      if test "$GXX" = yes; then
!       CXXFLAGS="$GCC_CXXFLAGS"
      else
!       CXXFLAGS="$VENDOR_CXXFLAGS"
      fi
    fi
    if test "$enable_debug" = yes && test "$ac_cv_prog_cxx_g" = yes; then
Index: src/template/freebsd
===================================================================
RCS file: /cvsroot/pgsql/src/template/freebsd,v
retrieving revision 1.12
diff -c -r1.12 freebsd
*** src/template/freebsd	7 Jul 2002 14:24:13 -0000	1.12
--- src/template/freebsd	7 Jul 2002 20:05:57 -0000
***************
*** 2,6 ****
  
  case $host_cpu in
    alpha*)   CFLAGS="$CFLAGS -O";;
!             CXXFLAGS="$CXXFLAGS -O"
  esac
--- 2,6 ----
  
  case $host_cpu in
    alpha*)   CFLAGS="$CFLAGS -O";;
!             GCC_CXXFLAGS="-O"
  esac
Index: src/template/osf
===================================================================
RCS file: /cvsroot/pgsql/src/template/osf,v
retrieving revision 1.3
diff -c -r1.3 osf
*** src/template/osf	31 Oct 2000 18:16:20 -0000	1.3
--- src/template/osf	7 Jul 2002 20:05:57 -0000
***************
*** 6,8 ****
--- 6,10 ----
    CFLAGS='-O4 -Olimit 2000'
    CCC=cxx
  fi
+ VENDOR_CXXFLAGS='-O4 -Olimit 2000'
+ 
Index: src/template/unixware
===================================================================
RCS file: /cvsroot/pgsql/src/template/unixware,v
retrieving revision 1.9
diff -c -r1.9 unixware
*** src/template/unixware	22 Oct 2000 22:15:09 -0000	1.9
--- src/template/unixware	7 Jul 2002 20:05:57 -0000
***************
*** 3,5 ****
--- 3,7 ----
  else
    CFLAGS='-O -K inline'
  fi
+ VENDOR_CXXFLAGS="-O"
+
Sun, 7 Jul 2002 16:27:13 -0400 (EDT)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: libpq++ build problems