Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 Jan 1997 23:42:36 -0500 (EST)
From:      "Eric J. Chet" <ejc@gargoyle.bazzle.com>
To:        Terry Lambert <terry@lambert.org>
Cc:        Bakul Shah <bakul@torrentnet.com>, hackers@FreeBSD.ORG
Subject:   Re: g++, STL and -frepo on FreeBSD-2.2-Beta
Message-ID:  <Pine.BSF.3.95.970131231640.15472A-100000@gargoyle.bazzle.com>
In-Reply-To: <199702010114.SAA03677@phaeton.artisoft.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 31 Jan 1997, Terry Lambert wrote:

> > cat >x.cc <<EOF
> > #include <stl.h>                // include everything for simplicity.
> > #include <iostream.h>
> > #include <stdlib.h>
> > 
> > int main(int, char*[]) {
> >     list<int> list1;
> >     for(int i = 0; i < 10; ++i) {
> >         list1.push_back(rand());
> >     }
> >     return 0;
> > }
> > EOF
> > 
> > g++ -frepo -c x.cc
> > g++ -o x x.o
> > 
> > The last step above should call the compiler to instantiate the
> > list<int> class and everything should just work.  No such luck.  I
> > get:
> > 
> > x.o: Undefined symbol `list<int>::list(void)' referenced from text segment
>                          ********************* constructor
> > x.o: Undefined symbol `list<int>::push_back(int const &)' referenced from text segment
>                          ********************************* type member
> > x.o: Undefined symbol `list<int>::~list(void)' referenced from text segment
>                          ********************** destructor
> 
> It can't call the constructor, used implicitly in the list1 auto
> declarator.  It can't call the destructor, called implicily when the
> list1 auto storage goes out of scope of main().  It can't call the
> push_back member function, which is explicitly called.
> 
> 
> Clearly, the template class definition
> 
> 	template <class Type>
> 	class list ... {
> 		...
> 	};
> 
> is not in scope.  The header files you have included are apparently
> not sufficient.
> 
> Perhaps you meant "List" instead of "list"???
> 
Hello

	The -frepo patches don't work on our version of the g++ and 
ld.  I assume ld is the problem.  I haven't had the time to take a look 
to see what needs to be changed. The -frepo patch from Cygnus when
applied, should create a set of *.ii one for each source file complied 
from g++.  The *.ii files specify all templates that need to be 
instantiated before linking can take place.  I believe there is a collect2
module that performs the instantiations task.  

	I do know that if you build g++ with John Polstra's ELF patches
and the -frepo patches.  Then template repository works as advertised.

	On the other hand, the only thing you lose by not having the
repository with our native compiler is executable size.  The compiler
will instantiated every template used in a object file and include it in
that object file.  Meaning, you can have duplicate template instantiations
across different object files.



                                              Eric J. Chet
					       - ejc@naserver1.cb.lucent.com
                                               - ejc@bazzle.com

> 
> 					Terry Lambert
> 					terry@lambert.org
> ---
> Any opinions in this posting are my own and not those of my present
> or previous employers.
> 




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