107 points · by andyonthewings · 7y ago · 39 comments
I should rebase Cygnal to Cygwin 3.0.
As someone who has mostly used the MSVC environment on Windows, can you comment on how often Cygwin allows for a Linux port to compile and run with no source changes? I read a while back that the fork "emulation" is a performance hit. I wonder if Cygwin benefited from the WSL fork implementation [0]
Programs that fork and immediately exec can be improved under Cygwin by using the spawn, family of system calls, like what I have here:
http://www.kylheku.com/cgit/txr/tree/stream.c
in this source file there is a version of the run function that uses _wspawnvp, support for which is detected in my ./configure script. Well, _wspawnlp, but they're in the same family:
printf "Checking for _wspawnlp ... "
cat > conftest.c <<!
#include "config.h"
#include <process.h>
#include <wchar.h>
int main(int argc, char **argv)
{
wchar_t *wargv[] = { L"foo", L"bar", 0 };
int r = _wspawnlp(_P_WAIT, L"foo", wargv);
return 0;
}
!
if conftest ; then
printf "yes\n"
printf "#define HAVE_WSPAWN 1\n" >> config.h
else
printf "no\n"
fi
The porting experience of Unix and Linux programs to Cygwin is pretty darn good. You can tell just from the large number of packages that are available under Cygwin.Even programs that use termios to put the TTY in raw mode and use ANSI escape sequences to control the screen work in Cygwin. Cygwin's I/O system contains a layer that translates ANSI codes to Win32 Console API calls. This works inside the Windows CMD.EXE console, not only the Cygwin terminall.
You have a typo in conhost.exe there. The Windows console has native support for those escape sequences by now too, though.
Two or three years ago there was an announcement on the mailing list that Cygwin it's switching to the LGPL. I kicked off the Cygnal project that very day, pretty much.
fork has its own implementation, cygwin is entirely unrelated to WSL (as before the Interix subsystem). It's extremely slow though. WSL or mingw are much faster. But mingw is a pain.
Maybe that newer MinGW-W64 project or whatever it is called.
The original MinGW that just links programs to the system library called MSVCRT.DLL.
It provides POSIX porting only the extent of the meagre support for a few POSIX functions in MSVCRT.DLL. That has things like open, read and dup2, and a half-baked stat and such.
The Win32 functions are available to Cygwin programs.
The funny thing about both Cygwin and WSL is that, in my experience, many of the people who make use of them wish that they didn't have to make use of them. For me, Cygwin makes it a little easier for me to forget I'm not where I want to be (especially with things like winpty and apt-cyg). In Cygwin I can run URxvt just like at home, and run all the nonsense legacy software I need to for work, just like it were actually reasonable. In WSL, I can do none of that. It just doesn't work. I have a few co-workers who run WSL alongside cmd.exe. If I'm going to have to do that, I'd rather just stick to Cygwin.
I forked Cygwin's main DLL (cygwin1.dll) to create "Cygnal": an drop-in alternative that provides more Windows-like behaviors in various areas. Programs built under Cygwin can be bundled with Cygnal. Then (for instance) they have path handling that is familiar to Windows users.
If you need your math to be correct, use Cygwin.
Access to Win32 APIs.
Static link and distribute to any windows user.
Better interoperability with Windows/cmd/powershell
> This feature requires Windows 10 1803 or later and WSL installed!
Interesting, so is cygwin going to be based on WSL?
https://blogs.msdn.microsoft.com/wsl/2016/06/15/wsl-file-sys...
Remember putting all the usr binaries (cat,ls,sed,etc.) in the windows path and it was great!