How to solve: undefined reference to `__sync_synchronize'

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 is
reported 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 different
flags 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

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'

class A
int m_i;


A(int i) : m_i(i)

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);

return a.value(x);

int main(int argc, char* argv[])
return use_static_inst(argc);

More questions in this forum