[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: GCC 3.2 on the NetBSD/i386 port



On Mon, Sep 02, 2002 at 10:23:40PM +0200, Martin v. Loewis wrote:
> Joel Baker <lucifer@lightbearer.com> writes:
> 
> > > /tmp/Build/gcc-3.2/gcc-3.2-3.2ds0/build/i386-unknown-netbsdelf1.6./libstdc++-v3/src/.libs/libstdc++.so: undefined reference to `__dso_handle'
> > > /tmp/Build/gcc-3.2/gcc-3.2-3.2ds0/build/i386-unknown-netbsdelf1.6./libstdc++-v3/src/.libs/libstdc++.so: undefined reference to `__cxa_atexit'
> > > collect2: ld returned 1 exit status
> [...]
> > So. Given that this clearly appears to be a workaround, that this was in
> > 3.0 or 3.1, and that it must have been removed for good reason (like, it
> > was itself a workaround to a different flaw) - what is the best way to
> > address this? Is there something in userland that can be tweaked to cope
> > with this, or is this an issue with using NetBSD's libc?
> 
> It isn't that easy to answer. Are these messages from the static
> linker (ld(1)) or the dynamic linker (ld.so.1(1))? If the static
> linker, what binutils version?

I believe they're from the dynamic linker (ld.elf_so), in this case.

> We have to consider __dso_handle and __cxa_atexit separately. For
> __dso_handle, can you tell whether HAVE_GAS_HIDDEN is defined?

root@thenet:/tmp/Build/gcc-3.2-HOLD/gcc-3.2-3.2ds0/src# find . -type f | xargs grep HAVE_GAS_HIDDEN
...
./gcc/config/cris/cris.h:#define HAVE_GAS_HIDDEN 1

(All of the others are .in files for autoconf, ChangeLog entries, or
#ifdef macros in various .c files)

I will note that the __dso_handle references go away if __cxa_atexit is not
enabled.

> For __cxa_atexit, it appears that gcc does not provide a replacement
> implementation if the C library does not provide a definition. Can you
> tell whether libc has a definition for __cxa_atexit? If not, it would
> be a good thing to encourage the NetBSD authors to provide one. This
> is a really useful facility; it unfortunately requires close
> integration into the atexit facility, so it can't really be replaced
> from the ouside. If possible, you should consider hacking libgcc_s.so
> to provide a cxa_atexit implementation that interworks with libc.so's
> atexit.

grep -i cxa /usr/src/lib/libc/stdlib/atexit.* returns nothing; I'm not sure
where else I would look, but that's not promising. I can file a feature
request on it, but it won't show up in the stable tree until at least 1.6++
(1.6 is at RC3 right now). Is there a simple spec, URL, or similar that I
can point at when filing the request?

Hacking libgcc_s.so in the meanwhile is also a possibility, but I would
definitely need a spec to be able to figure out what it needs to do.

> If there is indeed no __cxa_atexit on your system, you have to build
> gcc without that. Notice that --enable-__cxa_atexit is new in gcc
> 3.2. On Linux, using this is always the right thing (since glibc 2.1
> or so); that's why it is activated by default.

Is this something that can be autoconfed or otherwise detected? I can
maintain a patch, though I'd prefer to write one and submit it to the
maintainers, but it would seem wisest (especially with the potential of a
backported patch to the NetBSD libc sometime in the future) to be able to
write one based on actually looking for the item in question, rather than
checking the arch value and having a new entry in rules.defs...
-- 
***************************************************************************
Joel Baker                           System Administrator - lightbearer.com
lucifer@lightbearer.com              http://users.lightbearer.com/lucifer/

Attachment: pgpZqvH3DiGwd.pgp
Description: PGP signature


Reply to: