Thread

  1. Bug #584: postgresql will not build on Solaris with cc

    PostgreSQL Bugs List <pgsql-bugs@postgresql.org> — 2002-02-12T19:27:10Z

    Andre Blanchard (andre@synchronicity.com) reports a bug with a severity of 1
    The lower the number the more severe it is.
    
    Short Description
    postgresql will not build on Solaris with cc
    
    Long Description
    This is the input to build on Solaris 
    
    OS Version 5.6 5.7 5.8 (same results)
    Ansi C Compiler version cc -V =  4.0, or 5.1 (same results)
    
    I have many arguments to configure, however I believe the relevant one to this bug is the choice of compiler (aka cc vs gcc)
    
    gcc configures and will build fine.
    
    cc will fail with the following error
    
    
    ranlib libpsqlodbc.a
    cc -Xa -G -h libpsqlodbc.so.0 -Wl,-Bsymbolic info.o bind.o columninfo.o connection.o convert.o drvconn.o environ.o execute.o lobj.o md5.o misc.o options.o pgtypes.o psqlodbc.o qresult.o results.o socket.o parse.o statement.o tuple.o tuplelist.o dlg_specific.o odbcapi.o multibyte.o gpps.o -L/home/andre/build/relbf1/sbin/SunOS_56_CC_41 -lnsl -lsocket -lm -R/home/andre/build/relbf1/sbin/SunOS_56_CC_41 -o libpsqlodbc.so.0.27
    ld: fatal: symbol `_fini' is multiply defined:
            (file /opt/SUNWspro/SC4.0/lib/crti.o and file psqlodbc.o);
    ld: fatal: symbol `_init' is multiply defined:
            (file /opt/SUNWspro/SC4.0/lib/crti.o and file psqlodbc.o);
    ld: fatal: File processing errors. No output written to libpsqlodbc.so.0.27
    make[3]: *** [libpsqlodbc.so.0.27] Error 1
    
    
    I would receive this on the first library build, which I corrected with with the following options CFLAGS options to configure
    
    -z muldefs
    
    aka inform the link editor to process code with multiply defined symbols.  This will allow the build to proceed further but it eventually halts at the point indicated in the output above 
    
    
    Sample Code
    I am providing my complete script for completeness.
    
     cat build_pg.template 
    #!/usr/local/bin/bash 
    PATH=/usr/local/jakarta-ant-1.4.1/bin:$PATH ; export PATH
    unset EXTRA_CONFIG_OPTIONS
    if [ ! -z "`echo ${SYNC_PLATFORM} | grep dbg`" ] ; then
            echo Debug
            EXTRA_CONFIG_OPTIONS=`echo --with-debug` ; export EXTRA_CONFIG_OPTIONS
    else
            echo No Debug
    fi
    SRC_DIR=${SYNC_DEV_DIR}/${SYNC_RELEASE}/src/vendor/postgresql/72 ; export SRC_DIR
    SBIN_DIR=${SYNC_DEV_DIR}/${SYNC_RELEASE}/sbin/${SYNC_PLATFORM} ; export SBIN_DIR
    SOBJ_DIR=${SYNC_DEV_DIR}/${SYNC_RELEASE}/obj/${SYNC_PLATFORM}/postgresql-72 ; export SOBJ_DIR
    #NOTE JAVA_HOME is different for each platform
    if [ `uname` = "AIX" ] ; then
    JAVA_HOME=/usr/local/java.130 ; export JAVA_HOME;
    echo Press Return
    read input
    fi
    if [ `uname` = "HP-UX" ] ; then
    JAVA_HOME=/usr/local/java.130 ; export JAVA_HOME;
    fi
    if [ `uname` = "SunOS" ] ; then
    JAVA_HOME=/usr/local/j2sdk1_3_1 ; export JAVA_HOME;
    CONFIGURE_ENV="CC=cc" ; export CONFIGURE_ENV
    CONFIGURE_ENV1="CFLAGS='-z muldefs'" ; export CONFIGURE_ENV1
    fi
    echo EXTRA CONFIG OPTIONS : ${EXTRA_CONFIG_OPTIONS}
    echo CONFIGURE_ENV : ${CONFIGURE_ENV}
    TCL_HOME=${HOME}/build/${SYNC_RELEASE}/src/vendor/tcl/tcl8.3.3 ; export TCL_HOME
    TK_HOME=${HOME}/build/${SYNC_RELEASE}/src/vendor/tk/tk8.3.3 ; export TK_HOME
    TCL_INST=${HOME}/build/${SYNC_RELEASE}/sbin/${SYNC_PLATFORM} ; export TCL_INST
    TK_INST=${HOME}/build/${SYNC_RELEASE}/sbin/${SYNC_PLATFORM} ; export TK_INST
    #VPATH=${SRC_DIR}/src ; export VPATH
    echo "env ${CONFIGURE_ENV} ${CONFIGURE_ENV1} ${SRC_DIR}/configure --srcdir=${SRC_DIR} \
            --prefix=${SOBJ_DIR}/install \
            --enable-locale \
            --enable-multibyte \
            --with-CXX \
            ${EXTRA_CONFIG_OPTIONS} \
            --with-tcl \
            --without-tk \
            --with-java \
            --with-x \
            --with-odbc \
            --with-tclconfig=${TCL_INST} \
            --with-tkconfig=${TK_INST} \
            --with-includes="${SOBJ_DIR}/../tk/include ${SOBJ_DIR}/../tcl/include" \
            --with-libraries=${TCL_INST} \
            --bindir=${SBIN_DIR} \
            --libdir=${SBIN_DIR} "
    env ${CONFIGURE_ENV} CFLAGS='-z muldefs' bash  ${SRC_DIR}/configure --srcdir=${SRC_DIR} \
            --prefix=${SOBJ_DIR}/install \
            --enable-locale \
            --enable-multibyte \
            --with-CXX \
            ${EXTRA_CONFIG_OPTIONS} \
            --with-tcl \
            --without-tk \
            --with-java \
            --with-x \
            --with-odbc \
            --with-tclconfig=${TCL_INST} \
            --with-tkconfig=${TK_INST} \
            --with-includes="${SOBJ_DIR}/../tk/include ${SOBJ_DIR}/../tcl/include" \
            --with-libraries=${TCL_INST} \
            --bindir=${SBIN_DIR} \
            --libdir=${SBIN_DIR}
    make
      
    
    No file was uploaded with this report
    
    
    
  2. Re: Bug #584: postgresql will not build on Solaris with cc

    Tom Lane <tgl@sss.pgh.pa.us> — 2002-02-12T21:14:56Z

    pgsql-bugs@postgresql.org writes:
    > postgresql will not build on Solaris with cc
    
    Which cc, exactly?
    
    I just found out yesterday that /usr/ucb/cc doesn't work very well on
    Solaris; it tries to provide a BSD-ish environment and doesn't really
    succeed.  You want to use the SUNpro compiler directly, or via the
    standard link /usr/ccs/bin/ucbcc.
    
    			regards, tom lane
    
    
  3. Re: Bug #584: postgresql will not build on Solaris with cc

    Nishad Prakash <prakashn@uci.edu> — 2002-02-12T22:10:12Z

    On Tue, 12 Feb 2002, Tom Lane wrote:
    
    > pgsql-bugs@postgresql.org writes:
    > > postgresql will not build on Solaris with cc
    >
    > I just found out yesterday that /usr/ucb/cc doesn't work very well on
    > Solaris; it tries to provide a BSD-ish environment and doesn't really
    > succeed.  You want to use the SUNpro compiler directly, or via the
    > standard link /usr/ccs/bin/ucbcc.
    
    This is indeed important to keep in mind for Solaris users.  However, it
    will not fix the original poster's problem, which was this:
    
    ld: fatal: symbol `_fini' is multiply defined:
            (file /opt/SUNWspro/SC4.0/lib/crti.o and file psqlodbc.o);
    ld: fatal: symbol `_init' is multiply defined:
            (file /opt/SUNWspro/SC4.0/lib/crti.o and file psqlodbc.o);
    
    
    _fini and _init are already defined in the C run time environment (to
    make sure this is true on your system, write a simple 'hello world'
    program, compile and link, and run 'nm' on it).
    
    They are also defined in src/interfaces/odbc/psqlodbc.c.  I am
    speaking of 7.1.3 here, but it seems to be true of whichever version
    the OP was trying to build.
    
    Note the rather disingenuous comment in the code, appearing as it does in
    the Solaris port.
    
    -------------------------------------------------------------------------
    /* These two functions do shared library initialziation on UNIX, well at
     * on Linux. I don't know about other systems.
     */
    
    BOOL
    _init(void)
    {
            getGlobalDefaults(DBMS_NAME, ODBCINST_INI, FALSE);
            return TRUE;
    }
    
    BOOL
    _fini(void)
    {
            return TRUE;
    }
    
    -------------------------------------------------------------------------
    
    After you comment out these two, things should build just fine.  However,
    I have never tested the ODBC interface. so I don't know if things will
    *work* just fine as well.
    
    Cheers,
    
    Nishad
    -- 
    "Underneath the concrete, the dream is still alive" -- Talking Heads