I tried building libsigc++-2.0.6 (http://libsigc.sourceforge.net/) on
AIX 5.2 with GCC 3.3.2 and 3.4.2. GCC 3.4.2 worked fine. However, with
GCC 3.3.2, I ran into the following problem:
  ..
  /bin/sh ../libtool --mode=link g++  -O2 -mcpu=common
  -Wl,-blibpath:/opt/TWWfsw/gcc332r/lib -Wl,-brtl -Wl,-blibpath:/usr/lib
  -o test_trackable  test_trackable.o ../sigc++/libsigc-2.0.la
  g++ -O2 -mcpu=common -Wl,-blibpath:/opt/TWWfsw/gcc332r/lib
  -Wl,-brtl -Wl,-blibpath:/usr/lib -o .libs/test_trackable test_trackable.o
  -L../sigc++/.libs -lsigc-2.0 -L/opt/TWWfsw/gcc332/lib -lstdc++
  -Wl,-blibpath:/opt/TWWfsw/libsigc++20/lib/gcc32:\
  /opt/TWWfsw/gcc332/lib:/opt/TWWfsw/gcc332r/lib:/usr/lib
  ld: 0711-317 ERROR: Undefined symbol: _GLOBAL__F_signal.ccAo6sTo
  ld: 0711-317 ERROR: Undefined symbol: _GLOBAL__F_functors_slot.cccL3Cqq

Because I set LDFLAGS="-Wl,-brtl" during the ./configure state,
libtool will create a static and shared version of the libsigc++
library. The two undefined symbols, _GLOBAL__F_signal.ccAo6sTo and
_GLOBAL__F_functors_slot.cccL3Cqq, come from the static version of the
libsigc++ library, ../sigc++/.libs/libsigc-2.0.a. I thought it odd the
linker would use ../sigc++/.libs/libsigc-2.0.a rather than
../sigc++/.libs/libsigc-2.0.so. However, after adding "-v -Wl,-v" to
the final link command, I found the following:
  g++ -v -Wl,-v -O2 -mcpu=common -Wl,-blibpath:/opt/TWWfsw/gcc332r/lib
  -Wl,-brtl -Wl,-blibpath:/usr/lib -o .libs/test_trackable test_trackable.o
  -L../sigc++/.libs -lsigc-2.0 -L/opt/TWWfsw/gcc332/lib -lstdc++
  -Wl,-blibpath:/opt/TWWfsw/libsigc++20/lib/gcc32:\
  /opt/TWWfsw/gcc332/lib:/opt/TWWfsw/gcc332r/lib:/usr/lib
  ...
  /opt/TWWfsw/gcc332/bin/g++ -x c -c -o /tmp//ccI74qdc.o -mcpu=common
  -fno-exceptions -w /tmp//ccgMXWab.c
  ...

Looking at the /tmp/ccgMXWab.c file, I see:
  extern void *x13 __asm__ ("_GLOBAL__F_signal.ccAo6sTo");
  extern void *x19 __asm__ ("_GLOBAL__F_functors_slot.cccL3Cqq");

If I change these two lines to match the corresponding entries in
../sigc++/.libs/libsigc-2.0.so:
  extern void *x13 __asm__ ("_GLOBAL__F_signal.ccKvSdiF");
  extern void *x19 __asm__ ("_GLOBAL__F_functors_slot.ccHOMFb6");
then the link step that failed above succeeds.

The problem is that collect2 first looks in ".a" libraries for symbols and then
in ".so" libraries. It ignores -brtl (which redefines the library search order
to ".so" first and ".a" second).

-- 
           Summary: collect2 uses wrong search order if -brtl specified
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: other
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bugzilla-gcc at thewrittenword dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: powerpc-ibm-aix5.2.0.0
  GCC host triplet: powerpc-ibm-aix5.2.0.0
GCC target triplet: powerpc-ibm-aix5.2.0.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18720

Reply via email to