I try to build program with static linked toolchain libraries. I pass:
LDFLAGS=\"-Wl,-Bstatic -lwinpthread -Wl,-Bdynamic -static-libgcc -static-libstdc++\"
You are not doing anything incorrect, Mingw-Builds works that way you.
I recently stumbled on this, but for another reason:
Mingw-Builds automatically links executables to GCC dynamic libraries (libwinpthread-1.dll, libstdc++-6.dll, libgcc_s_dw2-1.dll) to save executable size (problem: when you release executables you have to remember to add missing dlls too along with your binary because there's no guarantee users have those DLL on their systems)
In my case the problem was that I had multiple GCC pakcages on the same system and hence I not added them to PATH to avoid name clashes.
The fun part is that CMAKE before configuring your project generates a C-SourceFile that is compiled and used to get informations about your compiler, since DLLs were not in PATH, that small executable generated by CMake was crashing because of missing DLLs and that stopped the whole build process.
The solution to fix that is adding the compiler path to PATH TEMPORARILY (or better run CMake in another environment).
Adding DLLs manually to the Cmake temp directory doesn't work because Cmake cleanup that directory at each configuration..
If you use mingwbuilds you have to link to pthreadBLAH.dll no workaround