It's a GCC option and "documented" (if we can call it that) here: https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html
-fno-threadsafe-statics
Note that it's purely a C++ option, so if you don't use C++, it should have no effect.
My understanding is that, contrary to C, for which initializers of static variables must be constants, in C++, local static variables can be initialized at run-time and thus there may be problems of thread-safety *for the initialization*. It's only about initialization. Obviously as you mentioned, using static variables may not be thread-safe per se otherwise. It all depends on how they are used.
As a simple illustration, the following piece of code is not correct C and won't compile:
#include <stdlib.h>
int Foo(int m)
{
static int n = rand();
return n + m;
}
But in C++, it is correct code and will compile.
Example of GCC (C++ mode) output for ARM:
with '-Os':
Foo(int):
push {r3, r4, r5, lr}
mov r5, r0
ldr r4, [pc, #36] ; (2c <Foo(int)+0x2c>)
ldr r3, [r4, #0]
dmb ish
lsls r3, r3, #31
bmi.n 24 <Foo(int)+0x24>
mov r0, r4
bl 0 <__cxa_guard_acquire>
R_ARM_THM_CALL __cxa_guard_acquire
cbz r0, 24 <Foo(int)+0x24>
bl 0 <rand>
R_ARM_THM_CALL rand
str r0, [r4, #4]
mov r0, r4
bl 0 <__cxa_guard_release>
R_ARM_THM_CALL __cxa_guard_release
ldr r0, [r4, #4]
add r0, r5
pop {r3, r4, r5, pc}
nop
.word 0x00000000
R_ARM_ABS32 .bss
It guards the initialization with calls to __cxa_guard_acquire and __cxa_guard_release.
With '-Os -fno-threadsafe-statics':
Foo(int):
push {r3, r4, r5, lr}
mov r5, r0
ldr r4, [pc, #20] ; (1c <Foo(int)+0x1c>)
ldr r3, [r4, #0]
lsls r3, r3, #31
bmi.n 16 <Foo(int)+0x16>
bl 0 <rand>
R_ARM_THM_CALL rand
movs r3, #1
str r0, [r4, #4]
str r3, [r4, #0]
ldr r0, [r4, #4]
add r0, r5
pop {r3, r4, r5, pc}
.word 0x00000000
R_ARM_ABS32 .bss
It doesn't guard initialization.
So this may look a bit pointless in practice. But it's actually mandated by C++11 as far as I've seen.
GCC just gives an option to disable it.
If you don't use C++ or use C++ but don't use local static objects, there is absolutely nothing to be concerned about.