public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Joe Buck <jbuck@synopsys.com>
To: greened@eecs.umich.edu
Cc: egcs@cygnus.com
Subject: Re: Template Instantiation
Date: Sun, 08 Feb 1998 18:44:00 -0000	[thread overview]
Message-ID: <199802090242.SAA05477@atrus.synopsys.com> (raw)
In-Reply-To: <Pine.LNX.3.96.980208142831.31547A-100000@drakh.eecs.umich.edu>

> Can someone clarify exactly how template instantiation
> works in egcs?  I'm using x86/Linux/ELF and SPARC/Solaris 
> systems.  

On both of these systems, it works pretty much like it does with Borland
C++.  All needed templates are instantiated in each object file, but
weak symbols are used.  At link time, one weak symbol is used as the
definition.  If you have a recent GNU ld, the duplicate definitions, if
any, get stripped out and are not included in the binary.  If you have
an older linker or are using the Solaris linker, everything works, but
your executable may contain extra copies of some functions.

> I've been using -frepo when linking object files.  When creating 
> liraries, I've been manually instantiating templates though IIRC, 
> someone mentioned that this wasn't necessary.

You're better off using no flags at all and just allowing things to work.

> In the (very outdated) g++ FAQ at www.cygnus.com,

It contains text referring to old versions as well as sections referring
to the latest version.

> I found this passage:
> 
>    Jason Merrill writes: "To perform closure on a set of objects, just try
>    to link them together. It will fail, but as a side effect all needed
>    instances will be generated in the objects." 
> 
> Maybe I'm dense, but I don't understand this.

It refers to 2.7.2.x .  The procedure is not recommended with 2.8.0 or
egcs.  The reason it worked is because -frepo attaches the instantiated
functions to the original .o files.  So if you did

	g++ -frepo *.o -o dummy

then -frepo would try to instantiate templates as needed; the link will
fail because there is no main defined.  But after that you can do

	ar qc libfoo.a *.o

to make the library, and the library will contain template expansions.

  reply	other threads:[~1998-02-08 18:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-02-08 11:38 David Greene
1998-02-08 18:44 ` Joe Buck [this message]
1998-02-09  9:08   ` David Greene
1998-02-09 11:54     ` Joe Buck
1998-02-09 11:54       ` David Greene

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199802090242.SAA05477@atrus.synopsys.com \
    --to=jbuck@synopsys.com \
    --cc=egcs@cygnus.com \
    --cc=greened@eecs.umich.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).