Project

General

Profile

Bug #14788

librados (C++) linker error (undefined reference)

Added by Jesse Williamson over 3 years ago. Updated almost 3 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
-
Target version:
-
Start date:
02/17/2016
Due date:
% Done:

0%

Source:
Community (dev)
Tags:
Backport:
infernalis
Regression:
Yes
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:

Description

When compiling a patched librados C++ example (or other C++ programs-- see included patchfile), pointing to the headers in the git repository causes linker errors
against librados (note that the stock Makefile uses only the system-wide headers and libraries, so here we're manually pointing at
the local build):

g++ -g -c hello_world.cc -o hello_world.o -std=c++0x -I../../src/include
g++ -I../../src/include -g hello_world.o -o librados_hello_world -Wl,-rpath,../../../ceph/src/.libs -L../../../ceph/src/.libs/ -lrados
hello_world.o: In function `ceph::buffer::list::iterator_impl<false>::iterator_impl(ceph::buffer::list*, unsigned int)':
/home/jwilliamson/work/ceph/ceph/examples/librados/../../src/include/rados/buffer.h:289: undefined reference to `ceph::buffer::list::iterator_impl<false>::advance(int)'

Using the system-wide headers results in successful linkage:
g++ -g -c hello_world.cc -o hello_world.o -std=c++0x
g++ -g hello_world.o -o librados_hello_world -Wl,-rpath,../../../ceph/src/.libs -L../../../ceph/src/.libs/ -lrados

0001-examples-librados-hello_world.cc-missing-semicolon.patch View (950 Bytes) Jesse Williamson, 02/17/2016 02:57 PM


Related issues

Related to Ceph - Bug #13429: bufferlist::iterator no longer ABI compatible Resolved 10/09/2015
Copied to Ceph - Backport #14916: infernalis: librados (C++) linker error (undefined reference) Rejected

Associated revisions

Revision 6c645780 (diff)
Added by Kefu Chai over 3 years ago

buffer: hide iterator_impl symbols

buffer::list::iterator_impl symbols are referenced by const_iterator
and iterator, and are exposed as weak symbols. if a source file is
compiled using the buffer.h, the produced object file will reference
these symbols as well, so we'd better hiding them and avoid using
them in the header file.
as a side-effect, buffer::list::const_iterator is also hidden, but
currently we don't have any librados client using this class, so
we can just leave it as an internal class at this moment.

Fixes: #14788
Signed-off-by: Kefu Chai <>

History

#1 Updated by Joao Eduardo Luis over 3 years ago

  • Source changed from other to Community (dev)

#2 Updated by Kefu Chai over 3 years ago

  • Status changed from New to Verified
  • Assignee set to Kefu Chai

so it sounds like a regression after introducing the buffer::list::const_iterator.

#3 Updated by Brad Hubbard over 3 years ago

What version is this?

That missing semicolon was fixed last year.

I can't reproduce this behaviour on master, can you Jesse?

#4 Updated by Kefu Chai over 3 years ago

  • Related to Bug #13429: bufferlist::iterator no longer ABI compatible added

#5 Updated by Kefu Chai over 3 years ago

  • Status changed from Verified to New

this reminds me of #13429.

turns out i was compiling with the header in my source repo, while linking against the packaged librados in system.

#6 Updated by Kefu Chai over 3 years ago

if that's the case which Jesse ran into. it's because the new buffer.h is referencing the symbols of buffer::list::iterator_impl<false>::*. so, if the client code is compiled using the new header file, the resulting object code will need the (weak) symbols of buffer::list::iterator_impl<false>::*.

but if the client code is compiled using the old header file, it will linked just fine with the new library.

the buffer::list::iterator_impl template class was introduced when adding list::const_iterator, in hope to consolidate the shared bits of list::const_iterator and list::iterator. but it introduced some ABI incompatibilities. #13429 addressed some of them by re-exposing the methods offered by list::iterator in hammer using their old symbol names (signatures). but it does not remove the dependency to the buffer::list::iterator_impl symbols.

i will try to add __attribute__ ((visibility ("hidden"))) to the template to hide its symbol to see how it works.

#7 Updated by Kefu Chai over 3 years ago

  • Status changed from New to Need Review

#8 Updated by Kefu Chai over 3 years ago

  • Backport set to infernalis

#9 Updated by Kefu Chai over 3 years ago

  • Status changed from Need Review to Pending Backport

#10 Updated by Nathan Cutler over 3 years ago

  • Copied to Backport #14916: infernalis: librados (C++) linker error (undefined reference) added

#11 Updated by Loic Dachary almost 3 years ago

  • Status changed from Pending Backport to Resolved

Also available in: Atom PDF