Thread: Compile/Link Error for Postgres 8.1.0 on Solaris 8

Compile/Link Error for Postgres 8.1.0 on Solaris 8

From
"Bhide, Rajan"
Date:
Hello,
 
I tried to compile Postgres 8.1.0 from the source tar file with following options:
 
./configure --without-readline --enable-thread-safety CFLAGS=-xO4 -D_REENTRANT -xipo -mt -lpthread  CC=/export/home/uxapps/workshop/SUNWspro/bin/cc
 
I am getting following error:
 
gmake -C ../../src/timezone all
gmake[3]: Entering directory `/home/rbhide/utilities/postgres-8.1/postgresql-8.1.0/src/timezone'
/usr/ccs/bin/ld -r -o SUBSYS.o localtime.o strftime.o pgtz.o
gmake -C ../../src/port all
gmake[4]: Entering directory `/home/rbhide/utilities/postgres-8.1/postgresql-8.1.0/src/port'
gmake[4]: Nothing to be done for `all'.
gmake[4]: Leaving directory `/home/rbhide/utilities/postgres-8.1/postgresql-8.1.0/src/port'
gmake[3]: Leaving directory `/home/rbhide/utilities/postgres-8.1/postgresql-8.1.0/src/timezone'
/export/home/uxapps/workshop/SUNWspro/bin/cc -Xa -xO4 -D_REENTRANT -xipo -mt -lpthread  -L../../src/port  -Wl,-R/usr/local/pgsql/lib  access/SUBSYS.o bootstrap/SUBSYS.o catalog/SUBSYS.o parser/SUBSYS.o commands/SUBSYS.o executor/SUBSYS.o lib/SUBSYS.o libpq/SUBSYS.o main/SUBSYS.o nodes/SUBSYS.o optimizer/SUBSYS.o port/SUBSYS.o postmaster/SUBSYS.o regex/SUBSYS.o rewrite/SUBSYS.o storage/SUBSYS.o tcop/SUBSYS.o utils/SUBSYS.o ../../src/timezone/SUBSYS.o ../../src/port/libpgport_srv.a    -lz -lrt -lresolv -lgen -lsocket -lnsl -ldl -lm  -o postgres
Undefined   first referenced
 symbol         in file
__ipo_error_recompile_file(4_1)     ../../src/timezone/SUBSYS.o
ld: fatal: Symbol referencing errors. No output written to postgres
gmake[2]: *** [postgres] Error 1
gmake[2]: Leaving directory `/home/rbhide/utilities/postgres-8.1/postgresql-8.1.0/src/backend'
gmake[1]: *** [all] Error 2
gmake[1]: Leaving directory `/home/rbhide/utilities/postgres-8.1/postgresql-8.1.0/src'
gmake: *** [all] Error 2
 
 
 
Could someone help on this?
 
Thanks,
-Rajan

"This email message and any attachments are confidential information of Starent Networks, Corp. The information transmitted may not be used to create or change any contractual obligations of Starent Networks, Corp. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this e-mail and its attachments by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify the sender immediately -- by replying to this message or by sending an email to postmaster@starentnetworks.com -- and destroy all copies of this message and any attachments without reading or disclosing their contents. Thank you."

Re: Compile/Link Error for Postgres 8.1.0 on Solaris 8

From
Alan Stange
Date:
Bhide, Rajan wrote:
> I tried to compile Postgres 8.1.0 from the source tar file with
> following options:
>
> ./configure --without-readline --enable-thread-safety CFLAGS=-xO4
> -D_REENTRANT -xipo -mt -lpthread
> CC=/export/home/uxapps/workshop/SUNWspro/bin/cc
>
> I am getting following error:
>
> gmake -C ../../src/timezone all
> gmake[3]: Entering directory
> `/home/rbhide/utilities/postgres-8.1/postgresql-8.1.0/src/timezone'
> /usr/ccs/bin/ld -r -o SUBSYS.o localtime.o strftime.o pgtz.o
> gmake -C ../../src/port all
> gmake[4]: Entering directory
> `/home/rbhide/utilities/postgres-8.1/postgresql-8.1.0/src/port'
> gmake[4]: Nothing to be done for `all'.
> gmake[4]: Leaving directory
> `/home/rbhide/utilities/postgres-8.1/postgresql-8.1.0/src/port'
> gmake[3]: Leaving directory
> `/home/rbhide/utilities/postgres-8.1/postgresql-8.1.0/src/timezone'
> /export/home/uxapps/workshop/SUNWspro/bin/cc -Xa -xO4 -D_REENTRANT
> -xipo -mt -lpthread  -L../../src/port  -Wl,-R/usr/local/pgsql/lib
> access/SUBSYS.o bootstrap/SUBSYS.o catalog/SUBSYS.o parser/SUBSYS.o
> commands/SUBSYS.o executor/SUBSYS.o lib/SUBSYS.o libpq/SUBSYS.o
> main/SUBSYS.o nodes/SUBSYS.o optimizer/SUBSYS.o port/SUBSYS.o
> postmaster/SUBSYS.o regex/SUBSYS.o rewrite/SUBSYS.o storage/SUBSYS.o
> tcop/SUBSYS.o utils/SUBSYS.o ../../src/timezone/SUBSYS.o
> ../../src/port/libpgport_srv.a    -lz -lrt -lresolv -lgen -lsocket
> -lnsl -ldl -lm  -o postgres
> *Undefined   first referenced
>  symbol         in file
> __ipo_error_recompile_file(4_1)     ../../src/timezone/SUBSYS.o
> ld: fatal: Symbol referencing errors. No output written to postgres
> *
> gmake[2]: *** [postgres] Error 1
> gmake[2]: Leaving directory
> `/home/rbhide/utilities/postgres-8.1/postgresql-8.1.0/src/backend'
> gmake[1]: *** [all] Error 2
> gmake[1]: Leaving directory
> `/home/rbhide/utilities/postgres-8.1/postgresql-8.1.0/src'
> gmake: *** [all] Error 2
>
> Could someone help on this?

