Ticket #83 (closed defect: worksforme)

Opened 2 years ago

Last modified 5 months ago

libpqxx-2.6.8 build failure using gcc-4.1.1 (Fedora Core 6)... works on Centos5...

Reported by: rdieter@math.unl.edu Assigned to: jtv
Priority: normal Milestone:
Component: Version:
Severity: Keywords: ""
Cc: andreas.bierfert@lowlatency.de

Description (Last modified by jtv)

Build fails apparently due to use of -fvisibility (and getting warnings) combined with -Werror. End of build looks like:

 if /bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H  -I../include -I../include -I/usr/include    -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -Werror -MT prepared_statement.lo -MD -MP -MF ".deps/prepared_statement.Tpo" -c -o prepared_statement.lo prepared_statement.cxx; \
        then mv -f ".deps/prepared_statement.Tpo" ".deps/prepared_statement.Plo"; else rm -f ".deps/prepared_statement.Tpo"; exit 1; fi
 g++ -DHAVE_CONFIG_H -I../include -I../include -I/usr/include -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -Werror -MT prepared_statement.lo -MD -MP -MF .deps/prepared_statement.Tpo -c prepared_statement.cxx  -fPIC -DPIC -o .libs/prepared_statement.o
cc1plus: warnings being treated as errors
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_algobase.h: In function '_BI2 std::copy_backward(_BI1, _BI1, _BI2) [with _BI1 = __gnu_cxx::__normal_iterator<pqxx::prepare::internal::prepared_def::param*, std::vector<pqxx::prepare::internal::prepared_def::param, std::allocator<pqxx::prepare::internal::prepared_def::param> > >, _BI2 = __gnu_cxx::__normal_iterator<pqxx::prepare::internal::prepared_def::param*, std::vector<pqxx::prepare::internal::prepared_def::param, std::allocator<pqxx::prepare::internal::prepared_def::param> > >]':
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/vector.tcc:257:   instantiated from 'void std::vector<_Tp, _Alloc>::_M_insert_aux(__gnu_cxx::__normal_iterator<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer, std::vector<_Tp, _Alloc> >, const _Tp&) [with _Tp = pqxx::prepare::internal::prepared_def::param, _Alloc = std::allocator<pqxx::prepare::internal::prepared_def::param>]'
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_vector.h:610:   instantiated from 'void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = pqxx::prepare::internal::prepared_def::param, _Alloc = std::allocator<pqxx::prepare::internal::prepared_def::param>]'
prepared_statement.cxx:139:   instantiated from here
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_algobase.h:480: warning: lowering visibility of 'static _BI2 std::__copy_backward_normal<true, true>::copy_b_n(_BI1, _BI1, _BI2) [with _BI1 = __gnu_cxx::__normal_iterator<pqxx::prepare::internal::prepared_def::param*, std::vector<pqxx::prepare::internal::prepared_def::param, std::allocator<pqxx::prepare::internal::prepared_def::param> > >, _BI2 = __gnu_cxx::__normal_iterator<pqxx::prepare::internal::prepared_def::param*, std::vector<pqxx::prepare::internal::prepared_def::param, std::allocator<pqxx::prepare::internal::prepared_def::param> > >]' to match its type
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_algobase.h: In static member function 'static _BI2 std::__copy_backward_normal<true, true>::copy_b_n(_BI1, _BI1, _BI2) [with _BI1 = __gnu_cxx::__normal_iterator<pqxx::prepare::internal::prepared_def::param*, std::vector<pqxx::prepare::internal::prepared_def::param, std::allocator<pqxx::prepare::internal::prepared_def::param> > >, _BI2 = __gnu_cxx::__normal_iterator<pqxx::prepare::internal::prepared_def::param*, std::vector<pqxx::prepare::internal::prepared_def::param, std::allocator<pqxx::prepare::internal::prepared_def::param> > >]':
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_algobase.h:517:   instantiated from '_BI2 std::copy_backward(_BI1, _BI1, _BI2) [with _BI1 = __gnu_cxx::__normal_iterator<pqxx::prepare::internal::prepared_def::param*, std::vector<pqxx::prepare::internal::prepared_def::param, std::allocator<pqxx::prepare::internal::prepared_def::param> > >, _BI2 = __gnu_cxx::__normal_iterator<pqxx::prepare::internal::prepared_def::param*, std::vector<pqxx::prepare::internal::prepared_def::param, std::allocator<pqxx::prepare::internal::prepared_def::param> > >]'
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/vector.tcc:257:   instantiated from 'void std::vector<_Tp, _Alloc>::_M_insert_aux(__gnu_cxx::__normal_iterator<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer, std::vector<_Tp, _Alloc> >, const _Tp&) [with _Tp = pqxx::prepare::internal::prepared_def::param, _Alloc = std::allocator<pqxx::prepare::internal::prepared_def::param>]'
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_vector.h:610:   instantiated from 'void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = pqxx::prepare::internal::prepared_def::param, _Alloc = std::allocator<pqxx::prepare::internal::prepared_def::param>]'
prepared_statement.cxx:139:   instantiated from here
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_algobase.h:480: warning: lowering visibility of 'static _BI2 std::__copy_backward_normal<true, true>::copy_b_n(_BI1, _BI1, _BI2) [with _BI1 = __gnu_cxx::__normal_iterator<pqxx::prepare::internal::prepared_def::param*, std::vector<pqxx::prepare::internal::prepared_def::param, std::allocator<pqxx::prepare::internal::prepared_def::param> > >, _BI2 = __gnu_cxx::__normal_iterator<pqxx::prepare::internal::prepared_def::param*, std::vector<pqxx::prepare::internal::prepared_def::param, std::allocator<pqxx::prepare::internal::prepared_def::param> > >]' to match its type
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_algobase.h: In function '_BI2 std::__copy_backward_aux(_BI1, _BI1, _BI2) [with _BI1 = pqxx::prepare::internal::prepared_def::param*, _BI2 = pqxx::prepare::internal::prepared_def::param*]':
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_algobase.h:482:   instantiated from 'static _BI2 std::__copy_backward_normal<true, true>::copy_b_n(_BI1, _BI1, _BI2) [with _BI1 = __gnu_cxx::__normal_iterator<pqxx::prepare::internal::prepared_def::param*, std::vector<pqxx::prepare::internal::prepared_def::param, std::allocator<pqxx::prepare::internal::prepared_def::param> > >, _BI2 = __gnu_cxx::__normal_iterator<pqxx::prepare::internal::prepared_def::param*, std::vector<pqxx::prepare::internal::prepared_def::param, std::allocator<pqxx::prepare::internal::prepared_def::param> > >]'
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_algobase.h:517:   instantiated from '_BI2 std::copy_backward(_BI1, _BI1, _BI2) [with _BI1 = __gnu_cxx::__normal_iterator<pqxx::prepare::internal::prepared_def::param*, std::vector<pqxx::prepare::internal::prepared_def::param, std::allocator<pqxx::prepare::internal::prepared_def::param> > >, _BI2 = __gnu_cxx::__normal_iterator<pqxx::prepare::internal::prepared_def::param*, std::vector<pqxx::prepare::internal::prepared_def::param, std::allocator<pqxx::prepare::internal::prepared_def::param> > >]'
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/vector.tcc:257:   instantiated from 'void std::vector<_Tp, _Alloc>::_M_insert_aux(__gnu_cxx::__normal_iterator<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer, std::vector<_Tp, _Alloc> >, const _Tp&) [with _Tp = pqxx::prepare::internal::prepared_def::param, _Alloc = std::allocator<pqxx::prepare::internal::prepared_def::param>]'
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_vector.h:610:   instantiated from 'void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = pqxx::prepare::internal::prepared_def::param, _Alloc = std::allocator<pqxx::prepare::internal::prepared_def::param>]'
prepared_statement.cxx:139:   instantiated from here
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_algobase.h:408: warning: lowering visibility of 'static _BI2 std::__copy_backward<_BoolType, std::random_access_iterator_tag>::copy_b(_BI1, _BI1, _BI2) [with _BI1 = pqxx::prepare::internal::prepared_def::param*, _BI2 = pqxx::prepare::internal::prepared_def::param*, bool _BoolType = false]' to match its type
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_algobase.h: In static member function 'static _BI2 std::__copy_backward<_BoolType, std::random_access_iterator_tag>::copy_b(_BI1, _BI1, _BI2) [with _BI1 = pqxx::prepare::internal::prepared_def::param*, _BI2 = pqxx::prepare::internal::prepared_def::param*, bool _BoolType = false]':
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_algobase.h:443:   instantiated from '_BI2 std::__copy_backward_aux(_BI1, _BI1, _BI2) [with _BI1 = pqxx::prepare::internal::prepared_def::param*, _BI2 = pqxx::prepare::internal::prepared_def::param*]'
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_algobase.h:482:   instantiated from 'static _BI2 std::__copy_backward_normal<true, true>::copy_b_n(_BI1, _BI1, _BI2) [with _BI1 = __gnu_cxx::__normal_iterator<pqxx::prepare::internal::prepared_def::param*, std::vector<pqxx::prepare::internal::prepared_def::param, std::allocator<pqxx::prepare::internal::prepared_def::param> > >, _BI2 = __gnu_cxx::__normal_iterator<pqxx::prepare::internal::prepared_def::param*, std::vector<pqxx::prepare::internal::prepared_def::param, std::allocator<pqxx::prepare::internal::prepared_def::param> > >]'
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_algobase.h:517:   instantiated from '_BI2 std::copy_backward(_BI1, _BI1, _BI2) [with _BI1 = __gnu_cxx::__normal_iterator<pqxx::prepare::internal::prepared_def::param*, std::vector<pqxx::prepare::internal::prepared_def::param, std::allocator<pqxx::prepare::internal::prepared_def::param> > >, _BI2 = __gnu_cxx::__normal_iterator<pqxx::prepare::internal::prepared_def::param*, std::vector<pqxx::prepare::internal::prepared_def::param, std::allocator<pqxx::prepare::internal::prepared_def::param> > >]'
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/vector.tcc:257:   instantiated from 'void std::vector<_Tp, _Alloc>::_M_insert_aux(__gnu_cxx::__normal_iterator<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer, std::vector<_Tp, _Alloc> >, const _Tp&) [with _Tp = pqxx::prepare::internal::prepared_def::param, _Alloc = std::allocator<pqxx::prepare::internal::prepared_def::param>]'
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_vector.h:610:   instantiated from 'void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = pqxx::prepare::internal::prepared_def::param, _Alloc = std::allocator<pqxx::prepare::internal::prepared_def::param>]'
prepared_statement.cxx:139:   instantiated from here
/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_algobase.h:408: warning: lowering visibility of 'static _BI2 std::__copy_backward<_BoolType, std::random_access_iterator_tag>::copy_b(_BI1, _BI1, _BI2) [with _BI1 = pqxx::prepare::internal::prepared_def::param*, _BI2 = pqxx::prepare::internal::prepared_def::param*, bool _BoolType = false]' to match its type
make[1]: *** [prepared_statement.lo] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory `/builddir/build/BUILD/libpqxx-2.6.8/src'

Attachments

Change History

09/20/06 14:34:08 changed by rdieter@math.unl.edu

Hmm... maybe not, on second glance, I don't see any -fvisibility flags in there, though that appears to be what the warnings are referring to.

09/21/06 00:40:15 changed by jtv

  • description changed.

09/21/06 02:22:25 changed by jtv

We do use gcc's visibility specifications if they're available, so that's no big surprise. But I'm not sure what the problem is here... All I see happening on the libpqxx end of the error is a fairly straightforward invocation of the standard library.

The only possible complication I see there is with constness of the temporary object passed there. Does the problem go away if you change line 139 in src/prepared_statement.cxx from this:

parameters.push_back(param(sqltype,treatment));

to this:

param p(sqltype, treatment);
parameters.push_back(p);

?

It's a long shot, but the only thing I can think of right now besides the compiler just "being difficult."

09/21/06 10:30:45 changed by rdieter@math.unl.edu

After applying suggested patch:

--- prepared_statement.cxx.gcc41        2006-08-29 11:29:23.000000000 -0400
+++ prepared_statement.cxx      2006-09-21 10:27:02.000000000 -0400
@@ -136,7 +136,8 @@
        const PGSTD::string &sqltype,
        param_treatment treatment)
 {
-  parameters.push_back(param(sqltype,treatment));
+  param p(sqltype,treatment);
+  parameters.push_back(p);
 }

Build (still) fails similarly:

/usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/bits/stl_algobase.h:408: warning: lowering visibility of 'static _BI2 std::__copy_backward<_BoolType, std::random_access_iterator_tag>::copy_b(_BI1, _BI1, _BI2) [with _BI1 = pqxx::prepare::internal::prepared_def::param*, _BI2 = pqxx::prepare::internal::prepared_def::param*, bool _BoolType = false]' to match its type
make: *** [prepared_statement.lo] Error 1

My quick-n-dirty fix (for now), was to simply remove -Werror from CXXFLAGS.

09/21/06 13:36:02 changed by anonymous

  • cc set to andreas.bierfert@lowlatency.de.

09/30/06 04:27:13 changed by jtv

  • component changed from other to portability.

I haven't been able to reproduce this on Debian systems with g++ 4.1.2 (4.2 preview). So this may simply have been a compiler bug.

If you don't mind, I'll just close this one!

10/06/06 06:48:43 changed by jtv

  • status changed from new to closed.
  • resolution set to worksforme.

02/14/07 12:09:01 changed by jtv

The warning appears to be the product of a Fedora patch to g+++. Until Fedora or someone else documents what it's for exactly, there's not much we can do except recommend that people (a) remove -Werror from their CXXFLAGS, (b) add -Wno-attributes to their CXXFLAGS, or (c) not use the Fedora-patched versions of g++.

04/23/07 13:36:50 changed by anonymous

Note: You have to change both of the Makefiles. (one in the main dir and the other in the src dir)

This problem happens on RHEL5 and Centos5, too. (since they're all derived from Fedora Core)

Here's the %build section that was necessary to get the rpmbuild to work:

%build CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%prefix --sysconfdir="/etc" --mandir=%{_mandir} --enable-shared

# Need to remove the -Werror cat Makefile | sed -e 's/CXXFLAGS = -g -O2 -Werror$/CXXFLAGS = -g -O2/' > Makefile.tmp mv Makefile.tmp Makefile

# Need to remove the -Werror from the src Makefile, too cat src/Makefile | sed -e 's/CXXFLAGS = -g -O2 -Werror$/CXXFLAGS = -g -O2/' > src/Makefile.tmp mv src/Makefile.tmp src/Makefile

make

07/16/07 17:14:37 changed by Jacob Rief <jacob.rief@gmx.at>

Disabeling the warning just shifts the problem from compilation to linking. Here is my solution tested on Fedora 7. Apply this patch. This forces the compiler to export the missing symbol into the shared library.

diff -ur libpqxx-2.6.9/include/pqxx/result.hxx libpqxx-2.6.9-visibility/include/pqxx/result.hxx --- libpqxx-2.6.9/include/pqxx/result.hxx 2007-01-29 20:18:52.000000000 +0100 +++ libpqxx-2.6.9-visibility/include/pqxx/result.hxx 2007-07-16 22:45:53.000000000 +0200 @@ -60,7 +60,7 @@

~result_data();

};

-void freemem_result_data(result_data *) throw (); +attribute ((visibility("default"))) void freemem_result_data(result_data *) throw ();

template<> inline void PQAlloc<result_data>::freemem() throw () { freemem_result_data(m_Obj); } } // namespace internal

diff -ur libpqxx-2.6.9/src/result.cxx libpqxx-2.6.9-visibility/src/result.cxx --- libpqxx-2.6.9/src/result.cxx 2007-01-29 20:18:53.000000000 +0100 +++ libpqxx-2.6.9-visibility/src/result.cxx 2007-07-16 22:46:17.000000000 +0200 @@ -44,7 +44,7 @@

pqxx::internal::result_data::~result_data() { PQclear(data); }

-void pqxx::internal::freemem_result_data(result_data *d) throw () { delete d; } +attribute ((visibility("default"))) void pqxx::internal::freemem_result_data(result_data *d) throw () { delete d; }

pqxx::result::result(pqxx::internal::pq::PGresult *rhs,

07/17/07 04:31:09 changed by jtv

You seem to be working off older code; the current development tree's result.hxx declares freemem_result_data() as PQXX_LIBEXPORT. That change was a fix for #103.

With that, I think the change in result.cxx should not be needed.

09/05/07 18:10:11 changed by kinneym@redacesolutions.com

  • summary changed from libpqxx-2.6.8 build failure using gcc-4.1.1 (Fedora Core 6) to libpqxx-2.6.8 build failure using gcc-4.1.1 (Fedora Core 6)... works on Centos5....

Many thanks to everyone's help. (especially jtv!!!) I was able to build the rpm on Centos from 2.6.9 tarball. I suspect it will work fine on Fedora and Red Hat Enterprise Linux boxes as well.

Here's the %build section of the spec file: === start of the %build section ==== %build CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%prefix --sysconfdir="/etc" --mandir=%{_mandir} --enable-shared # Need to remove the -Werror cat Makefile | sed -e 's/CXXFLAGS = -g -O2 -Werror$/CXXFLAGS = -g -O2/' > Makefile.tmp mv Makefile.tmp Makefile # Need to remove the -Werror from the src Makefile, too cat src/Makefile | sed -e 's/CXXFLAGS = -g -O2 -Werror$/CXXFLAGS = -g -O2/' > src/Makefile.tmp mv src/Makefile.tmp src/Makefile # Need to add PQXX_LIBEXPORT to the freemem_result_data function declaration cat include/pqxx/result.hxx | sed -e 's/void freemem_result_data/void PQXX_LIBEXPORT freemem_result_data/' > include/pqxx/result.hxx.tmp; mv -f include/pqxx/result.hxx.tmp include/pqxx/result.hxx make

end of the %build section

With that, I was able to build the rpm *AND* link against the library.

03/26/08 12:46:07 changed by stic6021@yahoo.com

Gents,

Thank you for the information in this ticket. With it, I was also able to build cleanly under CentOS 5.1. I took a slightly different approach, in that I added "-Wno-attributes" at configure time:

CXXFLAGS="-g -O2 -Wno-attributes" ./configure

After that, a trivial patch was made to result.hxx:

--- include/pqxx/result.hxx     2007-01-29 19:18:52.000000000 +0000
+++ include/pqxx/result.hxx     2008-03-26 15:47:17.000000000 +0000
@@ -60,7 +60,7 @@
   ~result_data();
 };

-void freemem_result_data(result_data *) throw ();
+void PQXX_LIBEXPORT freemem_result_data(result_data *) throw ();
 template<> inline
 void PQAlloc<result_data>::freemem() throw () { freemem_result_data(m_Obj); }
 } // namespace internal

From there, the standard build procedure (make; make install) will take you the rest of the way. "make check" will even declare "All 95 tests passed". Can't beat that.

Once more, thank you for the information here.


Add/Change #83 (libpqxx-2.6.8 build failure using gcc-4.1.1 (Fedora Core 6)... works on Centos5...)




Change Properties
Action