Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
17 years ago

optimize the size of a C program????

hi,

i have write a C program with 20 line of code, i try optimize it with NIOS II compliler option like -Os, -g3 i obtain 7700 bytes but is not sufficient for my design, because i use an onchip memory.

my question is:

can I optimize my program for obtain a smaller size ?

Nios II compiler contain others options for program optimisation?

thks for all members

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Is the 7700 bytes you mention code space or data space?

    Optimization will attempt to reduce code size but not have much of an effect on data size.

    Since it's only 20 lines of C, perhaps you could post it so members could take a look and suggest any code style optimizations .

    Thanks
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Have you tried customizing the system library? This can make a relatively big difference when your actual program is quite small.

    For example, in the system library you can disable C++ support as well as enable "reduced device drivers" and "small C library".