Solaris 8?

Given that you've enabled -xipo, and the error is related to ipo, I'd
suggest dropping that option for now.   What version of the Sun
compilers are you using here?

You might want to consider using gcc for compiler though.   In a bit of
testing with the Studio 10 compilers against a recent gcc release, we
found that the gcc built postgres performed better (on our test
workload).  This was mostly because the function MemoryContextSwitchTo
is inlined with gcc and not with the Sun compilers.  I suppose you could
also try -xinline=%auto,MemoryContextSwitchTo, but then you need
-xcrossfile, which conflicts with -xipo....which leads me back to using gcc.

-- Alan

Re: Compile/Link Error for Postgres 8.1.0 on Solaris 8

From
Tom Lane
Date:
Alan Stange <stange@rentec.com> writes:
> Bhide, Rajan wrote:
>> ./configure --without-readline --enable-thread-safety CFLAGS=-xO4
>> -D_REENTRANT -xipo -mt -lpthread
>> CC=/export/home/uxapps/workshop/SUNWspro/bin/cc

> Given that you've enabled -xipo, and the error is related to ipo, I'd
> suggest dropping that option for now.

Putting -lpthread into CFLAGS seems pretty foolish as well.  If you
needed to specify that explicitly (which you do not) it would belong
in LDFLAGS --- putting it in CFLAGS is pretty certain to screw up
link order and so on.  And what is -mt?

            regards, tom lane

Re: Compile/Link Error for Postgres 8.1.0 on Solaris 8

