We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I am trying to update the tool-chain for a bare metal embedded project. We are building on windows an up to now we have been using version 5.4.1 20160609 (release) [ARM/embedded-5-branch revision 237715].
Now I am trying version 9.3.1 20200408 (release) (9-2020-q2-update), but I have an issue with an undefined symbol while linking: __sync_synchronize isreported as missing and I have no idea from which source this symbol should be resolved. Do I have to link a library that I am missing? Should I give differentflags to the compiler so that it generates the code for that function?
Below is a sample that compiles and links just fine with the old tool-chain, but fails with the new one. In both cases this command line was used:
arm-none-eabi-g++ -mthumb -specs=nosys.specs sample.cpp
The exact failure message is:c:/projects/cpt_tools/gcc-arm-none-eabi/9.3.1/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\RMatano\AppData\Local\Temp\ccSZkMXN.o: in function `use_static_inst(int)':synch.cpp:(.text+0xc): undefined reference to `__sync_synchronize'collect2.exe: error: ld returned 1 exit status
c:/projects/cpt_tools/gcc-arm-none-eabi/9.3.1/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\RMatano\AppData\Local\Temp\ccSZkMXN.o: in function `use_static_inst(int)':
synch.cpp:(.text+0xc): undefined reference to `__sync_synchronize'
collect2.exe: error: ld returned 1 exit status
Here is the content of sample.cpp:
// compile with 'arm-none-eabi-g++.exe -mthumb -specs=nosys.specs sample.cpp'//// result: in function `use_static_inst(int)':// synch.cpp:(.text+0x18): undefined reference to `__sync_synchronize'
// compile with 'arm-none-eabi-g++.exe -mthumb -specs=nosys.specs sample.cpp'
//
// result: in function `use_static_inst(int)':
// synch.cpp:(.text+0x18): undefined reference to `__sync_synchronize'
class A{ int m_i;
class A
{
int m_i;
public:
A(int i) : m_i(i) { }
A(int i) : m_i(i)
}
int value(int x) { return m_i + x; }};
int value(int x)
return m_i + x;
};
int use_static_inst(int x){ // for this ctor the compiler generates a call to __sync_synchronize static A a(0);
int use_static_inst(int x)
// for this ctor the compiler generates a call to __sync_synchronize
static A a(0);
return a.value(x);}
return a.value(x);
int main(int argc, char* argv[]){ return use_static_inst(argc);}
int main(int argc, char* argv[])
return use_static_inst(argc);