Subject: c++ failing on 1.4.3/i386
To: None <tech-toolchain@NetBSD.ORG>
From: Martin Husemann <>
List: tech-toolchain
Date: 10/16/2000 06:41:31
On NetBSD-i386 1.4.3 the mozilla pkg dies trying to build one of it's libraries
with the command

(line breaks added to increase readability)

c++ -fno-rtti -fno-exceptions -Wall -Wconversion -Wpointer-arith \
  -Wbad-function-cast -Wcast-align -Woverloaded-virtual -Wsynth -Wshadow \
  -pedantic -Wno-long-long -Dunix -O -DNDEBUG -DTRIMMED \
  -Wl,-R/usr/X11R6/lib/mozilla -shared -o nsXPComInit.o \
  -Wl,-R/usr/X11R6/lib/mozilla -Wl,-R/usr/X11R6/lib -L/usr/X11R6/lib \
  -Wl,-R/usr/pkg/lib -L/usr/pkg/lib -Wl,-R/usr/X11R6/lib/mozilla \
  -Wl,-R/usr/X11R6/lib -L/usr/X11R6/lib -Wl,-R/usr/pkg/lib -L/usr/pkg/lib \
  -Wl,--whole-archive ../../dist/lib/libxpcomds_s.a \
  ../../dist/lib/libxpcomio_s.a ../../dist/lib/libxpcomcomponents_s.a \
  ../../dist/lib/libxpcomthreads_s.a ../../dist/lib/libxpcomproxy_s.a \
  ../../dist/lib/libxpcombase_s.a ../../dist/lib/libxptcall.a \
  ../../dist/lib/libxptinfo.a ../../dist/lib/libxpt.a \
  ../../dist/lib/libxptcmd.a ../../dist/lib/libmozreg_s.a \
  -Wl,--no-whole-archive -L../../dist/bin -lplds4 -lplc4 -lnspr4 -lintl -lutil \

This results in:

/usr/lib/libgcc.a(_fixunsxfsi.o): Definition of symbol `___fixunsxfsi' (multiply defined)
/usr/lib/libgcc.a(_floatdixf.o): Definition of symbol `___floatdixf' (multiply defined)
/usr/lib/libgcc.a(_fixxfdi.o): Definition of symbol `___fixxfdi' (multiply defined)

and a few dozen more similar errors.

Adding a -v to that invocation shows:

Using builtin specs.
gcc version egcs-2.91.60 19981201 (egcs-1.1.1 release)
 /usr/libexec/collect2 -Bshareable -o /usr/lib/c++rt0.o \
  -L/usr/X11R6/lib -L/usr/pkg/lib -L/usr/X11R6/lib -L/usr/pkg/lib \
  -L../../dist/bin -L/usr/libexec -R/usr/X11R6/lib/mozilla nsXPComInit.o \
  -R/usr/X11R6/lib/mozilla -R/usr/X11R6/lib -R/usr/pkg/lib \
  -R/usr/X11R6/lib/mozilla -R/usr/X11R6/lib -R/usr/pkg/lib --whole-archive \
  ../../dist/lib/libxpcomds_s.a ../../dist/lib/libxpcomio_s.a \
  ../../dist/lib/libxpcomcomponents_s.a ../../dist/lib/libxpcomthreads_s.a \
  ../../dist/lib/libxpcomproxy_s.a ../../dist/lib/libxpcombase_s.a \
  ../../dist/lib/libxptcall.a ../../dist/lib/libxptinfo.a \
  ../../dist/lib/libxpt.a ../../dist/lib/libxptcmd.a \
  ../../dist/lib/libmozreg_s.a --no-whole-archive -lplds4 -lplc4 -lnspr4 -lintl \
  -lutil -lstdc++ -lm -lgcc -lc -lgcc

Searching through the objects and archives listed on the commandline with nm
and grep didn't show any symbol (nor reference) of the duplicates. So this
must happen due to the -lgcc -lc -lgcc automatically added by c++.

Why? How can we fix this?

The obvious workaround is to use ld directly and add /usr/lib/c++rt0.o
to the command line - but that realy is a hack!

The configure scripts were explicitly changed to invoke c++ when possible
instead of doing the ld hack on advice from Todd (sometime last year, the
shared-libs-vs-c++-constructors thread).