Received: from SOUTH-STATION-ANNEX.MIT.EDU by po7.MIT.EDU (5.61/4.7) id AA25865; Mon, 15 Jan 96 22:33:34 EST
Received: from halloran-eldar.lcs.mit.edu by MIT.EDU with SMTP
	id AA27167; Mon, 15 Jan 96 22:33:34 EST
Received: from freefall.FreeBSD.ORG by halloran-eldar.lcs.mit.edu; (5.65/1.1.8.2/19Aug95-0530PM)
	id AA14394; Mon, 15 Jan 1996 22:32:50 -0500
Received: (from root@localhost)
          by freefall.freebsd.org (8.7.3/8.7.3) id TAA05959
          for cvs-committers-outgoing; Mon, 15 Jan 1996 19:31:19 -0800 (PST)
Received: from austin.polstra.com (austin.polstra.com [206.213.73.10])
          by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id TAA05951
          for <CVS-committers@freefall.freebsd.org>; Mon, 15 Jan 1996 19:31:12 -0800 (PST)
Received: from austin.polstra.com (jdp@localhost) by austin.polstra.com (8.6.12/8.6.12) with ESMTP id TAA22202; Mon, 15 Jan 1996 19:31:07 -0800
Message-Id: <199601160331.TAA22202@austin.polstra.com>
To: Nate Williams <nate@sri.MT.net>
Cc: CVS-committers@freefall.freebsd.org
Subject: Re: cvs commit: src/lib/csu/i386 c++rt0.c 
In-Reply-To: Your message of "Mon, 15 Jan 1996 20:19:06 MST."
             <199601160319.UAA02972@rocky.sri.MT.net> 
Date: Mon, 15 Jan 1996 19:31:07 -0800
From: John Polstra <jdp@polstra.com>
Sender: owner-cvs-committers@FreeBSD.ORG
Precedence: bulk

Nate wrote:

> To get C++ constructors/destructors called correctly, we need to
> have this code linked into all shlibs, right?  Does this mean that
> we won't have to do anything special to get C++ programs working
> under FreeBSD?

Well, you only _have_ to link c++rt0.o into the C++ shared libraries,
i.e., those libraries that have static constructors or destructors.  But
with the change I made to c++rt0.o, it's now harmless to also link it
into other shared libraries.  So the idea is, that we will just _always_
link it into _all_ shared libraries.  Then, we won't have to do anything
special for C++ libraries.

> Is there any way we can 'automate' this?

In my opinion, we should not be using "ld" directly to build shared
libraries.  We ought to be building them with "cc -shared ...".  That's
how it's done everywhere else with gcc.

My plan is to fix our "cc" so that "cc -shared" will always link
c++rt0.o into the shared library it's building.  (That's a trivial
change, by the way.)  Once that's done, we can change the rule in
"bsd.lib.mk" to use "cc -shared" instead of "ld -Bshareable".

At that point, the process of building a shared library, for any
language, will be fully automated.

Even if people resist (for whatever reason) changing "bsd.lib.mk"
to use "cc -shared", we can still change it so that it always links
c++rt0.o into a shared library.  Then, again, the process is
automated.

> > soon.  I'm getting ready to send in ports of gcc-2.7.2 and libg++-2.7.1
> > that I've been working on.
> 
> Where are these being sent?  Are you going to send diffs back to the
> FSF?

I meant that I'm getting ready to submit them to the FreeBSD project.
But I also intend to send them to the FSF.

> > In the gcc port, the "-shared" option
> > (for building a shared library) works properly.  But that, of
> > course, depends on the name of c++rt0.o.
> 
> How is this any different from our current scheme of using 'ld' to build
> shlibs?

"gcc -shared" knows about linking in c++rt0.o, and does it
automatically.  If you use "ld" directly, you have to link in
c++rt0.o by hand.

-- John
