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.

Compiler/TMS570LS3137: Compiler remove dead code for unit test project?

Part Number: TMS570LS3137
Other Parts Discussed in Thread: TMS320F28335,

Tool/software: TI C/C++ Compiler

Hello all,

My company is working with a cross platform project on the TMS570LS3137 and TMS320F28335 (obviously there is Some processor specific code, but the bulk of the project is general). 

We are using Code Composer Studios v6.1.0.00104 and the ARM compiler v5.2.2

Our project builds and operates just fine. Now for DO178 we need to low-level unit test the functions of said project.

So our unit test framework is setup sorta as follows:

ut_main.c  calls  ut_app.c,  which includes as necessary:

a_code.c/h  with  ut_a_code.c/h

b_code.c/h  with  ut_b_code.c/h

c_code.c/h  with  ut_b_code.c/h

...

z_code.c/h  with  ut_z_code.c/h

Our unit tests are still under development, but the project code size has ballooned, and become difficult to run on hardware.

Obviously we can just comment out the includes, and exclude the files we don't need to test at the moment.

However, excluding files is a very manual process, and I am trying to find a better programmatic way.

For example, I have attempted to use the Properties > Build > ARM Compiler > Advanced Options > Runtime Model Options > "Place each function in a separate subsection" option.

According to the compiler user guide, this should cause all unlinked function to not be included in the project and final code size should be reduced, assuming most of the functions are unused.

Since my unit test project has all but one code/ut_code file commented out from the ut_app.c, I would expect that my code size should be much reduced with this option.

However, this did NOT occur.

The only thing that has successfully reduced project size is manually excluding unused code/ut_code files from the project.

So, given my unit test setup and my goal of reducing the project to just the currently included code via programmatic build options, does any one have any advice?

Thank you very much,

Neal

  • ngohara1991 said:

    For example, I have attempted to use the Properties > Build > ARM Compiler > Advanced Options > Runtime Model Options > "Place each function in a separate subsection" option.

    According to the compiler user guide, this should cause all unlinked function to not be included in the project and final code size should be reduced, assuming most of the functions are unused.

    Suppose your code contains a function named never_called(), in a source file named file.c, and you build with --gen_func_subsections. The resulting file.obj has the code for never_called(), isolated to a section named .text:never_called.  The linker looks for any use of the symbol never_called.  Note it does not have to be a typical function call.  Any use of the symbol counts.  If any use of the symbol never_called is found, the section .text:never_called remains.  Otherwise, it is discarded.

    I don't completely understand how you organize your code.  But I suspect you somehow continue to make a symbolic reference to the functions you do not call, and that is why the tools do not remove them.

    Thanks and regards,

    -George

  • Thanks for the reply George,
    with regards to your example, I have commented out the #include "never_called.h",
    and I am fairly sure all instances of never_called() are either commented out or in unused files, as the project will build without the "implicit declaration" warnings.
    I mean unused by the project, but still part of the build, apparently.

    Can you advice as to the proper way to track down the symbolic usage of never_called(), such that I can make the --gen_func_subsection flag properly reduce my code size?

    Thank you
    Neal
  • ngohara1991 said:
    Can you advice as to the proper way to track down the symbolic usage of never_called(), such that I can make the --gen_func_subsection flag properly reduce my code size?

    Unfortunately, I can't.  That's because I don't understand what you are doing well enough to reproduce it.  

    Please submit a test case.  Since this a situation involving the linker, I need a complete CCS project that has this problem.  Feel free to send in the whole project, or perhaps you prefer to create a separate, smaller, project that still demonstrates the problem.  Please see the wiki article Project Sharing to learn how to package up a project.  Then attach that to your next post.

    Thanks and regards,

    -George