Skip to content

msys-2.0.dl to cygwin1.dll switch patches#334

Draft
lygstate wants to merge 13 commits intomsys2:msys2-3.6.7from
lygstate:msys2-to-cygwin-3.6.7
Draft

msys-2.0.dl to cygwin1.dll switch patches#334
lygstate wants to merge 13 commits intomsys2:msys2-3.6.7from
lygstate:msys2-to-cygwin-3.6.7

Conversation

@lygstate
Copy link
Copy Markdown

@lygstate lygstate commented Apr 7, 2026

This MR reorder the patches, so we can transition from msys-2.0.dl to cygwin1.dll.

First, we revert the patches that rename cygwin1.dll to msys-2.0.dll

  • Revert "strace.cc: Don't set MSYS=noglob"

  • Revert "Rename dll from cygwin to msys"

  • Revert "Fix msys library name in import libraries"

  • Revert "uname: allow setting the system name to CYGWIN"

  • Revert "Add functionality for changing OS name via MSYSTEM environment variables."

NOTE: these reverts can be dropped in the next rebase

Then add patches that support for transition msys-2.0.dl to cygwin1.dll.

  • Add functionality for changing OS name via MSYSTEM environment variables.

  • Support for both cygwin and msys2

  • Support for both MSYS and CYGWIN environment variable

  • strace.cc: Don't set CYGWIN=noglob

  • Convert to use msys'style named pipe

The last two patch is to keep the orignal Rename dll from cygwin to msys

  • Rename dll from cygwin to msys

  • Fix msys library name in import libraries

With the last two patch, the built dll will be msys-2.0.dll.
Without the last two patch, the built dll will be cygwin1.dll.

So we can bootstrap msys-2.0.dll to cygwin1.dll in MSYS2-packages in a single code base.

@dscho
Copy link
Copy Markdown
Collaborator

dscho commented Apr 8, 2026

This MR reorder the patches, so we can transition from msys-2.0.dl to cygwin1.dll.

I am unaware of such a plan.

I mean, I can imagine that there is a ton of benefit to reduce the difference between the MSYS2 runtime and the Cygwin runtime to the bare minimum, to the point where even the path translation (which is probably the most distinguishing feature of the MSYS2 runtime) would be upstreamed to the Cygwin runtime as an opt-in, e.g. via a flag in /etc/nsswitch.conf. That would generate synergies between the Cygwin and the MSYS2 project, making it even easier to help each other out in meaningful ways. I'm all for going this direction.

At the same time, I am convinced that such a plan can only succeed by first building consensus about the direction, and I haven't seen such a discussion. Have I missed it?

@lygstate
Copy link
Copy Markdown
Author

lygstate commented Apr 8, 2026

This MR reorder the patches, so we can transition from msys-2.0.dl to cygwin1.dll.

I am unaware of such a plan.

I mean, I can imagine that there is a ton of benefit to reduce the difference between the MSYS2 runtime and the Cygwin runtime to the bare minimum, to the point where even the path translation (which is probably the most distinguishing feature of the MSYS2 runtime) would be upstreamed to the Cygwin runtime as an opt-in, e.g. via a flag in /etc/nsswitch.conf. That would generate synergies between the Cygwin and the MSYS2 project, making it even easier to help each other out in meaningful ways. I'm all for going this direction.

At the same time, I am convinced that such a plan can only succeed by first building consensus about the direction, and I haven't seen such a discussion. Have I missed it?

This is my local draft work that can transition from transition msys-2.0.dl to cygwin1.dll, post here for discussion.

This is just barelly bootstrap msys-2.0.dll into cygwin1.dll, other things I am not considered yet.

The most important part of msys2 I think is pacman, othere things(the runtime differencies) is minimal now.

And indeed pacman not working in cygwin at all.

Comment thread winsup/cygwin/hookapi.cc
Comment on lines +381 to +383
char *name_to_compare = rva (PSTR, map ?: (char *) hm, pd->Name - delta);
bool not_msys2 = !ascii_strcasematch (name_to_compare, "msys-2.0.dll");
bool not_cygwin = !ascii_strcasematch (name_to_compare, "cygwin1.dll");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up until this point, I see the keying factor to be the presence of the MSYS and the CYGWIN environment variable. It is not quite clear what this MR wants to do if both are set, but it is clear that it wants to trigger the MSYS2 vs Cygwin code paths depending on the presence of either environment variable.

This hunk, however, tells a very different story (and one that I could understand much better): whether to run in MSYS2 or in Cygwin mode is keyed by the name of the DLL.

It sounds a bit fraught with peril to have both mechanisms. It would probably be a lot more desirable to key only on one of the two, not on both.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a temporary patch that bootstrap from "msys-2.0.dll" to "cygwin1.dll", once the bootstrap finished. we can then revert this patch directly.

