Build fixes from MSYS2/MinGW-w64

I work on the MSYS2 project and node.js is one of our packages. I'd like upstream my patches and would like to have a discussion about this set of changes first.