With
-static-libgcc -static-libstdc++
you still link dynamically against libwinpthread, on MinGW distributions that use it (e.g. MSYS2). Just use -static
to statically link everything.