I am trying to check thread_local(which is provided as __thread or __declspec(thread) ) feature in armcc
.
CHECK_C_SOURCE_COMPILES("int main(){ static __thread int num; return 0;}" GCC_THREAD_LOCAL_AVAILABLE)
With my version of armcc, I am able to compile the source code in above cmake command without any error.
But cmake fails this test with following log:
Building C object CMakeFiles/cmTC_293ce.dir/src.o
/opt/ARM/DS-5//bin/armcc -DGCC_THREAD_LOCAL_AVAILABLE -o CMakeFiles/cmTC_293ce.dir/src.o -c /devdisk/users/gjha/code/aepe15_dryos_2nd/CMakeFiles/CMakeTmp/src.c
"/devdisk/users/gjha/code/aepe15_dryos_2nd/CMakeFiles/CMakeTmp/src.c", line 1: Warning: #177-D: variable "num" was declared but never referenced
int main(){ static __thread int num; return 0;}
^
/devdisk/users/gjha/code/aepe15_dryos_2nd/CMakeFiles/CMakeTmp/src.c: 1 warning, 0 errors
Linking C executable cmTC_293ce.elf
/opt/cmake394/bin/cmake -E cmake_link_script CMakeFiles/cmTC_293ce.dir/link.txt --verbose=1
/opt/ARM/DS-5/bin/armlink -DGCC_THREAD_LOCAL_AVAILABLE CMakeFiles/cmTC_293ce.dir/src.o -o cmTC_293ce.elf
Warning: L3910W: Old syntax, please use '-d'.
Fatal error: L3900U: Unrecognized option '-GCC_THREAD_LOCAL_AVAILABLE'.
Finished: 0 information, 1 warning, 0 error and 1 fatal error messages.
gmake[1]: *** [cmTC_293ce.elf] Error 1
Problem here is, cmake spills macro definition -DGCC_THREAD_LOCAL_AVAILABLE
into linker command and armlink
fails.
Please guide me how to avoid this macro definition spilling.
ARMCC version: 5.04
cmake version: 3.9.4
For GCC this problem does not occur and gnu-ld
simply ignores the macro definition in the command line.