Win64 fixes

This patchset fixes some parts broken on Win64.

This also adds `--disable-pthreads` flags to llvm on mingw-w64 archs
due to bad performance. See #8996 for discussion.