From
Alan Stange
Date:
Tom Lane wrote:
> Alan Stange <stange@rentec.com> writes:
>
>> Bhide, Rajan wrote:
>>
>>> ./configure --without-readline --enable-thread-safety CFLAGS=-xO4
>>> -D_REENTRANT -xipo -mt -lpthread
>>> CC=/export/home/uxapps/workshop/SUNWspro/bin/cc
>>>
>
>
>> Given that you've enabled -xipo, and the error is related to ipo, I'd
>> suggest dropping that option for now.
>>
>
> Putting -lpthread into CFLAGS seems pretty foolish as well.  If you
> needed to specify that explicitly (which you do not) it would belong
> in LDFLAGS --- putting it in CFLAGS is pretty certain to screw up
> link order and so on.  And what is -mt?
>
>             regards, tom lane
>
     -mt  Passes D_REENTRANT to preprocessor. Appends -lthread
          after all other user-specified libraries on the command
          line.  If you are doing your own multithread coding,
          you must use this option in the compile and link steps.
          To obtain faster execution, this option requires a mul-
          tiprocessor system. On a single-processor system, the
          resulting executable usually runs more slowly with this
          option.


Re: Compile/Link Error for Postgres 8.1.0 on Solaris 8

From
Bruce Momjian
Date:
Alan Stange wrote:
> Tom Lane wrote:
> > Alan Stange <stange@rentec.com> writes:
> >
> >> Bhide, Rajan wrote:
> >>
> >>> ./configure --without-readline --enable-thread-safety CFLAGS=-xO4
> >>> -D_REENTRANT -xipo -mt -lpthread
> >>> CC=/export/home/uxapps/workshop/SUNWspro/bin/cc
> >>>
> >
> >
> >> Given that you've enabled -xipo, and the error is related to ipo, I'd
> >> suggest dropping that option for now.
> >>
> >
> > Putting -lpthread into CFLAGS seems pretty foolish as well.  If you
> > needed to specify that explicitly (which you do not) it would belong
> > in LDFLAGS --- putting it in CFLAGS is pretty certain to screw up
> > link order and so on.  And what is -mt?
> >
> >             regards, tom lane
> >
>      -mt  Passes D_REENTRANT to preprocessor. Appends -lthread
>           after all other user-specified libraries on the command
>           line.  If you are doing your own multithread coding,
>           you must use this option in the compile and link steps.
>           To obtain faster execution, this option requires a mul-
>           tiprocessor system. On a single-processor system, the
>           resulting executable usually runs more slowly with this
>           option.

Are you saying that --enable-thread-safety isn't setting PTHREAD_CFLAGS
and PTHREAD_LIBS in Makefile.global properly?  If so, please check out
config.log to see why it isn't trying those flags?  What settings to you
have for those anyway?

We have this in config/acx_pthread.m4 which modifies the flags tried on
Solaris:

  case "${host_cpu}-${host_os}" in
        *solaris*)

        # On Solaris (at least, for some versions), libc contains stubbed
        # (non-functional) versions of the pthreads routines, so link-based
        # tests will erroneously succeed.  (We need to link with -pthread or
        # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
        # a function called by this macro, so we could check for that, but
        # who knows whether they'll stub that too in a future libc.)  So,
        # we'll just look for -pthreads and -lpthread first:

        acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags"
        ;;
  esac

Is this incorrect?  Feel free to wack around configure (which is built
from  config/acx_pthread.m4) and let us know what works.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: Compile/Link Error for Postgres 8.1.0 on Solaris 8

From
"Bhide, Rajan"
Date:
man CC:
    -mt       Compile and link for multithreaded code.
               This option:
               o Passes -D_REENTRANT to the preprocessor
               o Passes -lthread in the correct order to ld
               o Ensures that, for standard mode (the default
                 mode), libthread is linked before libCrun
               o Ensures that, for compability mode (-compat),
                 libthread is linked before libC
               The -mt option is required if the application or
               libraries are multithreaded.
               Warnings:
               To ensure proper library linking order, you must
               use this option, rather than -lthread, to link
               with libthread.
               If you are using POSIX threads, you must link with
               the options -mt -lpthread.  The -mt option is
               necessary because libC (compatibility mode) and
               libCrun (standard mode) need libthread for a mul-
               tithreaded application.
               If you compile and link in separate steps and you
               compile with -mt, you might get unexpected
               results. If you compile one translation unit with
               -mt, compile all units of the program with -mt.
               If you are mixing parallel Fortran objects with
               C++ objects, the link line must specify the -mt
               flag.

