logoalt Hacker News

okanatyesterday at 8:22 PM1 replyview on HN

You're conflating MSYS2 with Mingw-w64. MSYS2 installation comes with multiple environments/ABIs and MSYS2 mode is actually a fork of Cygwin. They fork Cygwin, put some patches on and rename the DLL as msys-2.0.dll . Here is the sources for MSYS2 runtime that produces it: https://github.com/msys2/msys2-runtime . To run bash you need termios API, stty, fork, exec and signals (and some other POSIX-specific funtions).

Due to Windows's execution model it is not possible to natively implement fork. Cygwin implements those via a executable backdoor hack. Basically the executable starts executing from the usual start point and it receives where to jump via a named pipe. Since MSYS2 is a fork it uses the same implementation.

Unlike Cygwin, MSYS2's goal isn't to be a complete system but ship just enough tooling to enable development with Mingw-w64. Mingw-w64 is the toolchain that ships GCC and it also defines its own ABI where the C ABI is the same as MSVC / Win32 ABI except that Mingw-ABI comes with its own threading and structured exception handling infrastructure. For C++ Mingw-w32 uses Itanium ABI instead of MSVC. If you use GCC to compile the debugging symbols will be DWARF with Mingw-32.

You can also use Clang environments where you can generate PDB debug symbols and use native Win32 threading.

Except for the differences above, the executables targetting Mingw-w64 ABI are normal native Windows executables. They don't have access to most of the unistd.h and they have to use native Windows system calls (kernel32.dll user32.dll, ucrt etc.)

You can target MSYS2 / Cygwin ABI too (just like Bash). In this ABI the entire system works like a POSIX system. Unlike Mingw-w64 backslashes are not native. In MSYS2-ABI programs execute very slowly compared to purely Mingw-w64 executables since they always have to pass the POSIX emulation layer.


Replies

rzzztyesterday at 8:25 PM

I did forget about these! The installer will add separate launchers for each style of environment.