Subject: RE: Newbie template linking problem
From: [email-masked] (Mumit Khan)

17 Jun 1998 20:24:50 -0700
Message-ID: <[email-masked]>
References: <c=US%a=_%p=NASD%l=[email-masked]>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
To: "Berns, Brian" <[email-masked]>
Cc: "[email-masked]'" <[email-masked]>

On Wed, 17 Jun 1998, Berns, Brian wrote:

> Thanks.  I am now successfully using egcs to compile and link my C++
> program.  My question now is: Should I be using the -frepo option?  When
> I do, I get linker errors.  When I don't, everything links and runs
> fine, but the resulting executable is quite large (esp. in comparison to
> the corresponding .exe produced by VC++) -- I wonder if it contains
> redundant template instantiations?  The archive info on this topic seems
> somewhat muddled.  What's the current behavior?
> 

-frepo is unnecessary on platforms using either ELF (Linux, Solaris 2.x,
....) and PE-COFF (Win32). Also, -frepo doesn't work correctly on cygwin32 
without a few patches, and I don't remember what the status was in the 
egcs-1.0.2 for cygwin32. On other platforms, such as SunOS 4.1.x etc, it
can be a big win (I personally use explicit instantiation, and prefer it
over -frepo. Search dejanews for many articles on this top in gnu.g++.help
and thereabouts).

On both ELF and PE-COFF, the linker discards the duplicate templates, so 
you end up with the "optimal" template code in your final executable. The 
code bloat you're seeing might be just debugging symbols (does "strip" 
help?). There should be no redundant template instances on these
platforms.

For any variant of GCC, I recommend either explicitly instantiating
templates (a royal pain the first time around) or if you're using egcs 
or gcc-2.8.x on ELF/PE-COFF, then using automatic instantiation.

Mumit

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".