Linkfailures on amd64 with -fvisibility-inlines-hidden and the libstdc++ headers or symbols
Andreas Pokorny
andreas.pokorny@gmx.de
Thu Jan 27 23:17:00 GMT 2005
Hi,
I currently experiment with the new -fvisibility options for gcc-3.4
and gcc-4.0. And i ran into problems with the basic_string headers.
If i use std::string within a library that gets compiled with
-fvisibility-inlines-hidden, ld is unable to link.
lib.cpp:
#include <string>
int some_function( std::string const& do_something ) __attribute__ ((visibility("default")));
int some_function( std::string const& do_something )
{
std::string another_string;
return 0;
}
g++ -fPIC -fvisibility=hidden -fvisibility-inlines-hidden lib.cpp -c
g++ -shared -fPIC -fvisibility=hidden -fvisibility-inlines-hidden lib.o -o liblib.so
/usr/lib/gcc/x86_64-pc-linux-gnu/4.0.0/../../../../x86_64-pc-linux-gnu/bin/ld:
lib.o: relocation R_X86_64_PC32 against `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()@@GLIBCXX_3.4' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/4.0.0/../../../../x86_64-pc-linux-gnu/bin/ld:
final link failed: Bad value
collect2: ld returned 1 exit status
If i do not use the default constructor of std::string, it works fine. I
noticed similar problems with the destructor and the std::allocator. It
seems like a bad idea to use -fvisibility-inlines-hidden at all. The
problem vanishes if I add __attribute__ ((visibility("default"))) to the
symbols in the string headers. Other inline methods of my own code are not
affected, this happens only in the libstdc++ headers.
I noticed other parties having the same problem:
http://groups.google.de/groups?q=relocation+R_X86_64_PC32+against+making+a+shared+object&hl=de&lr=&selm=ct12kj%242njo%241%40FreeBSD.csie.NCTU.edu.tw&rnum=2
http://bugs.gentoo.org/show_bug.cgi?id=78720
Is this a gcc bug? Or maybe some problem that occurs because the gcc-extern-export
and the new visibility options collide?
Regards
Andreas Pokorny
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20050127/29f3ce9c/attachment.sig>
More information about the Libstdc++
mailing list