For portability reasons, I am using Posix threads.
As pointed out by Alan, -D_REENTRANT is redundant which I will remove.

>>What version of the Sun compilers are you using here?
cc: Sun WorkShop 6 update 2 C 5.3 2001/05/15


I got cc: Sun C 5.7 2005/01/07 (Studio 10) installed on other box,so
would try this one with the options suggested.
The updated configure params are as under.


./configure --without-readline --enable-thread-safety
CFLAGS='-xinline=%auto,MemoryContextSwitchTo -xcrossfile -mt'
LDFLAGS='-lpthread' CC=/export/home/uxapps/workshop/SUNWspro/bin/cc

The main reason to use -mt options was to build thread safe PQ Client
Library.
We use Postgres mostly on Sparc v240 system with Solaris 8 and above.
The app demands very high performance and is very extensive db write
kind of.
As the latest Postgres version mentions about many performance
enhancement, we wanted to try before migrating to it.
I would be highly obliged if you guys have some performance figures or
benchmark results for Solaris environment. Could you please send
pointers to it.
If you have some input specific to compilation that too would be of much
help.

Thanks,
Rajan Bhide

-----Original Message-----
From: Alan Stange [mailto:stange@rentec.com]
Sent: Friday, December 09, 2005 1:06 AM
To: Tom Lane
Cc: Bhide, Rajan; pgsql-novice@postgresql.org
Subject: Re: [NOVICE] Compile/Link Error for Postgres 8.1.0 on Solaris 8


Tom Lane wrote:
> Alan Stange <stange@rentec.com> writes:
>
>> Bhide, Rajan wrote:
>>
>>> ./configure --without-readline --enable-thread-safety CFLAGS=-xO4
>>> -D_REENTRANT -xipo -mt -lpthread
>>> CC=/export/home/uxapps/workshop/SUNWspro/bin/cc
>>>
>
>
>> Given that you've enabled -xipo, and the error is related to ipo, I'd
>> suggest dropping that option for now.
>>
>
> Putting -lpthread into CFLAGS seems pretty foolish as well.  If you
> needed to specify that explicitly (which you do not) it would belong
> in LDFLAGS --- putting it in CFLAGS is pretty certain to screw up link

> order and so on.  And what is -mt?
>
>             regards, tom lane
>
     -mt  Passes D_REENTRANT to preprocessor. Appends -lthread
          after all other user-specified libraries on the command
          line.  If you are doing your own multithread coding,
          you must use this option in the compile and link steps.
          To obtain faster execution, this option requires a mul-
          tiprocessor system. On a single-processor system, the
          resulting executable usually runs more slowly with this
          option.


"This email message and any attachments are confidential information of Starent Networks, Corp. The information
transmittedmay not be used to create or change any contractual obligations of Starent Networks, Corp.  Any review,
retransmission,dissemination or other use of, or taking of any action in reliance upon this e-mail and its attachments
bypersons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please
notifythe sender immediately -- by replying to this message or by sending an email to postmaster@starentnetworks.com --
anddestroy all copies of this message and any attachments without reading or disclosing their contents. Thank you." 

Re: Compile/Link Error for Postgres 8.1.0 on Solaris 8

From
"Aly S.P Dharshi"
Date:
Why don't you just try out the version that is compiled for Solaris at
www.blastwave.org ? Secondly a slightly OT point, Studio 11 is available
for download from Sun's site for free try that.

Aly


On Fri, 9 Dec 2005, Bhide, Rajan wrote:

