Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 May 2003 18:40:22 +0200 (CEST)
From:      Gerald Pfeifer <gerald@FreeBSD.org>
To:        Keith Bostic <bostic@abyssinian.sleepycat.com>
Cc:        freebsd-bugs@FreeBSD.org
Subject:   Re: gnu/13525: gcc fails load against library with both C++ and C modules
Message-ID:  <Pine.BSF.4.55.0305221826360.81189@naos.dbai.tuwien.ac.at>
In-Reply-To: <200305211400.h4LE06nx008396@abyssinian.sleepycat.com>
References:  <200305211400.h4LE06nx008396@abyssinian.sleepycat.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 21 May 2003, Keith Bostic wrote:
> Your analysis misses the point I tried to make -- if you write
> a C program, which only uses C library modules, why should a C++
> compiler be needed?

You don't actually need the C++ _compiler_, but C++ code generated by GCC
needs to link in some support library.

This can be accomplished by explicitly specifying this library or by
using the g++ driver instead of the gcc to perform the final linkage.

> Neither the C code you wrote, nor the C library modules you loaded,
> should have "used any C++ library routines (directly or indirectly)" --
> why does the act of loading against a library that contains both C and
> C++ modules, suddenly require use of a C++ compiler?

You don't need a C++ compiler, but the C++ modules require you to link
with libstdc++ or (as of GCC 3.0) libsupc++.

In fact, GCC 3 switch to a minimal library like libsupc++ also to help
users like you who don't really need a full C++ library.

> There shouldn't be any "additional libraries" required -- it's
> a program written entirely in C, it never loaded a C++ anything,
> why would there be any need for additional C++ libraries!?

The (nice) example program added to the PR by someone else used iostream,
so in that case one explictly needs full C++ libraries, but even if we
remove that use of iostream, current GCCs will complain about

  __gxx_personality_v0

missing.  That is, the problem you were seeing gut improved, indeed, and
if you just add -lsupc++ to your linker command, everything is fine (and
you can indeed link using gcc).

> I mean, it's probably that there's something that's getting magically
> loaded out of the library, just because it exists in the library, but my
> point is there's no reason for that to happen that I can think of.

Intuitively I agree with you, but would you mind raising this issue on
the gcc@gcc.gnu.org list where you can reach those GCC developers who
have more in depth knowledge of that?

(This issue is not FreeBSD-specific, as has also been observed by other
committers, that's why I have closed the PR now.)

Gerald



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.55.0305221826360.81189>