Comment on lines -359 to +373
/* Commit message for this code was:
"* strace.cc (create_child): Set CYGWIN=noglob when starting new process so that

Cygwin will leave already-parsed the command line alonw."

I can see no reason for it and it badly breaks the ability to use
strace.exe to investigate calling a Cygwin program from a Windows
program, for example:
strace mingw32-make.exe
.. where mingw32-make.exe finds sh.exe and uses it as the shell.
The reason it badly breaks this use-case is because dcrt0.cc depends
on globbing to happen to parse commandlines from Windows programs;
irrespective of whether they contain any glob patterns or not.

See quoted () comment:
"This must have been run from a Windows shell, so preserve
quotes for globify to play with later."

const char *cygwin_env = getenv ("MSYS");

#if 0
const char *cygwin_env = getenv ("CYGWIN");
const char *space;

if (cygwin_env && strlen (cygwin_env) <= 256) // sanity check
if (cygwin_env && strlen (cygwin_env) <= 256) /* sanity check */
space = " ";
else
space = cygwin_env = "";
char *newenv = (char *) malloc (sizeof ("MSYS=noglob")
char *newenv = (char *) malloc (sizeof ("CYGWIN=noglob")
+ strlen (space) + strlen (cygwin_env));
sprintf (newenv, "MSYS=noglob%s%s", space, cygwin_env);
sprintf (newenv, "CYGWIN=noglob%s%s", space, cygwin_env);
_putenv (newenv);
*/
#endif

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a lot of dead code. It would make more sense to investigate properly what the original commit tried to do, why it was wrong, and then to drop that part altogether. But that should most likely come as a separate Merge Request.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do this for reduce MSYS presence in code-base, as it's commted code, so I use #if 0, as this can be accepted, I'll create separte MR for it.

@lygstate lygstate marked this pull request as draft April 8, 2026 09:55
@lygstate
Copy link
Copy Markdown
Author

lygstate commented Apr 8, 2026

I mean, I can imagine that there is a ton of benefit to reduce the difference between the MSYS2 runtime and the Cygwin runtime to the bare minimum, to the point where even the path translation (which is probably the most distinguishing feature of the MSYS2 runtime) would be upstreamed to the Cygwin runtime as an opt-in, e.g. via a flag in /etc/nsswitch.conf. That would generate synergies between the Cygwin and the MSYS2 project, making it even easier to help each other out in meaningful ways. I'm all for going this direction.

The main target of this MR is rename rename msys-2.0.dll back to cygwin1.dll, and convert msys- prefix ino cyg, so that the whole MYS2-packages can remove many patches, the upstream patches of msys2-runtime into cygwin did not conflict with this MR, as this MR did not change the runtime much.

lygstate and others added 3 commits April 8, 2026 18:06
…les.

allow setting the system name to CYGWIN

We are currently trying to move our cygwin build environment closer
to cygwin and some autotools/bash based build systems call "uname -s"
to figure out the OS and in many cases only handle the cygwin case, so
we have to patch them.

With this instead of patching we can set MSYSTEM=CYGWIN and change
uname output that way.

The next step would be to always output CYGWIN in an msys env by default,
but for now this allows us to get rid of all the patches without
affecting users.
Alexpux and others added 4 commits April 8, 2026 19:19
Changes of winsup/cygwin/environ.cc is split from "Add functionality for changing OS name via MSYSTEM environment variables."
Changes of winsup/cygwin/exceptions.cc, winsup/utils/mingw/cygcheck.cc is split from "Rename dll from cygwin to msys"

known_env_vars is sorted, update it
Commit message for this code was:

* strace.cc (create_child): Set CYGWIN=noglob when starting new process so that

  Cygwin will leave already-parsed the command line alonw."

I can see no reason for it and it badly breaks the ability to use
strace.exe to investigate calling a Cygwin program from a Windows
program, for example:
strace mingw32-make.exe
.. where mingw32-make.exe finds sh.exe and uses it as the shell.
The reason it badly breaks this use-case is because dcrt0.cc depends
on globbing to happen to parse commandlines from Windows programs;
irrespective of whether they contain any glob patterns or not.

See quoted () comment:
"This must have been run from a Windows shell, so preserve
 quotes for globify to play with later."
This is split from "Rename dll from cygwin to msys"
@lygstate lygstate force-pushed the msys2-to-cygwin-3.6.7 branch from f5f360c to 95177a1 Compare April 8, 2026 11:31
This is a prepare for merge msys2 into cygwin
This is for bootstrap building msys2 as cygwin1.dll

This can be rebased before "Rename dll from cygwin to msys"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants