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.

How to exclude unused Runtime Support library functions from the build?



Hello,

How can I exclude unused Runtime Support library functions from the build?

Stephen

  • Stephen,

    The -mo is a compiler option that will place each function in a source file into a seperate code section when the source file is compiled.  I don't think this is what you are looking to do, since the runtime support library is already compiled into a library.

    In actuality, each function in the rts library is already in its own source file, and therefore in its own code section.  When you link in the library, only the sections that are being referenced by your project will get included.  This means that only the functions you are using will show up in the .out file.

    So, I'm not sure what originally motivated your post.  You should already be getting in your executable only the rts functions you are using.

    Regards,

    David

  • Hello David,

    Thanks for the reply.

    I took another look at my map file and I noticed the -mo option didn't remove the functions that I thought I wasn't using, i.e. malloc, max_free, memccpy, memset,fopen, fputc, fputs ,free ,free_memory, freopen and maybe others.

    I'm not using those functions in my program, so why are those functions being included in the build?

    Stephen

     

  • Stephen,

    I can guarantee you that something in your project is referencing these functions.  Probably some other library functions and you just don't realize it is doing it.  For example, just doing a single printf() sucks in a whole bunch of objects from the library.  Something like this from a quick check I just did:

    atoi.obj (.text)
    fd_cmp.obj (.text)
    fd_neg.obj (.text)
    fd_sub.obj (.text)
    fd_toi.obj (.text)
    fs_tofd.obj (.text)
    l_div.obj (.text)
    l_tofd.obj (.text)
    ll_cmp.obj (.text)
    ll_mpy.obj (.text)
    ltoa.obj (.text)
    memchr.obj (.text)
    memset.obj (.text)
    printf.obj (.text)
    remove.obj (.text)
    strchr.obj (.text)
    strcmp.obj (.text)
    strlen.obj (.text)
    strncpy.obj (.text)
    strcpy.obj (.text) 

    The above is not even all of them.  I got tired of cutting-and-pasting.

    Regards,

    David

     

     

  • Ok.  I am using vfprintf in conjunction with a serial port driver. 

    Thanks,

    Stephen