5 ms·
MSYS and MSYS2 actually are Cygwin-- the original MSYS being a (horribly out of date) fork of Cygwin that never really pulled much from upstream, and MSYS2 att
by JonathonW 11y ago
MSYS and MSYS2 actually are Cygwin-- the original MSYS being a (horribly out of date) fork of Cygwin that never really pulled much from upstream, and MSYS2 attempting to track upstream Cygwin more closely.
You're getting confused with MinGW, which uses MSYS to build native Windows executables. They need MSYS (as a Cygwin-derived emulation layer) because tools like GCC or Bash expect the system to support POSIX APIs and have POSIX semantics-- for example, Windows has no equivalent to a POSIX fork() call. The code you're compiling under MinGW has no MSYS or Cygwin dependencies, but the compiler and tools themselves (gcc, bash, the linker, etc.) do.
- reidrac 11y agoMSYS (as part of MinGW project) doesn't use Cygwin AFAIK; with the licensing implications that it has, because Windows programs written with Cygwin run on top of a copylefted compatibility DLL that must be distributed with the program, along with the program's source code (quoting Wikipedia). In fact the binaries, that are compiled with MinGW, link with MSVCRT by default (Microsoft Visual C Run-Time DLL). So no compatibility layer, and they don't rely on Cygwin.
- gpvos 11y agoPlease distinguish carefully between MSYS and MinGW. MSYS (or MSYS2) programs runs on top of a copylefted compatibility DLL that is suspiciously similar to Cygwin. They must be GPL-compatible. MinGW programs link with MSVCRT. They are compiled by GCC toolchain programs, most of which are MSYS programs.
- vram22 11y ago>MSYS and MSYS2 actually are Cygwin Not the person you're replying to, but interesting ... >tools like GCC or Bash expect the system to support POSIX APIs and have POSIX semantics-- for example, Windows has no equivalent to a POSIX fork() call. So do Cygwin and/or MSYS emulate the fork() call on Windows? and if so, do you have any idea how that is done? Just interested, since I have a Unix background - not at deep OS level, but at app level and also at the level of the interface between apps and the OS (using system calls, etc.).
- jmgao 11y ago> So do Cygwin and/or MSYS emulate the fork() call on Windows? and if so, do you have any idea how that is done? Cygwin does some pretty horrific hacks to emulate it. It basically creates a paused child running the same binary, fills in its memory, stores the register context of where it came from in a shared memory, and then resumes the child. The child on startup detects that it was forked, and then looks into shared memory to resume running at the place of the fork. edit: It's even worse than I remembered: https://www.cygwin.com/faq.html#faq.api.fork https://www.cygwin.com/faq.html#faq.api.fork
- vram22 11y agoWow. That sure is complex.
- bitcrazed 11y ago> So do Cygwin and/or MSYS emulate the fork() Yes. That's one thing we spent considerable engineering effort on in this first version of the Windows Subsystem for Linux: We implement fork in the Windows kernel, along with the other POSIX and Linux syscalls. This allows us to build a very efficient fork() and expose it to the GNU/Ubuntu user-mode apps via the fork(syscall). We'll be publishing more details on this very soon.
- vram22 11y agoInteresting! thanks. The original Unix fork() was found to be somewhat expensive in resources (a little surprising since it was the only way to create a child process), later there was vfork() (copy-on-write) (maybe innovated by BSD), and I read Linux's clone() does even better, though not looked into it in detail.
- jmgao 11y agofork would copy the entire address space of the process, which was wasteful when you're usually going to just throw all of that memory away by calling exec. BSD added vfork to optimize the `if (fork() == 0) exec(...)` scenario, by not copying the memory, and just pausing and then borrowing memory from the parent, until exec is called. Modern operating systems use copy on write pages for fork, so instead of copying all of memory, you just need to copy the page tables.