On 3/13/12 5:07 AM, Dirk Zimoch wrote:
Andrew, Lewis,
If the C++ template instantiation is the problem, then the
-fno-implicit-templates command line option may help. If that is
used, the compiler will not create any code "behind the scenes".
Hi, Dirk.
That option is being used.
Instead it requires that for each template, you explicitly
specify in which file you want to have the implementation. See
section "Where's the Template?" in the gcc info pages.
In exactly one source code file one has to write a line like
template class epicsSingleton<localHostName>::reference;
I added the above line to src/ca/cac.cpp, but now the build
fails. (See attached log.) So maybe I need to add it to a
different file (e.g. src/libCom/cxxTemplates/epicsSingleton.h),
or maybe I need to remove things from other files?
Thanks,
Lewis
Andrew Johnson wrote:
Hi Dirk,
On 3/7/12 2:50 AM, Dirk Zimoch wrote:
These two functions,
epicsSingleton<localHostName>::reference::~reference(void) and
epicsSingleton<localHostName>::reference::operator->(void) both
contain 'assert' (see
src/libCom/cxxTemplates/epicsSingleton.h).
'assert' is a macro:
# define assert(exp) ((exp) ? (void)0 : \
epicsAssert(__FILE__, __LINE__, #exp,
epicsAssertAuthor))
Depending on the optimization level, '(void)0' may be
eliminated
and the code becomes shorter (by 4 bytes = 1 PPC instruction).
Try to 'make clean' in the epics base top directory and compile
again.
The problem is more subtle than that, although I suspect that
different optimization levels is probably the underlying cause.
Remember Lewis is using a very old version of g++, from back
when C++ templates were new; my guess is that ldppc is
recompiling the template instances it needs to link the code
behind the scenes, but it wasn't told the optimization level
that g++ppc used to compile the instances that appear in the
.o files it's linking with so it doesn't get the same length
code and generates that warning. There may be a flag we could
turn on to show more about what's going on inside ldppc, but
it's really not worth looking into IMHO; better to spend the
time upgrading to vxWorks 5.5.
- Andrew