This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Linker problem with compiler 6: armclang -flto armlink --lto can't ignore unused extern reference variable or function

Dear all:

I'am working on DS-5 Version: 5.28.1. Imported sample project startup_Cortex-R8. and modified main.c file with code like:

extern int g_TobeyTest;

void TobetTestFun(void)

{

g_TobeyTest = 0xffff;

while(1);

}

but actually I don't invoke function TobetTestFun(), or  use g_TobeyTest in the project.

AS i thought, with armclang -flto armlink --lto can help me remove symbol g_TobeyTest, but it doesn't work. 

Can somebody help me figure out my fault, thanks!!

================================================

below is project build log:

11:16:42 **** Build of configuration Debug for project startup_Cortex-R8 ****
make all

'Building file: ../main.c'
'Invoking: Arm C Compiler 6'
armclang --target=arm-arm-none-eabi -mcpu=cortex-r8 -O0 -w
-flto -mthumb -MD -MP -c -o "main.o" "../main.c"
'Finished building: ../main.c'
' '
'Building file: ../sorts.c'
'Invoking: Arm C Compiler 6'
armclang --target=arm-arm-none-eabi -mcpu=cortex-r8 -O0 -w
-flto -mthumb -MD -MP -c -o "sorts.o" "../sorts.c"
'Finished building: ../sorts.c'
' '
'Building file: ../startup.s'
'Invoking: Arm Assembler 6'
armclang --target=arm-arm-none-eabi -mcpu=cortex-r8 -marm -g -w -x assembler-with-cpp -c -o "startup.o" "../startup.s"
'Finished building: ../startup.s'
' '
'Building target: ../startup_Cortex-R8.axf'
'Invoking: Arm Linker 6'
armlink --entry=Start --scatter="M:\tobey\DS-5 Workspace\startup_Cortex-R8\VT3549_FW_MCU0.scat" --info=totals --info=inline
--lto -o "../startup_Cortex-R8.axf"  ./main.o ./sorts.o ./startup.o  
armclang.exe: warning: Your license for feature ulteval_armcompiler will expire in 14 days [-Wlicense-management]
Error: L6218E: Undefined symbol g_TobeyTest (referred from main.o).
Finished: 0 information, 0 warning and 1 error messages.

BR

TobeyTan