views:

963

answers:

3

Trying to use the RHEL5.3 GCC 4.3.2 compiler to build my software on that platform. I get the following error no matter what I try when compiling with -O2, but it builds fine without optimization. Any ideas?

/usr/bin/ld: myapp: hidden symbol `void std::__ostream_fill<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, long)' isn't defined
/usr/bin/ld: final link failed: Nonrepresentable section on output

In RHEL5.3, I am using /usr/bin/g++43 for compilation and linking. The correct libstdc++.so is found here:

/usr/lib/gcc/i386-redhat-linux6E/4.3.2/libstdc++.so

which is a text file containing INPUT ( -lstdc++_nonshared /usr/lib/libstdc++.so.6 ).

Wouldn't that mismatch the system stdlibc++ 4.1 version?

A: 

You seem to be running into visibility issues -- can we see your full command line?

For example, what -fvisibility-inlines-hidden does may change at different optimization levels because GCC decides to inline different things.

ephemient
For a component:/usr/bin/g++43 -c -pipe -Wextra -Wcast-qual -Wno-long-long -m32 -O2 -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -D_REENTRANT -D_GNU_SOURCE -DQT_NO_DEBUG -DQT_WEBKIT_LIB [various includes, etc]For the link:/usr/bin/g++43 -Wl,-O1 -Wl,-rpath,/home/hudson/qt4/lib -o myapp [... a ton of .o files] [various static and shared libraries]It is a qmake/qt 4.5 project
Kevin Bowling
Well, I'd have preferred it if you had made that an edit to the question instead of a comment, but oh well :) Hmm, so it's not quite obvious from this; I'll have to try to find a small test case to reproduce this.
ephemient
I was able to reproduce this with the latest Gnucap snapshot (http://www.gnucap.org/devel) -- probably RHEL 5.3 GCC specificI set CC=/usr/bin/gcc43 CXX=/usr/bin/g++43 LINK=/usr/bin/g++43,then ran configure and make. Same error
Kevin Bowling
A: 

It only happens with optimization. Does that give a clue?

+1  A: 

It turns out to be a GCC bug in RHEL 5.3 :-/. https://bugzilla.redhat.com/show_bug.cgi?id=493929. I sent an email to the maintainer, Jakub Jelinek, who said that RHEL 5.4 (which is due out soon) will have a fix and also will bump to GCC 4.4.

A workaround is to use -fno-inline, but this has some obvious drawbacks.

Kevin Bowling