This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

error: Must link using shell to complete template instantiations

I have been dividing some working code into multiple files in accord with a previous thread on C++ exception handling in a multithreaded application. In particular, I have a single class whose implementation is split into two .cpp files -- one that can throw exceptions and one that cannot. The two files have slightly different compiler options: first file has --exceptions and the second has -o2 (optimization; the same thing happens with -o0 and -o1 FWIW). This gives me two problems.

First, when I compile one of the files that was split up I get several similar messages to these:

"[...]/stl/_alloc.h", line 131: Warning - INLINE recursion limit exceeded.
"[...]/stl/_uninitialized.h", line 120: Warning - INLINE recursion limit exceeded.

The same things pop up repeatedly when linking (presumably because of the late template instantiation as described in the TI wiki article on that topic). I can get this to go away by doing any of these things:

  1. Enable --exceptions on second file even though it doesn't (and must not!) throw exceptions.
  2. Turn off optimization (-o2) on the second file.
  3. Copy-and-paste the one file in toto at the botom of the other and put -o2 and --exceptions on that file.

The second is the least bad of these options, but I would prefer to have at least function inlining enabled for the sake of my STL functions.

Irrespective of whether these warning show up or not, I also get a perplexingly vague linker error:

>>   error: Must link using shell to complete template instantiations

I have opened a command prompt and tried linking from there, both using the .lkf file and invoking the linker with all the .lkf's params directly, but I get the same error. In both cases I am invoking cl67x.exe, not lnk6x.exe. Help!

I am using CCS 3.1 and cgtools 5.1.12.

  • I found the following in a response to someone who had a question about the warning you are seeing:

     It isn't really a recursion limit so much as a call-chain depth limit.

    The limit is triggered when an inlined function body contains a call which is inlined, and its body contains a call which is inlined, and so on.

    The limit is arbitrarily set at 10 for 5.1.x and 6.0.x compilers. The 6.1.x releases use a different inlining strategy that does not have the same kind of limit.

    When the limit is reached, inlining will be disabled for further calls to the function called at the point of the warning, but will otherwise continue unaffected.


    In regards to the linker error you are getting, I searched through some old requests and found a case where someone getting that error was able to avoid it by using the --static_template_instantiation switch, which first appears in v6.0.x compilers. The compiler does not instantiate templates when the program is first compiled and the linker reinvokes the shell with the recorded template inforation in the object file to re-compile those files that have the template class definitions.

    Have you considered using a v6.0.x or v6.1.x compiler? Note that BIOS 4.90 would not be compatible with these compilers and you would have to upgrade to a newer BIOS version. See http://tiexpressdsp.com/wiki/index.php?title=Compatibility_between_DSP/BIOS_versions_and_Code_Generation_Tools for information on compatibility.

     

     

    Regards,
    Harry Thompson

  • Thanks, Harry.

    Is there any way to disable this warning message (it doesn't show a numerical identifier with -pden)?

    We can't upgrade our tools right now because we're in the middle of integration and that would introduce unknowns that we don't want to deal with now.

    Cheers!

  • In case anyone is coming to this thread to find answers (I know this is an old thread).

    This may seem elementary but when I received the:

    error: Must link using shell to complete template instantiations

    I "cleaned" the project and lost the vague linker error.

     


  • This cleaning process worked for me, as well.

    Note:  The linker error started when I changed the data type for a derived template class.  Although the .cpp file automatically recompiled, old information seemed to persist, creating the linker error.

    Thanks for the tip!

  • I just wanted to add to this thread since it's one of the first ones that show up through google for this error message. You cannot link template files directly through a call to the linker. You must invoke the linker through the compiler with a -z or "--run_linker" option.