>man CC:
>    -mt       Compile and link for multithreaded code.
>               This option:
>               o Passes -D_REENTRANT to the preprocessor
>               o Passes -lthread in the correct order to ld
>               o Ensures that, for standard mode (the default
>                 mode), libthread is linked before libCrun
>               o Ensures that, for compability mode (-compat),
>                 libthread is linked before libC
>               The -mt option is required if the application or
>               libraries are multithreaded.
>               Warnings:
>               To ensure proper library linking order, you must
>               use this option, rather than -lthread, to link
>               with libthread.
>               If you are using POSIX threads, you must link with
>               the options -mt -lpthread.  The -mt option is
>               necessary because libC (compatibility mode) and
>               libCrun (standard mode) need libthread for a mul-
>               tithreaded application.
>               If you compile and link in separate steps and you
>               compile with -mt, you might get unexpected
>               results. If you compile one translation unit with
>               -mt, compile all units of the program with -mt.
>               If you are mixing parallel Fortran objects with
>               C++ objects, the link line must specify the -mt
>               flag.
>
>For portability reasons, I am using Posix threads.
>As pointed out by Alan, -D_REENTRANT is redundant which I will remove.
>
>>>What version of the Sun compilers are you using here?
>cc: Sun WorkShop 6 update 2 C 5.3 2001/05/15
>
>
>I got cc: Sun C 5.7 2005/01/07 (Studio 10) installed on other box,so
>would try this one with the options suggested.
>The updated configure params are as under.
>
>
>./configure --without-readline --enable-thread-safety
>CFLAGS='-xinline=%auto,MemoryContextSwitchTo -xcrossfile -mt'
>LDFLAGS='-lpthread' CC=/export/home/uxapps/workshop/SUNWspro/bin/cc
>
>The main reason to use -mt options was to build thread safe PQ Client
>Library.
>We use Postgres mostly on Sparc v240 system with Solaris 8 and above.
>The app demands very high performance and is very extensive db write
>kind of.
>As the latest Postgres version mentions about many performance
>enhancement, we wanted to try before migrating to it.
>I would be highly obliged if you guys have some performance figures or
>benchmark results for Solaris environment. Could you please send
>pointers to it.
>If you have some input specific to compilation that too would be of much
>help.
>
>Thanks,
>Rajan Bhide
>
>-----Original Message-----
>From: Alan Stange [mailto:stange@rentec.com]
>Sent: Friday, December 09, 2005 1:06 AM
>To: Tom Lane
>Cc: Bhide, Rajan; pgsql-novice@postgresql.org
>Subject: Re: [NOVICE] Compile/Link Error for Postgres 8.1.0 on Solaris 8
>
>
>Tom Lane wrote:
>> Alan Stange <stange@rentec.com> writes:
>>
>>> Bhide, Rajan wrote:
>>>
>>>> ./configure --without-readline --enable-thread-safety CFLAGS=-xO4
>>>> -D_REENTRANT -xipo -mt -lpthread
>>>> CC=/export/home/uxapps/workshop/SUNWspro/bin/cc
>>>>
>>
>>
>>> Given that you've enabled -xipo, and the error is related to ipo, I'd
>>> suggest dropping that option for now.
>>>
>>
>> Putting -lpthread into CFLAGS seems pretty foolish as well.  If you
>> needed to specify that explicitly (which you do not) it would belong
>> in LDFLAGS --- putting it in CFLAGS is pretty certain to screw up link
>
>> order and so on.  And what is -mt?
>>
>>             regards, tom lane
>>
>     -mt  Passes D_REENTRANT to preprocessor. Appends -lthread
>          after all other user-specified libraries on the command
>          line.  If you are doing your own multithread coding,
>          you must use this option in the compile and link steps.
>          To obtain faster execution, this option requires a mul-
>          tiprocessor system. On a single-processor system, the
>          resulting executable usually runs more slowly with this
>          option.
>
>
>"This email message and any attachments are confidential information of Starent Networks, Corp. The information
transmittedmay not be used to create or change any contractual obligations of Starent Networks, Corp.  Any review,
retransmission,dissemination or other use of, or taking of any action in reliance upon this e-mail and its attachments
bypersons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please
notifythe sender immediately -- by replying to this message or by sending an email to postmaster@starentnetworks.com --
anddestroy all copies of this message and any attachments without reading or disclosing their contents. Thank you." 
>
>---------------------------(end of broadcast)---------------------------
>TIP 6: explain analyze is your friend
>

--
Aly S.P Dharshi
aly.dharshi@telus.net

     "A good speech is like a good dress
      that's short enough to be interesting
      and long enough to cover the subject"