Forum Discussion
Altera_Forum
Honored Contributor
15 years agoHi,
This internal error is caused by the gcc's loop optimization, -fPIC switch and incomplete implementation of Nios code generation. If we compile the next source
/* test.c for nios2-wrs-linux-gnu-gcc internal error */
# define MAXST 1024*8 + 1
struct st {
int i;
} st;
void test()
{
struct st *pst = st;
int i;
/*
* Loop Optimization: eliminating of the loop valiable i with -O1,2,3.
* You can disable this optimization with -fno-tree-loop-optimize.
*/
for (i = 0; i < MAXST; i++) {
if (pst->i == 0) {
break;
}
pst++;
}
}
with
nios2-wrs-linux-gnu-gcc -O2 -fPIC -S test.c -o test.s
gcc will eliminate the loop variable 'i', use the pointer 'pst' instead of it and try to calculate the address for 'pst' when the loop is ended. But Nios code generator does not have the instruction like
addi reg, reg, 32bits_immediate_data
so the internal error is evoked. If you set the size of st[MAXST] within 1024*8, the immediate data is reduced within 16bits, so you can avoid the internal error. To use the compiler switch -fno-tree-loop-optimize is one method for work-around. Also next modification for the loop inside the function 'unload_all_mibs()'
/*
* tree nodes are cleared
*/
for (i = 0, ptc = tclist; i < MAXTC; i++/*, ptc++*/) {
if (ptc->type == 0) {
ptc++;
continue;
}
free_enums(&ptc->enums);
free_ranges(&ptc->ranges);
free(ptc->descriptor);
if (ptc->hint)
free(ptc->hint);
ptc++;
}
led me to the success of its compilation. Kazu P.S. Hi, Hippo, I think that the most important main maintainer's work is to show the direction of projects and gather many experts for its promotion rather than to answer FAQs in this forum. What is the project's main direction now?