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.
I'm experiencing a problem with the TI C compiler v7.3.2. Apart from -I, -D and -f* options, I'm using the following: "cl6x -qq --gcc -O3 -mi200 -mv6455 -mt -mw -oi -pdr --abi=eabi -k"
The problem is where two developers have used a static inline function with the same name. Basically, a simplified case would be with two files:
File 1:
static inline ResetState(void)
{
/* Do some resetting */
}
/* Lots of other code where ResetState gets called and is correctly inlined */
extern void GloballyUniqueName1(void)
{
ResetState();
}
File 2:
static inline ResetState(void)
{
/* Do some different resetting */
}
/* Lots of other code where ResetState gets called and is correctly inlined */
extern void GloballyUniqueName2(void)
{
ResetState();
}
The compiler seems to insert a .symalias of GloballyUniqueName1 to ResetState and, likewise, for GloballyUniqueName2. As a result, the supposedly file-scope names are leaked into the global namespace and the linker throws a wobbly with "error: symbol "ResetState " redefined". If I comment out the call in (say) GloballyUniqueName1, everything builds fine, with no mention of ResetState in the assembly at all.
Is this a compiler bug or is there additional decoration required on the static inline function to make it really static?
TIA,
SPH.
That would be a bug. I've submitted SDSCM00048452 to track this issue. As a workaround, give the static functions different names.
Thanks. Yes, I had already implemented that workaround; I just wanted to make sure that I wasn't missing something about "static inline".
SPH
based on your description of the problem, I worked out the following testcase:
====test1.c
#include <stdio.h>
static inline ResetState(void)
{
printf("In ResetState in test1\n");
}
extern void GloballyUniqueName1(void)
{
ResetState();
}
====
====test2.c
#include <stdio.h>
static inline ResetState(void)
{
printf("In ResetState in test2\n");
}
/* Lots of other code where ResetState gets called and is correctly inlined */
extern void GloballyUniqueName2(void)
{
ResetState();
}
====
====test3.c
#include <stdio.h>
extern void GloballyUniqueName1();
extern void GloballyUniqueName2();
main()
{
GloballyUniqueName1();
GloballyUniqueName2();
}
And I use these command to compile them:
cl6x -qq --gcc -O3 -mi200 -mv6455 -mt -mw -oi -pdr --abi=eabi -k test1.c
cl6x -qq --gcc -O3 -mi200 -mv6455 -mt -mw -oi -pdr --abi=eabi -k test2.c
cl6x -qq --gcc -O3 -mi200 -mv6455 -mt -mw -oi -pdr --abi=eabi -k test3.c
cl6x -qq --gcc -O3 -mi200 -mv6455 -mt -mw -oi -pdr --abi=eabi -k test1.obj test2.obj test3.obj -z -o test.out -llnk.cmd"test1.c", line 3: remark: explicit type is missing ("int" assumed)
"test1.c",line 7: remark: missing return statement at end of non-void function "ResetState"
"test2.c", line 3: remark: explicit type is missing ("int" assumed)
"test2.c", line 7: remark: missing return statement at end of non-void function "ResetState"
"test3.c", line 10: remark: missing return statement at end of non-void function "main"
remark: automatic RTS selection: linking in index library "libc.a"
remark: automatic RTS selection: linking in "rts64plus_elf.lib" in place of
index library "libc.a"
The linking is done fine.
When I run it, I got the following:
In ResetState in test1
In ResetState in test2
It seems this is also correct.
Please revisit the testcase I wrote based on your description, maybe I missed something. Otherwise, it is OK. I did not see any problem.
Thanks,
Wei
OK, I've reproduced it:
static int a; static inline void ResetState(void) { a = 0; } extern void f1_a(void) { volatile int local; int i; for(i = 0; i < 10; i++) { local = i; } ResetState(); } extern void f1_b(void) { ResetState(); }
static int a; static inline void ResetState(void) { a = 0; } extern void f2_a(void) { volatile int local; int i; for(i = 0; i < 10; i++) { local = i; } ResetState(); } extern void f2_b(void) { ResetState(); }
extern void f1_a(void); extern void f1_b(void); extern void f2_a(void); extern void f2_b(void); int main(void) { f1_a(); f2_a(); f1_b(); f2_b(); return 0; }
C:\tmp\ti_comp_issue>cl6x -qq --gcc -O3 -mi200 -mv6455 -mt -mw -oi -pdr --abi=eabi -k f1.c
"f1.c", line 1: warning: variable "a" was set but never used
C:\tmp\ti_comp_issue>cl6x -qq --gcc -O3 -mi200 -mv6455 -mt -mw -oi -pdr --abi=eabi -k f2.c
"f2.c", line 1: warning: variable "a" was set but never used
C:\tmp\ti_comp_issue>cl6x -qq --gcc -O3 -mi200 -mv6455 -mt -mw -oi -pdr --abi=eabi -k main.c
C:\tmp\ti_comp_issue>lnk6x *.obj
error: symbol "ResetState" redefined: first defined in "f1.obj"; redefined in
"f2.obj"
error: no input section is linked in
warning: no suitable entry-point found; setting to 0
error: errors encountered during linking; "a.out" not built
Both ResetState functions are, as you can see, defined as "static inline void ResetState(void)".
SPH
I've just had a bit more of a play and found that it looks to be a problem specifically with the EABI; I get the problem if I compile using "cl6x --abi=eabi -O1 <file>.c" but not if I compile with "cl6x -O1 <file>.c". All the other options appear superfluous to reproducing the problem.
Cheers,
SPH
Thanks for the testcase.
I can also reproduce it here.
A good news is that this problem is fixed already. It was reported before as CQ42632 and CQ41888. They both were fixed in 7.3.3.
You reported this problem on 7.3.2.
The newest release on 7.3.x branch is 7.3.13. If you can upgrade to this release, you problem should be gone.
Any problem in getting a newer release, please let us know.
Wei
Ah, OK. I've just tried with a newer version of the tools and can confirm that the problem has gone away.
Thanks for your help,
SPH
Great!
In the future, if possible, please always try to use the newest version of TI tools. It may solve some problems you know or you don't even feel.
Thanks again for filing this problem to us,
Wei